@axhub/genie 0.2.9 → 0.2.11

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 (96) hide show
  1. package/dist/api-docs.html +2 -2
  2. package/dist/assets/App-VH1wNUHs.js +259 -0
  3. package/dist/assets/{ReviewApp-C9K--AQE.js → ReviewApp-D_9EN4TM.js} +1 -1
  4. package/dist/assets/{_basePickBy-DR_8uFCo.js → _basePickBy-BDnj7-0Z.js} +1 -1
  5. package/dist/assets/{_baseUniq-D0njlQ_7.js → _baseUniq-Bl0JKOyl.js} +1 -1
  6. package/dist/assets/{arc-CKlr_Rec.js → arc-DY-4Kev3.js} +1 -1
  7. package/dist/assets/{architectureDiagram-2XIMDMQ5-BmO_uLUH.js → architectureDiagram-2XIMDMQ5-qw7crNVd.js} +1 -1
  8. package/dist/assets/{blockDiagram-WCTKOSBZ-DhAeO-56.js → blockDiagram-WCTKOSBZ-B9xg7ep3.js} +1 -1
  9. package/dist/assets/{c4Diagram-IC4MRINW-C67kFoXx.js → c4Diagram-IC4MRINW-H9xp3ytb.js} +1 -1
  10. package/dist/assets/channel-CyNUnRfc.js +1 -0
  11. package/dist/assets/{chunk-4BX2VUAB-mLLagvJi.js → chunk-4BX2VUAB-B3EVDUxI.js} +1 -1
  12. package/dist/assets/{chunk-55IACEB6-Lx-hOjlM.js → chunk-55IACEB6-CGv945ef.js} +1 -1
  13. package/dist/assets/{chunk-FMBD7UC4-Bt-XmVUV.js → chunk-FMBD7UC4-uAT4CKWM.js} +1 -1
  14. package/dist/assets/{chunk-JSJVCQXG-Cya6gaDV.js → chunk-JSJVCQXG-Cbvlpkf7.js} +1 -1
  15. package/dist/assets/{chunk-KX2RTZJC-Bd7Ig6tF.js → chunk-KX2RTZJC-CcqIuGat.js} +1 -1
  16. package/dist/assets/{chunk-NQ4KR5QH-5UAE0Vg-.js → chunk-NQ4KR5QH-CgrcsRuX.js} +1 -1
  17. package/dist/assets/{chunk-QZHKN3VN-BAxZ8m7w.js → chunk-QZHKN3VN-Cx0APOoV.js} +1 -1
  18. package/dist/assets/{chunk-WL4C6EOR-DjDPvUUP.js → chunk-WL4C6EOR-BbZirvBk.js} +1 -1
  19. package/dist/assets/classDiagram-VBA2DB6C-DxBtyz2A.js +1 -0
  20. package/dist/assets/classDiagram-v2-RAHNMMFH-DxBtyz2A.js +1 -0
  21. package/dist/assets/clone-C341l3d0.js +1 -0
  22. package/dist/assets/{cose-bilkent-S5V4N54A-D-60XrkJ.js → cose-bilkent-S5V4N54A-CrvmGFLD.js} +1 -1
  23. package/dist/assets/{dagre-KLK3FWXG-bqu3ZS4K.js → dagre-KLK3FWXG-C-W6VPjS.js} +1 -1
  24. package/dist/assets/{diagram-E7M64L7V-BueeqoYm.js → diagram-E7M64L7V-IP2q3bL0.js} +1 -1
  25. package/dist/assets/{diagram-IFDJBPK2-D4fDv2E7.js → diagram-IFDJBPK2-CQaL-XyV.js} +1 -1
  26. package/dist/assets/{diagram-P4PSJMXO-WqipY3fN.js → diagram-P4PSJMXO-BxBLThfv.js} +1 -1
  27. package/dist/assets/{erDiagram-INFDFZHY-D0oVnO-x.js → erDiagram-INFDFZHY-Dyl7bJTt.js} +1 -1
  28. package/dist/assets/{flowDiagram-PKNHOUZH-DzbGyxrr.js → flowDiagram-PKNHOUZH-B7NFMgFK.js} +1 -1
  29. package/dist/assets/{ganttDiagram-A5KZAMGK-BwhbbgCP.js → ganttDiagram-A5KZAMGK-hReWSDu2.js} +1 -1
  30. package/dist/assets/{gitGraphDiagram-K3NZZRJ6-DZgAh_KM.js → gitGraphDiagram-K3NZZRJ6-gVgcr0ST.js} +1 -1
  31. package/dist/assets/{graph-DzKos-N0.js → graph-DNDiJhTn.js} +1 -1
  32. package/dist/assets/{highlighted-body-TPN3WLV5-CKDMgz3X.js → highlighted-body-TPN3WLV5-DclLmTou.js} +1 -1
  33. package/dist/assets/index-DBkz_W_P.css +1 -0
  34. package/dist/assets/index-DdRyoXKh.js +2 -0
  35. package/dist/assets/{infoDiagram-LFFYTUFH-BFicZbTf.js → infoDiagram-LFFYTUFH-CqQOOzDA.js} +1 -1
  36. package/dist/assets/{ishikawaDiagram-PHBUUO56-CtihxDxl.js → ishikawaDiagram-PHBUUO56-CZ0iLiHg.js} +1 -1
  37. package/dist/assets/{journeyDiagram-4ABVD52K-Du00J8_d.js → journeyDiagram-4ABVD52K-DdfYKfNh.js} +1 -1
  38. package/dist/assets/{kanban-definition-K7BYSVSG-BJi9S0iQ.js → kanban-definition-K7BYSVSG-C5Vf32u6.js} +1 -1
  39. package/dist/assets/{layout-B80Sityu.js → layout-rvTEu2KS.js} +1 -1
  40. package/dist/assets/{linear-sRQLOf5H.js → linear-CD9SiYze.js} +1 -1
  41. package/dist/assets/{mermaid-O7DHMXV3-CBuVs4eJ.js → mermaid-O7DHMXV3-OZ8qWWwa.js} +167 -157
  42. package/dist/assets/{mindmap-definition-YRQLILUH-C5IL_xi-.js → mindmap-definition-YRQLILUH-CQxrLNVc.js} +1 -1
  43. package/dist/assets/{pieDiagram-SKSYHLDU-CeTwlJ8z.js → pieDiagram-SKSYHLDU-XgAUByWg.js} +1 -1
  44. package/dist/assets/{quadrantDiagram-337W2JSQ-COfUcLWt.js → quadrantDiagram-337W2JSQ-CH16ls7G.js} +1 -1
  45. package/dist/assets/{requirementDiagram-Z7DCOOCP-DSb-CJ5B.js → requirementDiagram-Z7DCOOCP-B_kQO06L.js} +1 -1
  46. package/dist/assets/{sankeyDiagram-WA2Y5GQK-8jtuVb45.js → sankeyDiagram-WA2Y5GQK-ofe78CyS.js} +1 -1
  47. package/dist/assets/{sequenceDiagram-2WXFIKYE-C2VpkMwA.js → sequenceDiagram-2WXFIKYE-Ckbxwny6.js} +1 -1
  48. package/dist/assets/{stateDiagram-RAJIS63D-fmwMqxxc.js → stateDiagram-RAJIS63D-DNtzCk14.js} +1 -1
  49. package/dist/assets/stateDiagram-v2-FVOUBMTO-B3VPhiE1.js +1 -0
  50. package/dist/assets/{timeline-definition-YZTLITO2-Dx1hP5lg.js → timeline-definition-YZTLITO2-zT6CklKt.js} +1 -1
  51. package/dist/assets/{treemap-KZPCXAKY-CkLOdYCZ.js → treemap-KZPCXAKY-y0U2c3xG.js} +1 -1
  52. package/dist/assets/vendor-codemirror-CMHSJ_9p.js +9 -0
  53. package/dist/assets/{vennDiagram-LZ73GAT5-D6KWcnln.js → vennDiagram-LZ73GAT5-xKj3SjYG.js} +1 -1
  54. package/dist/assets/{xychartDiagram-JWTSCODW-6fh6qmzN.js → xychartDiagram-JWTSCODW-Da_qyEoX.js} +1 -1
  55. package/dist/index.html +3 -3
  56. package/package.json +6 -5
  57. package/server/acp-runtime/client.js +120 -14
  58. package/server/acp-runtime/index.js +54 -0
  59. package/server/acp-runtime/registry.js +2 -2
  60. package/server/acp-runtime/session-store.js +75 -1
  61. package/server/cli.js +32 -8
  62. package/server/database/db.js +20 -0
  63. package/server/external-agent/ws.js +477 -24
  64. package/server/index.js +89 -147
  65. package/server/lan-access/core.js +79 -0
  66. package/server/lan-access/state.js +102 -0
  67. package/server/middleware/auth.js +57 -14
  68. package/server/projects.js +442 -535
  69. package/server/routes/auth.js +24 -4
  70. package/server/routes/cli-auth.js +21 -25
  71. package/server/routes/codex.js +84 -298
  72. package/server/routes/commands.js +335 -407
  73. package/server/routes/lan-access.js +231 -0
  74. package/server/routes/projects.js +154 -158
  75. package/server/routes/session-core.js +13 -7
  76. package/server/routes/settings.js +113 -99
  77. package/server/session-core/eventStore.js +15 -2
  78. package/server/session-core/providerAdapters.js +28 -28
  79. package/server/session-core/sessionListMerge.js +47 -0
  80. package/shared/conversationEvents.js +96 -1
  81. package/shared/modelConstants.js +79 -99
  82. package/dist/assets/App-GBcTeeUS.js +0 -460
  83. package/dist/assets/channel-V3MBjKys.js +0 -1
  84. package/dist/assets/classDiagram-VBA2DB6C-C790yYiY.js +0 -1
  85. package/dist/assets/classDiagram-v2-RAHNMMFH-C790yYiY.js +0 -1
  86. package/dist/assets/clone-BbMGfZwt.js +0 -1
  87. package/dist/assets/index-DiQlHzGj.js +0 -2
  88. package/dist/assets/index-Drat2nB9.css +0 -1
  89. package/dist/assets/stateDiagram-v2-FVOUBMTO-9GGXVWrR.js +0 -1
  90. package/dist/assets/vendor-codemirror-BxPY6emf.js +0 -39
  91. package/server/routes/git.js +0 -1110
  92. package/server/routes/mcp-utils.js +0 -48
  93. package/server/routes/mcp.js +0 -536
  94. package/server/routes/taskmaster.js +0 -1963
  95. package/server/utils/mcp-detector.js +0 -198
  96. package/server/utils/taskmaster-websocket.js +0 -129
@@ -0,0 +1,259 @@
1
+ import{j as n}from"./vendor-codemirror-CMHSJ_9p.js";import{a as i,c as sd,R as wt,d as Jr,g as ui,B as ad,e as id,f as So,u as ld,h as cd,i as dd,j as ud}from"./vendor-react-xmA_f8ig.js";import{bJ as Ve,bK as Xn,bL as Wo,bM as pi,bN as qe,bO as Yt,bP as gs,bQ as mi,bR as an,bS as fi,bT as pd,bU as md,bV as Sn,bW as fd,bX as hd,bY as xd,bZ as gd,b_ as vd,b$ as yd,c0 as bd,c1 as wd,c2 as kd,c3 as jd,c4 as xt,c5 as vs,c6 as Et,c7 as jn,c8 as Sd,c9 as Le,ca as Tt,cb as hi,cc as Ko,cd as xi,ce as Nd,cf as gi,cg as Cd,ch as Ed,ci as _d,cj as Ad,ck as Id,cl as Td,cm as Pd,cn as Rd,co as Md,cp as Dd,cq as Ld,cr as Od,cs as Fd,ct as Ho,cu as qo,cv as Go,cw as Yr,cx as $d,cy as zd,cz as Bd,cA as Ud,cB as Wd,cC as Kd,cD as Fn,cE as Hd,cF as vi,cG as qd,cH as Gd,cI as Vd,cJ as Jd,cK as No,I as Yd,T as Xd,U as Qd,cL as Zd}from"./mermaid-O7DHMXV3-OZ8qWWwa.js";import{r as eu,a as tu,b as nu}from"./vendor-xterm-DfaPXD3y.js";import{l as Js,i as ru}from"./index-DdRyoXKh.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 ou=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],su=Ve("arrow-left",ou);/**
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 au=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],iu=Ve("chevron-left",au);/**
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 lu=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],yi=Ve("chevron-right",lu);/**
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 cu=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ys=Ve("circle-check-big",cu);/**
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 du=[["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"}]],Tr=Ve("ellipsis",du);/**
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 uu=[["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"}]],Xr=Ve("external-link",uu);/**
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 pu=[["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"}]],mu=Ve("eye",pu);/**
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 fu=[["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"}]],hu=Ve("eye-off",fu);/**
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 xu=[["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"}]],gu=Ve("file-pen-line",xu);/**
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 vu=[["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"}]],yu=Ve("file-plus-2",vu);/**
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 bu=[["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"}]],wu=Ve("file-search",bu);/**
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 ku=[["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"}]],cr=Ve("folder-open",ku);/**
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 ju=[["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"}]],Gn=Ve("folder-plus",ju);/**
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 Su=[["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"}]],Co=Ve("folder",Su);/**
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 Nu=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],Cu=Ve("hard-drive",Nu);/**
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 Eu=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],Xs=Ve("key-round",Eu);/**
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 _u=[["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"}]],bi=Ve("key",_u);/**
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 Au=[["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"}]],Iu=Ve("languages",Au);/**
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 Tu=[["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"}]],Qs=Ve("list-todo",Tu);/**
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 Pu=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],Ru=Ve("lock-keyhole",Pu);/**
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 Mu=[["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"}]],Du=Ve("message-square-plus",Mu);/**
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 Lu=[["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"}]],ys=Ve("message-square",Lu);/**
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 Ou=[["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"}]],Zs=Ve("pen-line",Ou);/**
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 Fu=[["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"}]],ea=Ve("pen",Fu);/**
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 $u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],hr=Ve("plus",$u);/**
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 zu=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],Pr=Ve("qr-code",zu);/**
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 Bu=[["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"}]],Vo=Ve("refresh-cw",Bu);/**
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 Uu=[["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"}]],Wu=Ve("settings",Uu);/**
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 Ku=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Jo=Ve("shield-check",Ku);/**
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 Hu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],qu=Ve("shield",Hu);/**
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 Gu=[["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"}]],Vu=Ve("square-terminal",Gu);/**
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 Ju=[["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"}]],ta=Ve("star",Ju);/**
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 Yu=[["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"}]],In=Ve("trash-2",Yu);/**
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 Xu=[["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"}]],Qr=Ve("triangle-alert",Xu);/**
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 Qu=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],Zu=Ve("unlink",Qu);/**
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 ep=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],tp=Ve("wifi",ep);/**
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 np=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=Ve("x",np);function rp(e,t=[]){let r=[];function o(a,l){const c=i.createContext(l),d=r.length;r=[...r,l];const u=m=>{const{scope:f,children:x,...h}=m,N=f?.[e]?.[d]||c,w=i.useMemo(()=>h,Object.values(h));return n.jsx(N.Provider,{value:w,children:x})};u.displayName=a+"Provider";function p(m,f){const x=f?.[e]?.[d]||c,h=i.useContext(x);if(h)return h;if(l!==void 0)return l;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const s=()=>{const a=r.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,op(s,...t)]}function op(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return r.scopeName=t.scopeName,r}function wi(e){const t=sp(e),r=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(ip);if(d){const u=d.props.children,p=c.map(m=>m===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:m);return n.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,p):null})}return n.jsx(t,{...l,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function sp(e){const t=i.forwardRef((r,o)=>{const{children:s,...a}=r;if(i.isValidElement(s)){const l=cp(s),c=lp(a,s.props);return s.type!==i.Fragment&&(c.ref=o?Xn(o,l):l),i.cloneElement(s,c)}return i.Children.count(s)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ap=Symbol("radix.slottable");function ip(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ap}function lp(e,t){const r={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?r[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(r[o]=s):o==="style"?r[o]={...s,...a}:o==="className"&&(r[o]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function cp(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var dp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xr=dp.reduce((e,t)=>{const r=wi(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function up(e,t){e&&sd.flushSync(()=>e.dispatchEvent(t))}function pp(e,t=[]){let r=[];function o(a,l){const c=i.createContext(l),d=r.length;r=[...r,l];const u=m=>{const{scope:f,children:x,...h}=m,N=f?.[e]?.[d]||c,w=i.useMemo(()=>h,Object.values(h));return n.jsx(N.Provider,{value:w,children:x})};u.displayName=a+"Provider";function p(m,f){const x=f?.[e]?.[d]||c,h=i.useContext(x);if(h)return h;if(l!==void 0)return l;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const s=()=>{const a=r.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,mp(s,...t)]}function mp(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return r.scopeName=t.scopeName,r}function fp(e){const t=hp(e),r=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(gp);if(d){const u=d.props.children,p=c.map(m=>m===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:m);return n.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,p):null})}return n.jsx(t,{...l,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function hp(e){const t=i.forwardRef((r,o)=>{const{children:s,...a}=r;if(i.isValidElement(s)){const l=yp(s),c=vp(a,s.props);return s.type!==i.Fragment&&(c.ref=o?Xn(o,l):l),i.cloneElement(s,c)}return i.Children.count(s)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var xp=Symbol("radix.slottable");function gp(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xp}function vp(e,t){const r={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?r[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(r[o]=s):o==="style"?r[o]={...s,...a}:o==="className"&&(r[o]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function yp(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var bp=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ki=bp.reduce((e,t)=>{const r=fp(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),Eo="rovingFocusGroup.onEntryFocus",wp={bubbles:!1,cancelable:!0},gr="RovingFocusGroup",[Yo,ji,kp]=pi(gr),[jp,Si]=pp(gr,[kp]),[Sp,Np]=jp(gr),Ni=i.forwardRef((e,t)=>n.jsx(Yo.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Yo.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Cp,{...e,ref:t})})}));Ni.displayName=gr;var Cp=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:o,loop:s=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...m}=e,f=i.useRef(null),x=Yt(t,f),h=gs(a),[N,w]=mi({prop:l,defaultProp:c??null,onChange:d,caller:gr}),[S,$]=i.useState(!1),F=an(u),Z=ji(r),z=i.useRef(!1),[R,E]=i.useState(0);return i.useEffect(()=>{const B=f.current;if(B)return B.addEventListener(Eo,F),()=>B.removeEventListener(Eo,F)},[F]),n.jsx(Sp,{scope:r,orientation:o,dir:h,loop:s,currentTabStopId:N,onItemFocus:i.useCallback(B=>w(B),[w]),onItemShiftTab:i.useCallback(()=>$(!0),[]),onFocusableItemAdd:i.useCallback(()=>E(B=>B+1),[]),onFocusableItemRemove:i.useCallback(()=>E(B=>B-1),[]),children:n.jsx(ki.div,{tabIndex:S||R===0?-1:0,"data-orientation":o,...m,ref:x,style:{outline:"none",...e.style},onMouseDown:qe(e.onMouseDown,()=>{z.current=!0}),onFocus:qe(e.onFocus,B=>{const I=!z.current;if(B.target===B.currentTarget&&I&&!S){const Y=new CustomEvent(Eo,wp);if(B.currentTarget.dispatchEvent(Y),!Y.defaultPrevented){const _=Z().filter(de=>de.focusable),re=_.find(de=>de.active),ie=_.find(de=>de.id===N),ae=[re,ie,..._].filter(Boolean).map(de=>de.ref.current);_i(ae,p)}}z.current=!1}),onBlur:qe(e.onBlur,()=>$(!1))})})}),Ci="RovingFocusGroupItem",Ei=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:o=!0,active:s=!1,tabStopId:a,children:l,...c}=e,d=Wo(),u=a||d,p=Np(Ci,r),m=p.currentTabStopId===u,f=ji(r),{onFocusableItemAdd:x,onFocusableItemRemove:h,currentTabStopId:N}=p;return i.useEffect(()=>{if(o)return x(),()=>h()},[o,x,h]),n.jsx(Yo.ItemSlot,{scope:r,id:u,focusable:o,active:s,children:n.jsx(ki.span,{tabIndex:m?0:-1,"data-orientation":p.orientation,...c,ref:t,onMouseDown:qe(e.onMouseDown,w=>{o?p.onItemFocus(u):w.preventDefault()}),onFocus:qe(e.onFocus,()=>p.onItemFocus(u)),onKeyDown:qe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const S=Ap(w,p.orientation,p.dir);if(S!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let F=f().filter(Z=>Z.focusable).map(Z=>Z.ref.current);if(S==="last")F.reverse();else if(S==="prev"||S==="next"){S==="prev"&&F.reverse();const Z=F.indexOf(w.currentTarget);F=p.loop?Ip(F,Z+1):F.slice(Z+1)}setTimeout(()=>_i(F))}}),children:typeof l=="function"?l({isCurrentTabStop:m,hasTabStop:N!=null}):l})})});Ei.displayName=Ci;var Ep={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _p(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ap(e,t,r){const o=_p(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Ep[o]}function _i(e,t=!1){const r=document.activeElement;for(const o of e)if(o===r||(o.focus({preventScroll:t}),document.activeElement!==r))return}function Ip(e,t){return e.map((r,o)=>e[(t+o)%e.length])}var Tp=Ni,Pp=Ei,Xo=["Enter"," "],Rp=["ArrowDown","PageUp","Home"],Ai=["ArrowUp","PageDown","End"],Mp=[...Rp,...Ai],Dp={ltr:[...Xo,"ArrowRight"],rtl:[...Xo,"ArrowLeft"]},Lp={ltr:["ArrowLeft"],rtl:["ArrowRight"]},vr="Menu",[ur,Op,Fp]=pi(vr),[$n,Ii]=rp(vr,[Fp,fi,Si]),uo=fi(),Ti=Si(),[$p,zn]=$n(vr),[zp,yr]=$n(vr),Pi=e=>{const{__scopeMenu:t,open:r=!1,children:o,dir:s,onOpenChange:a,modal:l=!0}=e,c=uo(t),[d,u]=i.useState(null),p=i.useRef(!1),m=an(a),f=gs(s);return i.useEffect(()=>{const x=()=>{p.current=!0,document.addEventListener("pointerdown",h,{capture:!0,once:!0}),document.addEventListener("pointermove",h,{capture:!0,once:!0})},h=()=>p.current=!1;return document.addEventListener("keydown",x,{capture:!0}),()=>{document.removeEventListener("keydown",x,{capture:!0}),document.removeEventListener("pointerdown",h,{capture:!0}),document.removeEventListener("pointermove",h,{capture:!0})}},[]),n.jsx(pd,{...c,children:n.jsx($p,{scope:t,open:r,onOpenChange:m,content:d,onContentChange:u,children:n.jsx(zp,{scope:t,onClose:i.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:p,dir:f,modal:l,children:o})})})};Pi.displayName=vr;var Bp="MenuAnchor",bs=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e,s=uo(r);return n.jsx(md,{...s,...o,ref:t})});bs.displayName=Bp;var ws="MenuPortal",[Up,Ri]=$n(ws,{forceMount:void 0}),Mi=e=>{const{__scopeMenu:t,forceMount:r,children:o,container:s}=e,a=zn(ws,t);return n.jsx(Up,{scope:t,forceMount:r,children:n.jsx(Sn,{present:r||a.open,children:n.jsx(fd,{asChild:!0,container:s,children:o})})})};Mi.displayName=ws;var Jt="MenuContent",[Wp,ks]=$n(Jt),Di=i.forwardRef((e,t)=>{const r=Ri(Jt,e.__scopeMenu),{forceMount:o=r.forceMount,...s}=e,a=zn(Jt,e.__scopeMenu),l=yr(Jt,e.__scopeMenu);return n.jsx(ur.Provider,{scope:e.__scopeMenu,children:n.jsx(Sn,{present:o||a.open,children:n.jsx(ur.Slot,{scope:e.__scopeMenu,children:l.modal?n.jsx(Kp,{...s,ref:t}):n.jsx(Hp,{...s,ref:t})})})})}),Kp=i.forwardRef((e,t)=>{const r=zn(Jt,e.__scopeMenu),o=i.useRef(null),s=Yt(t,o);return i.useEffect(()=>{const a=o.current;if(a)return hd(a)},[]),n.jsx(js,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:qe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Hp=i.forwardRef((e,t)=>{const r=zn(Jt,e.__scopeMenu);return n.jsx(js,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),qp=wi("MenuContent.ScrollLock"),js=i.forwardRef((e,t)=>{const{__scopeMenu:r,loop:o=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:f,onDismiss:x,disableOutsideScroll:h,...N}=e,w=zn(Jt,r),S=yr(Jt,r),$=uo(r),F=Ti(r),Z=Op(r),[z,R]=i.useState(null),E=i.useRef(null),B=Yt(t,E,w.onContentChange),I=i.useRef(0),Y=i.useRef(""),_=i.useRef(0),re=i.useRef(null),ie=i.useRef("right"),V=i.useRef(0),ae=h?gd:i.Fragment,de=h?{as:qp,allowPinchZoom:!0}:void 0,ve=U=>{const le=Y.current+U,oe=Z().filter(ye=>!ye.disabled),Te=document.activeElement,te=oe.find(ye=>ye.ref.current===Te)?.textValue,Q=oe.map(ye=>ye.textValue),we=om(Q,le,te),Ie=oe.find(ye=>ye.textValue===we)?.ref.current;(function ye(Oe){Y.current=Oe,window.clearTimeout(I.current),Oe!==""&&(I.current=window.setTimeout(()=>ye(""),1e3))})(le),Ie&&setTimeout(()=>Ie.focus())};i.useEffect(()=>()=>window.clearTimeout(I.current),[]),xd();const fe=i.useCallback(U=>ie.current===re.current?.side&&am(U,re.current?.area),[]);return n.jsx(Wp,{scope:r,searchRef:Y,onItemEnter:i.useCallback(U=>{fe(U)&&U.preventDefault()},[fe]),onItemLeave:i.useCallback(U=>{fe(U)||(E.current?.focus(),R(null))},[fe]),onTriggerLeave:i.useCallback(U=>{fe(U)&&U.preventDefault()},[fe]),pointerGraceTimerRef:_,onPointerGraceIntentChange:i.useCallback(U=>{re.current=U},[]),children:n.jsx(ae,{...de,children:n.jsx(vd,{asChild:!0,trapped:s,onMountAutoFocus:qe(a,U=>{U.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:n.jsx(yd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:f,onDismiss:x,children:n.jsx(Tp,{asChild:!0,...F,dir:S.dir,orientation:"vertical",loop:o,currentTabStopId:z,onCurrentTabStopIdChange:R,onEntryFocus:qe(d,U=>{S.isUsingKeyboardRef.current||U.preventDefault()}),preventScrollOnEntryFocus:!0,children:n.jsx(bd,{role:"menu","aria-orientation":"vertical","data-state":Xi(w.open),"data-radix-menu-content":"",dir:S.dir,...$,...N,ref:B,style:{outline:"none",...N.style},onKeyDown:qe(N.onKeyDown,U=>{const oe=U.target.closest("[data-radix-menu-content]")===U.currentTarget,Te=U.ctrlKey||U.altKey||U.metaKey,te=U.key.length===1;oe&&(U.key==="Tab"&&U.preventDefault(),!Te&&te&&ve(U.key));const Q=E.current;if(U.target!==Q||!Mp.includes(U.key))return;U.preventDefault();const Ie=Z().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);Ai.includes(U.key)&&Ie.reverse(),nm(Ie)}),onBlur:qe(e.onBlur,U=>{U.currentTarget.contains(U.target)||(window.clearTimeout(I.current),Y.current="")}),onPointerMove:qe(e.onPointerMove,pr(U=>{const le=U.target,oe=V.current!==U.clientX;if(U.currentTarget.contains(le)&&oe){const Te=U.clientX>V.current?"right":"left";ie.current=Te,V.current=U.clientX}}))})})})})})})});Di.displayName=Jt;var Gp="MenuGroup",Ss=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e;return n.jsx(xr.div,{role:"group",...o,ref:t})});Ss.displayName=Gp;var Vp="MenuLabel",Li=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e;return n.jsx(xr.div,{...o,ref:t})});Li.displayName=Vp;var Zr="MenuItem",na="menu.itemSelect",po=i.forwardRef((e,t)=>{const{disabled:r=!1,onSelect:o,...s}=e,a=i.useRef(null),l=yr(Zr,e.__scopeMenu),c=ks(Zr,e.__scopeMenu),d=Yt(t,a),u=i.useRef(!1),p=()=>{const m=a.current;if(!r&&m){const f=new CustomEvent(na,{bubbles:!0,cancelable:!0});m.addEventListener(na,x=>o?.(x),{once:!0}),up(m,f),f.defaultPrevented?u.current=!1:l.onClose()}};return n.jsx(Oi,{...s,ref:d,disabled:r,onClick:qe(e.onClick,p),onPointerDown:m=>{e.onPointerDown?.(m),u.current=!0},onPointerUp:qe(e.onPointerUp,m=>{u.current||m.currentTarget?.click()}),onKeyDown:qe(e.onKeyDown,m=>{const f=c.searchRef.current!=="";r||f&&m.key===" "||Xo.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});po.displayName=Zr;var Oi=i.forwardRef((e,t)=>{const{__scopeMenu:r,disabled:o=!1,textValue:s,...a}=e,l=ks(Zr,r),c=Ti(r),d=i.useRef(null),u=Yt(t,d),[p,m]=i.useState(!1),[f,x]=i.useState("");return i.useEffect(()=>{const h=d.current;h&&x((h.textContent??"").trim())},[a.children]),n.jsx(ur.ItemSlot,{scope:r,disabled:o,textValue:s??f,children:n.jsx(Pp,{asChild:!0,...c,focusable:!o,children:n.jsx(xr.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...a,ref:u,onPointerMove:qe(e.onPointerMove,pr(h=>{o?l.onItemLeave(h):(l.onItemEnter(h),h.defaultPrevented||h.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:qe(e.onPointerLeave,pr(h=>l.onItemLeave(h))),onFocus:qe(e.onFocus,()=>m(!0)),onBlur:qe(e.onBlur,()=>m(!1))})})})}),Jp="MenuCheckboxItem",Fi=i.forwardRef((e,t)=>{const{checked:r=!1,onCheckedChange:o,...s}=e;return n.jsx(Wi,{scope:e.__scopeMenu,checked:r,children:n.jsx(po,{role:"menuitemcheckbox","aria-checked":eo(r)?"mixed":r,...s,ref:t,"data-state":Cs(r),onSelect:qe(s.onSelect,()=>o?.(eo(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Fi.displayName=Jp;var $i="MenuRadioGroup",[Yp,Xp]=$n($i,{value:void 0,onValueChange:()=>{}}),zi=i.forwardRef((e,t)=>{const{value:r,onValueChange:o,...s}=e,a=an(o);return n.jsx(Yp,{scope:e.__scopeMenu,value:r,onValueChange:a,children:n.jsx(Ss,{...s,ref:t})})});zi.displayName=$i;var Bi="MenuRadioItem",Ui=i.forwardRef((e,t)=>{const{value:r,...o}=e,s=Xp(Bi,e.__scopeMenu),a=r===s.value;return n.jsx(Wi,{scope:e.__scopeMenu,checked:a,children:n.jsx(po,{role:"menuitemradio","aria-checked":a,...o,ref:t,"data-state":Cs(a),onSelect:qe(o.onSelect,()=>s.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});Ui.displayName=Bi;var Ns="MenuItemIndicator",[Wi,Qp]=$n(Ns,{checked:!1}),Ki=i.forwardRef((e,t)=>{const{__scopeMenu:r,forceMount:o,...s}=e,a=Qp(Ns,r);return n.jsx(Sn,{present:o||eo(a.checked)||a.checked===!0,children:n.jsx(xr.span,{...s,ref:t,"data-state":Cs(a.checked)})})});Ki.displayName=Ns;var Zp="MenuSeparator",Hi=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e;return n.jsx(xr.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})});Hi.displayName=Zp;var em="MenuArrow",qi=i.forwardRef((e,t)=>{const{__scopeMenu:r,...o}=e,s=uo(r);return n.jsx(wd,{...s,...o,ref:t})});qi.displayName=em;var tm="MenuSub",[Jv,Gi]=$n(tm),ir="MenuSubTrigger",Vi=i.forwardRef((e,t)=>{const r=zn(ir,e.__scopeMenu),o=yr(ir,e.__scopeMenu),s=Gi(ir,e.__scopeMenu),a=ks(ir,e.__scopeMenu),l=i.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},p=i.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return i.useEffect(()=>p,[p]),i.useEffect(()=>{const m=c.current;return()=>{window.clearTimeout(m),d(null)}},[c,d]),n.jsx(bs,{asChild:!0,...u,children:n.jsx(Oi,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":Xi(r.open),...e,ref:Xn(t,s.onTriggerChange),onClick:m=>{e.onClick?.(m),!(e.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:qe(e.onPointerMove,pr(m=>{a.onItemEnter(m),!m.defaultPrevented&&!e.disabled&&!r.open&&!l.current&&(a.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{r.onOpenChange(!0),p()},100))})),onPointerLeave:qe(e.onPointerLeave,pr(m=>{p();const f=r.content?.getBoundingClientRect();if(f){const x=r.content?.dataset.side,h=x==="right",N=h?-5:5,w=f[h?"left":"right"],S=f[h?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+N,y:m.clientY},{x:w,y:f.top},{x:S,y:f.top},{x:S,y:f.bottom},{x:w,y:f.bottom}],side:x}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:qe(e.onKeyDown,m=>{const f=a.searchRef.current!=="";e.disabled||f&&m.key===" "||Dp[o.dir].includes(m.key)&&(r.onOpenChange(!0),r.content?.focus(),m.preventDefault())})})})});Vi.displayName=ir;var Ji="MenuSubContent",Yi=i.forwardRef((e,t)=>{const r=Ri(Jt,e.__scopeMenu),{forceMount:o=r.forceMount,...s}=e,a=zn(Jt,e.__scopeMenu),l=yr(Jt,e.__scopeMenu),c=Gi(Ji,e.__scopeMenu),d=i.useRef(null),u=Yt(t,d);return n.jsx(ur.Provider,{scope:e.__scopeMenu,children:n.jsx(Sn,{present:o||a.open,children:n.jsx(ur.Slot,{scope:e.__scopeMenu,children:n.jsx(js,{id:c.contentId,"aria-labelledby":c.triggerId,...s,ref:u,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{l.isUsingKeyboardRef.current&&d.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:qe(e.onFocusOutside,p=>{p.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:qe(e.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:qe(e.onKeyDown,p=>{const m=p.currentTarget.contains(p.target),f=Lp[l.dir].includes(p.key);m&&f&&(a.onOpenChange(!1),c.trigger?.focus(),p.preventDefault())})})})})})});Yi.displayName=Ji;function Xi(e){return e?"open":"closed"}function eo(e){return e==="indeterminate"}function Cs(e){return eo(e)?"indeterminate":e?"checked":"unchecked"}function nm(e){const t=document.activeElement;for(const r of e)if(r===t||(r.focus(),document.activeElement!==t))return}function rm(e,t){return e.map((r,o)=>e[(t+o)%e.length])}function om(e,t,r){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=r?e.indexOf(r):-1;let l=rm(e,Math.max(a,0));s.length===1&&(l=l.filter(u=>u!==r));const d=l.find(u=>u.toLowerCase().startsWith(s.toLowerCase()));return d!==r?d:void 0}function sm(e,t){const{x:r,y:o}=e;let s=!1;for(let a=0,l=t.length-1;a<t.length;l=a++){const c=t[a],d=t[l],u=c.x,p=c.y,m=d.x,f=d.y;p>o!=f>o&&r<(m-u)*(o-p)/(f-p)+u&&(s=!s)}return s}function am(e,t){if(!t)return!1;const r={x:e.clientX,y:e.clientY};return sm(r,t)}function pr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var im=Pi,lm=bs,cm=Mi,dm=Di,um=Ss,pm=Li,mm=po,fm=Fi,hm=zi,xm=Ui,gm=Ki,vm=Hi,ym=qi,bm=Vi,wm=Yi;function km(e,t=[]){let r=[];function o(a,l){const c=i.createContext(l),d=r.length;r=[...r,l];const u=m=>{const{scope:f,children:x,...h}=m,N=f?.[e]?.[d]||c,w=i.useMemo(()=>h,Object.values(h));return n.jsx(N.Provider,{value:w,children:x})};u.displayName=a+"Provider";function p(m,f){const x=f?.[e]?.[d]||c,h=i.useContext(x);if(h)return h;if(l!==void 0)return l;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const s=()=>{const a=r.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,jm(s,...t)]}function jm(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return r.scopeName=t.scopeName,r}function Sm(e){const t=Nm(e),r=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(Em);if(d){const u=d.props.children,p=c.map(m=>m===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:m);return n.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,p):null})}return n.jsx(t,{...l,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function Nm(e){const t=i.forwardRef((r,o)=>{const{children:s,...a}=r;if(i.isValidElement(s)){const l=Am(s),c=_m(a,s.props);return s.type!==i.Fragment&&(c.ref=o?Xn(o,l):l),i.cloneElement(s,c)}return i.Children.count(s)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Cm=Symbol("radix.slottable");function Em(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Cm}function _m(e,t){const r={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?r[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(r[o]=s):o==="style"?r[o]={...s,...a}:o==="className"&&(r[o]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function Am(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Im=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Tm=Im.reduce((e,t)=>{const r=Sm(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),mo="DropdownMenu",[Pm,Yv]=km(mo,[Ii]),Rt=Ii(),[Rm,Qi]=Pm(mo),Zi=e=>{const{__scopeDropdownMenu:t,children:r,dir:o,open:s,defaultOpen:a,onOpenChange:l,modal:c=!0}=e,d=Rt(t),u=i.useRef(null),[p,m]=mi({prop:s,defaultProp:a??!1,onChange:l,caller:mo});return n.jsx(Rm,{scope:t,triggerId:Wo(),triggerRef:u,contentId:Wo(),open:p,onOpenChange:m,onOpenToggle:i.useCallback(()=>m(f=>!f),[m]),modal:c,children:n.jsx(im,{...d,open:p,onOpenChange:m,dir:o,modal:c,children:r})})};Zi.displayName=mo;var el="DropdownMenuTrigger",tl=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,disabled:o=!1,...s}=e,a=Qi(el,r),l=Rt(r);return n.jsx(lm,{asChild:!0,...l,children:n.jsx(Tm.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":o?"":void 0,disabled:o,...s,ref:Xn(t,a.triggerRef),onPointerDown:qe(e.onPointerDown,c=>{!o&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:qe(e.onKeyDown,c=>{o||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});tl.displayName=el;var Mm="DropdownMenuPortal",nl=e=>{const{__scopeDropdownMenu:t,...r}=e,o=Rt(t);return n.jsx(cm,{...o,...r})};nl.displayName=Mm;var rl="DropdownMenuContent",ol=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Qi(rl,r),a=Rt(r),l=i.useRef(!1);return n.jsx(dm,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...o,ref:t,onCloseAutoFocus:qe(e.onCloseAutoFocus,c=>{l.current||s.triggerRef.current?.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:qe(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!s.modal||p)&&(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)"}})});ol.displayName=rl;var Dm="DropdownMenuGroup",Lm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(um,{...s,...o,ref:t})});Lm.displayName=Dm;var Om="DropdownMenuLabel",Fm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(pm,{...s,...o,ref:t})});Fm.displayName=Om;var $m="DropdownMenuItem",sl=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(mm,{...s,...o,ref:t})});sl.displayName=$m;var zm="DropdownMenuCheckboxItem",Bm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(fm,{...s,...o,ref:t})});Bm.displayName=zm;var Um="DropdownMenuRadioGroup",Wm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(hm,{...s,...o,ref:t})});Wm.displayName=Um;var Km="DropdownMenuRadioItem",Hm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(xm,{...s,...o,ref:t})});Hm.displayName=Km;var qm="DropdownMenuItemIndicator",Gm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(gm,{...s,...o,ref:t})});Gm.displayName=qm;var Vm="DropdownMenuSeparator",al=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(vm,{...s,...o,ref:t})});al.displayName=Vm;var Jm="DropdownMenuArrow",Ym=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(ym,{...s,...o,ref:t})});Ym.displayName=Jm;var Xm="DropdownMenuSubTrigger",Qm=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(bm,{...s,...o,ref:t})});Qm.displayName=Xm;var Zm="DropdownMenuSubContent",ef=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...o}=e,s=Rt(r);return n.jsx(wm,{...s,...o,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ef.displayName=Zm;var Rr=Zi,Mr=tl,Dr=nl,Lr=ol,on=sl,ra=al;function tf(e){const t=nf(e),r=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(of);if(d){const u=d.props.children,p=c.map(m=>m===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:m);return n.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,p):null})}return n.jsx(t,{...l,ref:s,children:a})});return r.displayName=`${e}.Slot`,r}function nf(e){const t=i.forwardRef((r,o)=>{const{children:s,...a}=r;if(i.isValidElement(s)){const l=af(s),c=sf(a,s.props);return s.type!==i.Fragment&&(c.ref=o?Xn(o,l):l),i.cloneElement(s,c)}return i.Children.count(s)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var rf=Symbol("radix.slottable");function of(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rf}function sf(e,t){const r={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?r[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(r[o]=s):o==="style"?r[o]={...s,...a}:o==="className"&&(r[o]=[s,a].filter(Boolean).join(" "))}return{...e,...r}}function af(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var lf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],br=lf.reduce((e,t)=>{const r=tf(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function cf(e,t=[]){let r=[];function o(a,l){const c=i.createContext(l),d=r.length;r=[...r,l];const u=m=>{const{scope:f,children:x,...h}=m,N=f?.[e]?.[d]||c,w=i.useMemo(()=>h,Object.values(h));return n.jsx(N.Provider,{value:w,children:x})};u.displayName=a+"Provider";function p(m,f){const x=f?.[e]?.[d]||c,h=i.useContext(x);if(h)return h;if(l!==void 0)return l;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const s=()=>{const a=r.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,df(s,...t)]}function df(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return r.scopeName=t.scopeName,r}function uf(e,t){return i.useReducer((r,o)=>t[r][o]??r,e)}var Es="ScrollArea",[il,Xv]=cf(Es),[pf,Xt]=il(Es),ll=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:o="hover",dir:s,scrollHideDelay:a=600,...l}=e,[c,d]=i.useState(null),[u,p]=i.useState(null),[m,f]=i.useState(null),[x,h]=i.useState(null),[N,w]=i.useState(null),[S,$]=i.useState(0),[F,Z]=i.useState(0),[z,R]=i.useState(!1),[E,B]=i.useState(!1),I=Yt(t,_=>d(_)),Y=gs(s);return n.jsx(pf,{scope:r,type:o,dir:Y,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:p,content:m,onContentChange:f,scrollbarX:x,onScrollbarXChange:h,scrollbarXEnabled:z,onScrollbarXEnabledChange:R,scrollbarY:N,onScrollbarYChange:w,scrollbarYEnabled:E,onScrollbarYEnabledChange:B,onCornerWidthChange:$,onCornerHeightChange:Z,children:n.jsx(br.div,{dir:Y,...l,ref:I,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":F+"px",...e.style}})})});ll.displayName=Es;var cl="ScrollAreaViewport",dl=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:o,nonce:s,...a}=e,l=Xt(cl,r),c=i.useRef(null),d=Yt(t,c,l.onViewportChange);return n.jsxs(n.Fragment,{children:[n.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:s}),n.jsx(br.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});dl.displayName=cl;var dn="ScrollAreaScrollbar",ul=i.forwardRef((e,t)=>{const{forceMount:r,...o}=e,s=Xt(dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:l}=s,c=e.orientation==="horizontal";return i.useEffect(()=>(c?a(!0):l(!0),()=>{c?a(!1):l(!1)}),[c,a,l]),s.type==="hover"?n.jsx(mf,{...o,ref:t,forceMount:r}):s.type==="scroll"?n.jsx(ff,{...o,ref:t,forceMount:r}):s.type==="auto"?n.jsx(pl,{...o,ref:t,forceMount:r}):s.type==="always"?n.jsx(_s,{...o,ref:t}):null});ul.displayName=dn;var mf=i.forwardRef((e,t)=>{const{forceMount:r,...o}=e,s=Xt(dn,e.__scopeScrollArea),[a,l]=i.useState(!1);return i.useEffect(()=>{const c=s.scrollArea;let d=0;if(c){const u=()=>{window.clearTimeout(d),l(!0)},p=()=>{d=window.setTimeout(()=>l(!1),s.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",p)}}},[s.scrollArea,s.scrollHideDelay]),n.jsx(Sn,{present:r||a,children:n.jsx(pl,{"data-state":a?"visible":"hidden",...o,ref:t})})}),ff=i.forwardRef((e,t)=>{const{forceMount:r,...o}=e,s=Xt(dn,e.__scopeScrollArea),a=e.orientation==="horizontal",l=ho(()=>d("SCROLL_END"),100),[c,d]=uf("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"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,s.scrollHideDelay,d]),i.useEffect(()=>{const u=s.viewport,p=a?"scrollLeft":"scrollTop";if(u){let m=u[p];const f=()=>{const x=u[p];m!==x&&(d("SCROLL"),l()),m=x};return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[s.viewport,a,d,l]),n.jsx(Sn,{present:r||c!=="hidden",children:n.jsx(_s,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:t,onPointerEnter:qe(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:qe(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),pl=i.forwardRef((e,t)=>{const r=Xt(dn,e.__scopeScrollArea),{forceMount:o,...s}=e,[a,l]=i.useState(!1),c=e.orientation==="horizontal",d=ho(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,p=r.viewport.offsetHeight<r.viewport.scrollHeight;l(c?u:p)}},10);return Vn(r.viewport,d),Vn(r.content,d),n.jsx(Sn,{present:o||a,children:n.jsx(_s,{"data-state":a?"visible":"hidden",...s,ref:t})})}),_s=i.forwardRef((e,t)=>{const{orientation:r="vertical",...o}=e,s=Xt(dn,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=gl(c.viewport,c.content),p={...o,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:f=>l.current=f};function m(f,x){return bf(f,l.current,c,x)}return r==="horizontal"?n.jsx(hf,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollLeft,x=oa(f,c,s.dir);a.current.style.transform=`translate3d(${x}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=m(f,s.dir))}}):r==="vertical"?n.jsx(xf,{...p,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollTop,x=oa(f,c);a.current.style.transform=`translate3d(0, ${x}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=m(f))}}):null}),hf=i.forwardRef((e,t)=>{const{sizes:r,onSizesChange:o,...s}=e,a=Xt(dn,e.__scopeScrollArea),[l,c]=i.useState(),d=i.useRef(null),u=Yt(t,d,a.onScrollbarXChange);return i.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),n.jsx(fl,{"data-orientation":"horizontal",...s,ref:u,sizes:r,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":fo(r)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.x),onDragScroll:p=>e.onDragScroll(p.x),onWheelScroll:(p,m)=>{if(a.viewport){const f=a.viewport.scrollLeft+p.deltaX;e.onWheelScroll(f),yl(f,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&l&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:no(l.paddingLeft),paddingEnd:no(l.paddingRight)}})}})}),xf=i.forwardRef((e,t)=>{const{sizes:r,onSizesChange:o,...s}=e,a=Xt(dn,e.__scopeScrollArea),[l,c]=i.useState(),d=i.useRef(null),u=Yt(t,d,a.onScrollbarYChange);return i.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),n.jsx(fl,{"data-orientation":"vertical",...s,ref:u,sizes:r,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":fo(r)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.y),onDragScroll:p=>e.onDragScroll(p.y),onWheelScroll:(p,m)=>{if(a.viewport){const f=a.viewport.scrollTop+p.deltaY;e.onWheelScroll(f),yl(f,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&l&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:no(l.paddingTop),paddingEnd:no(l.paddingBottom)}})}})}),[gf,ml]=il(dn),fl=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:o,hasThumb:s,onThumbChange:a,onThumbPointerUp:l,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:m,...f}=e,x=Xt(dn,r),[h,N]=i.useState(null),w=Yt(t,I=>N(I)),S=i.useRef(null),$=i.useRef(""),F=x.viewport,Z=o.content-o.viewport,z=an(p),R=an(d),E=ho(m,10);function B(I){if(S.current){const Y=I.clientX-S.current.left,_=I.clientY-S.current.top;u({x:Y,y:_})}}return i.useEffect(()=>{const I=Y=>{const _=Y.target;h?.contains(_)&&z(Y,Z)};return document.addEventListener("wheel",I,{passive:!1}),()=>document.removeEventListener("wheel",I,{passive:!1})},[F,h,Z,z]),i.useEffect(R,[o,R]),Vn(h,E),Vn(x.content,E),n.jsx(gf,{scope:r,scrollbar:h,hasThumb:s,onThumbChange:an(a),onThumbPointerUp:an(l),onThumbPositionChange:R,onThumbPointerDown:an(c),children:n.jsx(br.div,{...f,ref:w,style:{position:"absolute",...f.style},onPointerDown:qe(e.onPointerDown,I=>{I.button===0&&(I.target.setPointerCapture(I.pointerId),S.current=h.getBoundingClientRect(),$.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",x.viewport&&(x.viewport.style.scrollBehavior="auto"),B(I))}),onPointerMove:qe(e.onPointerMove,B),onPointerUp:qe(e.onPointerUp,I=>{const Y=I.target;Y.hasPointerCapture(I.pointerId)&&Y.releasePointerCapture(I.pointerId),document.body.style.webkitUserSelect=$.current,x.viewport&&(x.viewport.style.scrollBehavior=""),S.current=null})})})}),to="ScrollAreaThumb",hl=i.forwardRef((e,t)=>{const{forceMount:r,...o}=e,s=ml(to,e.__scopeScrollArea);return n.jsx(Sn,{present:r||s.hasThumb,children:n.jsx(vf,{ref:t,...o})})}),vf=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:o,...s}=e,a=Xt(to,r),l=ml(to,r),{onThumbPositionChange:c}=l,d=Yt(t,m=>l.onThumbChange(m)),u=i.useRef(void 0),p=ho(()=>{u.current&&(u.current(),u.current=void 0)},100);return i.useEffect(()=>{const m=a.viewport;if(m){const f=()=>{if(p(),!u.current){const x=wf(m,c);u.current=x,c()}};return c(),m.addEventListener("scroll",f),()=>m.removeEventListener("scroll",f)}},[a.viewport,p,c]),n.jsx(br.div,{"data-state":l.hasThumb?"visible":"hidden",...s,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:qe(e.onPointerDownCapture,m=>{const x=m.target.getBoundingClientRect(),h=m.clientX-x.left,N=m.clientY-x.top;l.onThumbPointerDown({x:h,y:N})}),onPointerUp:qe(e.onPointerUp,l.onThumbPointerUp)})});hl.displayName=to;var As="ScrollAreaCorner",xl=i.forwardRef((e,t)=>{const r=Xt(As,e.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?n.jsx(yf,{...e,ref:t}):null});xl.displayName=As;var yf=i.forwardRef((e,t)=>{const{__scopeScrollArea:r,...o}=e,s=Xt(As,r),[a,l]=i.useState(0),[c,d]=i.useState(0),u=!!(a&&c);return Vn(s.scrollbarX,()=>{const p=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(p),d(p)}),Vn(s.scrollbarY,()=>{const p=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(p),l(p)}),u?n.jsx(br.div,{...o,ref:t,style:{width:a,height:c,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function no(e){return e?parseInt(e,10):0}function gl(e,t){const r=e/t;return isNaN(r)?0:r}function fo(e){const t=gl(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-r)*t;return Math.max(o,18)}function bf(e,t,r,o="ltr"){const s=fo(r),a=s/2,l=t||a,c=s-l,d=r.scrollbar.paddingStart+l,u=r.scrollbar.size-r.scrollbar.paddingEnd-c,p=r.content-r.viewport,m=o==="ltr"?[0,p]:[p*-1,0];return vl([d,u],m)(e)}function oa(e,t,r="ltr"){const o=fo(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-s,l=t.content-t.viewport,c=a-o,d=r==="ltr"?[0,l]:[l*-1,0],u=jd(e,d);return vl([0,l],[0,c])(u)}function vl(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(r-e[0])}}function yl(e,t){return e>0&&e<t}var wf=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},o=0;return function s(){const a={left:e.scrollLeft,top:e.scrollTop},l=r.left!==a.left,c=r.top!==a.top;(l||c)&&t(),r=a,o=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(o)};function ho(e,t){const r=an(e),o=i.useRef(0);return i.useEffect(()=>()=>window.clearTimeout(o.current),[]),i.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,t)},[r,t])}function Vn(e,t){const r=an(t);kd(()=>{let o=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return s.observe(e),()=>{window.cancelAnimationFrame(o),s.unobserve(e)}}},[e,r])}var bl=ll,kf=dl,wl=ul,jf=hl,Sf=xl;const kl=i.forwardRef(({className:e,orientation:t="vertical",...r},o)=>n.jsx(wl,{ref:o,orientation:t,className:xt("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:n.jsx(jf,{className:"relative flex-1 rounded-full bg-border/80"})}));kl.displayName=wl.displayName;const jl=i.forwardRef(({className:e,children:t,...r},o)=>n.jsxs(bl,{ref:o,className:xt("relative overflow-hidden",e),...r,children:[n.jsx(kf,{className:"h-full w-full rounded-[inherit]",children:t}),n.jsx(kl,{}),n.jsx(Sf,{})]}));jl.displayName=bl.displayName;const wr=({className:e="w-5 h-5"})=>n.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),kr=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=vs();return n.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},jr=({className:e="w-5 h-5"})=>{const t=i.useId(),r=i.useId(),o=i.useId();return n.jsxs("svg",{"aria-label":"Gemini",className:e,role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("title",{children:"Gemini"}),n.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"}),n.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${t})`}),n.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})`}),n.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(#${o})`}),n.jsxs("defs",{children:[n.jsxs("linearGradient",{id:t,x1:"7",x2:"11",y1:"15.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[n.jsx("stop",{stopColor:"#08B962"}),n.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),n.jsxs("linearGradient",{id:r,x1:"8",x2:"11.5",y1:"5.5",y2:"11",gradientUnits:"userSpaceOnUse",children:[n.jsx("stop",{stopColor:"#F94543"}),n.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),n.jsxs("linearGradient",{id:o,x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[n.jsx("stop",{stopColor:"#FABC12"}),n.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]})},Sr=({className:e="h-5 w-auto",style:t,...r})=>n.jsxs("svg",{"aria-label":"OpenCode",className:e,role:"img",style:{width:"auto",maxWidth:"100%",...t},viewBox:"0 0 32 24",preserveAspectRatio:"xMidYMid meet",xmlns:"http://www.w3.org/2000/svg",...r,children:[n.jsx("title",{children:"OpenCode"}),n.jsx("rect",{x:"6",y:"2",width:"20",height:"20",rx:"5",fill:"currentColor"}),n.jsx("path",{d:"M20 6h-8v12h8V6zm4 16H8V2h16v20z",fill:"white"})]}),Ln=i.forwardRef(({className:e,type:t,...r},o)=>n.jsx("input",{type:t,className:xt("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:o,...r}));Ln.displayName="Input";const Nf=!1;function Cf(e,t,r={}){const{timeoutMs:o=null,signal:s,...a}=r,l=typeof AbortController=="function"?new AbortController:null;let c=null;l&&s&&(s.aborted?l.abort(s.reason):s.addEventListener("abort",()=>l.abort(s.reason),{once:!0})),l&&Number.isFinite(o)&&o>0&&(c=setTimeout(()=>{const u=new Error(`Request timed out after ${o}ms`);u.name="AbortError",l.abort(u)},o));const d=e(t,{...a,signal:l?.signal||s});return c?d.finally(()=>{clearTimeout(c)}):d}function sa(e){return e==="resolve"||e==="events"?2e4:null}function Ef(){return localStorage.getItem("auth-token")}function _f(e,t={}){const r={...t};!(e instanceof FormData)&&!r["Content-Type"]&&(r["Content-Type"]="application/json");{const o=Ef();o&&!r.Authorization&&(r.Authorization=`Bearer ${o}`)}return r}function Kt(e,t={}){const{timeoutMs:r=null,signal:o,headers:s,body:a,...l}=t;return Cf(fetch,e,{...l,body:a,headers:_f(a,s),signal:o,timeoutMs:r})}function dt(e,t={}){return Kt(e,t)}function mn(e,t,r={}){return dt(e,{...r,method:"POST",body:JSON.stringify(t)})}function Af(e,t,r={}){return dt(e,{...r,method:"PUT",body:JSON.stringify(t)})}function Hn(e,t={}){return dt(e,{...t,method:"DELETE"})}function fn(e,t){const r=new URLSearchParams;Object.entries(t||{}).forEach(([s,a])=>{a!=null&&a!==""&&r.set(s,String(a))});const o=r.toString();return o?`${e}?${o}`:e}const mt={auth:{status:()=>fetch("/api/auth/status"),bootstrap:()=>fetch("/api/auth/bootstrap",{method:"POST",headers:{"Content-Type":"application/json"}}),login:(e,t)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),register:(e,t)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),user:()=>dt("/api/auth/user"),logout:()=>dt("/api/auth/logout",{method:"POST"})},lanAccess:{summary:()=>dt("/api/lan-access/summary"),updatePassword:e=>mn("/api/lan-access/password",{password:e}),createToken:e=>mn("/api/lan-access/token",{address:e}),login:e=>fetch("/api/lan-access/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:e})})},projects:()=>dt("/api/projects"),projectsList:()=>dt("/api/projects/list"),projectDetails:e=>dt(`/api/projects/${e}/details`),sessions:(e,t=5,r=0)=>dt(fn(`/api/projects/${e}/sessions`,{limit:t,offset:r})),historyIndex:e=>dt(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,t=null)=>dt(fn(`/api/session-core/providers/${e}`,{projectPath:t})),providersDiscovery:(e=null)=>dt(fn("/api/session-core/providers",{projectPath:e})),sessionEvents:(e,t,r=null,o=null,s=null,a=0)=>dt(fn(`/api/session-core/sessions/${e}/${t}/events`,{projectName:r,projectPath:o,limit:s,offset:a}),{timeoutMs:sa("events")}),sessionMessages:(e,t,r=null,o=0,s="claude")=>dt(fn(`/api/session-core/sessions/${s}/${t}/events`,{projectName:e,limit:r,offset:o})),resolveSession:(e,t)=>dt(`/api/session-core/sessions/${e}/${t}/resolve`,{timeoutMs:sa("resolve")}),renameProject:(e,t)=>Af(`/api/projects/${e}/rename`,{displayName:t}),deleteSession:(e,t)=>Hn(`/api/projects/${e}/sessions/${t}`),deleteCodexSession:e=>Hn(`/api/codex/sessions/${e}`),deleteGeminiSession:e=>Hn(`/api/gemini/sessions/${e}`),deleteOpencodeSession:e=>Hn(`/api/opencode/sessions/${e}`),deleteProject:(e,t=!1)=>Hn(fn(`/api/projects/${e}`,{force:t?"true":null})),createProject:e=>mn("/api/projects/create",{path:e}),createWorkspace:e=>mn("/api/projects/create-workspace",e),readFile:(e,t)=>dt(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),getFiles:e=>dt(`/api/projects/${e}/files`),transcribe:e=>dt("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>dt(fn("/api/browse-filesystem",{path:e})),createFolder:e=>mn("/api/create-folder",{path:e}),ccConnect:{status:()=>dt("/api/cc-connect/status"),providers:()=>dt("/api/cc-connect/providers"),platforms:()=>dt("/api/cc-connect/platforms"),install:()=>dt("/api/cc-connect/install",{method:"POST"}),setup:(e,t)=>mn(`/api/cc-connect/${e}/setup`,t),sessionStatus:(e,t)=>dt(fn(`/api/cc-connect/${e}/status`,{sessionId:t})),refresh:(e,t)=>mn(`/api/cc-connect/${e}/refresh`,{sessionId:t}),cleanupSession:(e,t)=>Hn(fn(`/api/cc-connect/${e}/session`,{sessionId:t})),activeProvider:e=>dt(`/api/cc-connect/${e}/active-provider`),switchProvider:(e,t)=>mn(`/api/cc-connect/${e}/switch-provider`,{provider:t}),updateProject:(e,t)=>mn(`/api/cc-connect/${e}/project`,t),unbind:e=>dt(`/api/cc-connect/${e}/unbind`,{method:"POST"})},get:e=>dt(`/api${e}`)},aa="__windows_drives__",If="__workspace_roots__",Tf=/^[A-Za-z]:\\?$/,Pf=({onClose:e,onProjectCreated:t})=>{const{t:r}=Et(),[o,s]=i.useState(1),[a,l]=i.useState("existing"),[c,d]=i.useState(""),[u,p]=i.useState(!1),[m,f]=i.useState(null),[x,h]=i.useState([]),[N,w]=i.useState(!1),[S,$]=i.useState(!1),[F,Z]=i.useState("~"),[z,R]=i.useState("~"),[E,B]=i.useState([]),[I,Y]=i.useState(!1),[_,re]=i.useState(!1),[ie,V]=i.useState(!1),[ae,de]=i.useState(""),[ve,fe]=i.useState(!1),[U,le]=i.useState(null),[oe,Te]=i.useState(null),[te,Q]=i.useState(!1),we=C=>{const T=C.trim();if(!T)return"~";if(T.endsWith("/")||T.endsWith("\\"))return T;if(/^[A-Za-z]:$/.test(T))return`${T}\\`;const me=Math.max(T.lastIndexOf("/"),T.lastIndexOf("\\"));return me>0?me===2&&/^[A-Za-z]:/.test(T)?T.substring(0,3):T.substring(0,me):"~"},Ie=oe==="windows-drives",ye=oe==="workspace-roots",Oe=!!oe,$e=U==="win32"&&!te,he=te,et=!Oe,_e=!Oe;i.useEffect(()=>{c.length>2?Xe(c):(h([]),w(!1))},[c]);const Xe=async C=>{try{const T=we(C),xe=await(await mt.browseFilesystem(T)).json();if(xe.suggestions){const y=xe.suggestions.filter(D=>D.path.toLowerCase().startsWith(C.toLowerCase())&&D.path.toLowerCase()!==C.toLowerCase());h(y.slice(0,5)),w(y.length>0)}}catch(T){console.error("Error loading path suggestions:",T)}},Fe=()=>{if(f(null),o===1){if(!a){f(r("projectWizard.errors.selectType"));return}s(2)}else if(o===2){if(!c.trim()){f(r("projectWizard.errors.providePath"));return}s(3)}},Re=()=>{f(null),s(o-1)},ut=async()=>{p(!0),f(null);try{const C={workspaceType:a,path:c.trim()},T=await mt.createWorkspace(C),me=await T.json();if(!T.ok)throw new Error(me.details||me.error||r("projectWizard.errors.failedToCreate"));t&&t(me.project),e()}catch(C){console.error("Error creating workspace:",C),f(C.message||r("projectWizard.errors.failedToCreate"))}finally{p(!1)}},tt=C=>{d(C.path),w(!1)},Ue=async()=>{$(!0),await We()},We=async C=>{try{Y(!0);const me=await(await mt.browseFilesystem(C)).json();Z(me.path||C),R(me.displayPath||me.path||C),B(me.suggestions||[]),le(me.platform||null),Te(me.virtualRoot||null),Q(!!me.hasWorkspaceRootRestriction)}catch(T){console.error("Error loading folders:",T)}finally{Y(!1)}},ot=(C,T=!1)=>{!C||C===aa||(d(C),$(!1),T&&s(3))},Me=async C=>{await We(C)},st=async()=>{if(!(!ae.trim()||!_e)){fe(!0),f(null);try{const C=F.includes("\\")?"\\":"/",T=F.endsWith(C)?`${F}${ae.trim()}`:`${F}${C}${ae.trim()}`,me=await mt.createFolder(T),xe=await me.json();if(!me.ok)throw new Error(xe.error||r("projectWizard.errors.failedToCreateFolder"));de(""),V(!1),await We(xe.path||T)}catch(C){console.error("Error creating folder:",C),f(C.message||r("projectWizard.errors.failedToCreateFolder"))}finally{fe(!1)}}};return n.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:[n.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:[n.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:n.jsx(Gn,{className:"w-4 h-4 text-primary"})}),n.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectWizard.title")})]}),n.jsx("button",{onClick:e,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:u,children:n.jsx(Wt,{className:"w-5 h-5"})})]}),n.jsx("div",{className:"px-6 pt-4 pb-2",children:n.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(C=>n.jsxs(wt.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${C<o?"bg-green-500 text-white":C===o?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:C<o?n.jsx(jn,{className:"w-4 h-4"}):C}),n.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:r(C===1?"projectWizard.steps.type":C===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),C<3&&n.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${C<o?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},C))})}),n.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[m&&n.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:[n.jsx(Sd,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),n.jsx("div",{className:"flex-1",children:n.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:m})})]}),o===1&&n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:r("projectWizard.step1.question")}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.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:n.jsxs("div",{className:"flex items-start gap-3",children:[n.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:n.jsx(Gn,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:r("projectWizard.step1.existing.title")}),n.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step1.existing.description")})]})]})}),n.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:n.jsxs("div",{className:"flex items-start gap-3",children:[n.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:n.jsx(Gn,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:r("projectWizard.step1.new.title")}),n.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step1.new.description")})]})]})})]})]})}),o===2&&n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r(a==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),n.jsxs("div",{className:"relative flex gap-2",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(Ln,{type:"text",value:c,onChange:C=>d(C.target.value),placeholder:r(a==="existing"?"projectWizard.step2.existingPlaceholder":"projectWizard.step2.newPlaceholder"),className:"w-full"}),N&&x.length>0&&n.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:x.map((C,T)=>n.jsxs("button",{onClick:()=>tt(C),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[n.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:C.name}),n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:C.path})]},T))})]}),n.jsx(Le,{type:"button",variant:"outline",onClick:Ue,className:"px-3",title:r("projectWizard.folderBrowser.browseFolders"),children:n.jsx(cr,{className:"w-4 h-4"})})]}),n.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r(a==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]})}),o===3&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[n.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:r("projectWizard.step3.reviewConfig")}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.workspaceType")}),n.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r(a==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.path")}),n.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]})]})]}),n.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-4 border border-primary/30 dark:border-primary/60",children:n.jsx("p",{className:"text-sm text-primary",children:r(a==="existing"?"projectWizard.step3.existingInfo":"projectWizard.step3.newEmpty")})})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[n.jsx(Le,{variant:"outline",onClick:o===1?e:Re,disabled:u,children:o===1?r("projectWizard.buttons.cancel"):n.jsxs(n.Fragment,{children:[n.jsx(iu,{className:"w-4 h-4 mr-1"}),r("projectWizard.buttons.back")]})}),n.jsx(Le,{onClick:o===3?ut:Fe,disabled:u||o===1&&!a,children:u?n.jsxs(n.Fragment,{children:[n.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),r("projectWizard.buttons.creating")]}):o===3?n.jsxs(n.Fragment,{children:[n.jsx(jn,{className:"w-4 h-4 mr-1"}),r("projectWizard.buttons.createProject")]}):n.jsxs(n.Fragment,{children:[r("projectWizard.buttons.next"),n.jsx(yi,{className:"w-4 h-4 ml-1"})]})})]})]}),S&&n.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:n.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:[n.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:n.jsx(cr,{className:"w-4 h-4 text-primary"})}),n.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectWizard.folderBrowser.title")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{onClick:()=>Me($e?aa:If),className:`p-2 rounded-md transition-colors ${Oe?"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"} ${$e||he?"":"hidden"}`,title:r($e?"projectWizard.folderBrowser.browseDrives":"projectWizard.folderBrowser.browseRoots"),children:n.jsx(Cu,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>re(!_),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:r(_?"projectWizard.folderBrowser.hideHiddenFolders":"projectWizard.folderBrowser.showHiddenFolders"),children:_?n.jsx(mu,{className:"w-5 h-5"}):n.jsx(hu,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>V(!ie),className:`p-2 rounded-md transition-colors ${ie?"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:r("projectWizard.folderBrowser.createFolder"),disabled:!_e,children:n.jsx(hr,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>$(!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:n.jsx(Wt,{className:"w-5 h-5"})})]})]}),ie&&_e&&n.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-primary/10 dark:bg-primary/20",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ln,{type:"text",value:ae,onChange:C=>de(C.target.value),placeholder:r("projectWizard.folderBrowser.newFolderPlaceholder"),className:"flex-1",onKeyDown:C=>{C.key==="Enter"&&st(),C.key==="Escape"&&(V(!1),de(""))},autoFocus:!0}),n.jsx(Le,{size:"sm",onClick:st,disabled:!ae.trim()||ve,children:ve?n.jsx(Tt,{className:"w-4 h-4 animate-spin"}):r("buttons.create")}),n.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>{V(!1),de("")},children:r("buttons.cancel")})]})}),n.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:I?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(Tt,{className:"w-6 h-6 animate-spin text-gray-400"})}):n.jsxs("div",{className:"space-y-1",children:[F!=="~"&&F!=="/"&&!Tf.test(F)&&!Oe&&n.jsxs("button",{onClick:()=>{const C=Math.max(F.lastIndexOf("/"),F.lastIndexOf("\\"));let T;C<=0?T="/":C===2&&/^[A-Za-z]:/.test(F)?T=F.substring(0,3):T=F.substring(0,C),Me(T)},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:[n.jsx(cr,{className:"w-5 h-5 text-gray-400"}),n.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),E.length===0?n.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:r("projectWizard.folderBrowser.noSubfolders")}):E.filter(C=>_||!C.name.startsWith(".")).sort((C,T)=>C.name.toLowerCase().localeCompare(T.name.toLowerCase())).map((C,T)=>n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("button",{onClick:()=>Me(C.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:[n.jsx(Gn,{className:"w-5 h-5 text-primary"}),n.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:C.name})]}),n.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>ot(C.path,a==="existing"),className:"text-xs px-3",children:r("buttons.select")})]},T))]})}),n.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[n.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.folderBrowser.currentPath")}),n.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:Ie?r("projectWizard.folderBrowser.drivesRoot"):ye?r("projectWizard.folderBrowser.workspaceRoots"):z})]}),n.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[n.jsx(Le,{variant:"outline",onClick:()=>{$(!1),V(!1),de("")},children:r("buttons.cancel")}),n.jsx(Le,{variant:"outline",onClick:()=>ot(F,a==="existing"),disabled:!et,children:r("projectWizard.folderBrowser.useCurrentFolder")})]})]})]})})]})},bt=Object.freeze({NEW_SESSION:"new-session",NEW_PROJECT:"new-project",REMOTE_ACCESS:"remote-access",REFRESH:"refresh",THEME_TOGGLE:"theme-toggle",SHOW_SIDEBAR:"show-sidebar",UPDATE_AVAILABLE:"update-available"});function Rf({isProjectLockedMode:e=!1}={}){return{showSearch:!1,titleKey:e?"sessions.title":"projects.title",primaryActionIds:[bt.NEW_SESSION,bt.REMOTE_ACCESS],projectActionIds:e?[bt.REFRESH,bt.THEME_TOGGLE]:[bt.NEW_PROJECT,bt.REFRESH,bt.THEME_TOGGLE]}}function Mf({updateAvailable:e=!1}={}){const t=[bt.SHOW_SIDEBAR,bt.NEW_SESSION,bt.REMOTE_ACCESS,bt.THEME_TOGGLE];return e&&t.push(bt.UPDATE_AVAILABLE),t}function Df(e,{provider:t,projectName:r,sessionId:o}){switch(String(t||"claude").trim().toLowerCase()){case"codex":return e.deleteCodexSession(o);case"gemini":return e.deleteGeminiSession(o);case"opencode":return e.deleteOpencodeSession(o);default:return e.deleteSession(r,o)}}const Lf=(e,t,r)=>{const o=new Date(e),s=t;if(isNaN(o.getTime()))return r?r("status.unknown"):"Unknown";const a=s-o,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?r?r("time.justNow"):"Just now":c===1?r?r("time.oneMinuteAgo"):"1 min ago":c<60?r?r("time.minutesAgo",{count:c}):`${c} mins ago`:d===1?r?r("time.oneHourAgo"):"1 hour ago":d<24?r?r("time.hoursAgo",{count:d}):`${d} hours ago`:u===1?r?r("time.oneDayAgo"):"1 day ago":u<7?r?r("time.daysAgo",{count:u}):`${u} days ago`:o.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},Of=(e,t)=>{if(typeof e!="string")return"";const r=e.trim();return r.length<=t?r:`${r.slice(0,Math.max(0,t-1))}…`},qn="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",Or="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",_o="block min-w-0 w-full max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",ia=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?n.jsx(kr,{className:t}):e==="gemini"?n.jsx(jr,{className:t}):e==="opencode"?n.jsx(Sr,{className:"h-3.5 w-auto max-w-full"}):n.jsx(wr,{className:t});function la({projects:e,selectedProject:t,selectedSession:r,onProjectSelect:o,onProjectRename:s,onSessionSelect:a,onNewSession:l,onSessionDelete:c,onProjectDelete:d,isLoading:u,projectDetailsLoading:p,loadingProgress:m,onProjectExpand:f,onRefresh:x,updateAvailable:h,latestVersion:N,currentVersion:w,releaseInfo:S,onShowVersionModal:$,isPWA:F,isMobile:Z,onToggleSidebar:z,onShowSettings:R,lockedProjectName:E,showNewProject:B,setShowNewProject:I,onOpenCcConnectDialog:Y}){const{t:_}=Et("sidebar"),[re,ie]=i.useState(new Set),[V,ae]=i.useState(null),[de,ve]=i.useState(""),[fe,U]=i.useState({}),[le,oe]=i.useState({}),[Te,te]=i.useState(new Date),[Q,we]=i.useState("name"),[Ie,ye]=i.useState(!1),[Oe,Be]=i.useState(null),[$e,he]=i.useState(null),[et,_e]=i.useState(""),[Xe,Fe]=i.useState(null),[Re,ut]=i.useState(null),[tt,Ue]=i.useState({}),[We,ot]=i.useState(new Set),[Me,st]=i.useState(null),[C,T]=i.useState(null),[me,xe]=i.useState(()=>{try{const j=localStorage.getItem("starredProjects");return j?new Set(JSON.parse(j)):new Set}catch(j){return console.error("Error loading starred projects:",j),new Set}}),y=j=>ue=>{ue.target.closest(".overflow-y-auto")||ue.target.closest("[data-scroll-container]")||(ue.preventDefault(),ue.stopPropagation(),j())};i.useEffect(()=>{const j=setInterval(()=>{te(new Date)},6e4);return()=>clearInterval(j)},[]),i.useEffect(()=>{oe({})},[e]),i.useEffect(()=>{r&&t&&ie(j=>new Set([...j,t.name]))},[r,t]),i.useEffect(()=>{E&&ie(new Set([E]))},[E,e.length]),i.useEffect(()=>{const j=()=>{try{const Ne=localStorage.getItem("claude-settings");if(Ne){const He=JSON.parse(Ne);we(He.projectSortOrder||"name")}}catch(Ne){console.error("Error loading sort order:",Ne)}};j();const ue=Ne=>{Ne.key==="claude-settings"&&j()};window.addEventListener("storage",ue);const ge=setInterval(()=>{document.hasFocus()&&j()},1e3);return()=>{window.removeEventListener("storage",ue),clearInterval(ge)}},[]);const D=async j=>{const ue=new Set,ge=!re.has(j.name);ge&&ue.add(j.name),ie(ue),ge&&typeof f=="function"&&await f(j.name,{background:!0})},H=(j,ue)=>{a({...j,__projectName:ue})},L=j=>{const ue=new Set(me);ue.has(j)?ue.delete(j):ue.add(j),xe(ue);try{localStorage.setItem("starredProjects",JSON.stringify([...ue]))}catch(ge){console.error("Error saving starred projects:",ge)}},O=j=>me.has(j),ne=j=>{let ue={};try{ue=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const ge=[...j.sessions||[],...le[j.name]||[]].map(De=>({...De,__provider:ue[De.id]||"claude"})),Ne=(j.codexSessions||[]).map(De=>({...De,__provider:"codex"})),He=(j.geminiSessions||[]).map(De=>({...De,__provider:"gemini"})),Ze=(j.opencodeSessions||[]).map(De=>({...De,__provider:"opencode"})),Dt=De=>De.__provider==="codex"?new Date(De.createdAt||De.lastActivity):De.__provider==="gemini"?new Date(De.createdAt||De.lastActivity):De.__provider==="opencode"?new Date(De.createdAt||De.lastActivity):new Date(De.lastActivity);return[...ge,...Ne,...He,...Ze].sort((De,Lt)=>Dt(Lt)-Dt(De))},ke=j=>{const ue=ne(j);return ue.length===0?new Date(0):ue.reduce((Ne,He)=>{const Ze=new Date(He.lastActivity);return Ze>Ne?Ze:Ne},new Date(0))},Ge=[...e].sort((j,ue)=>{const ge=O(j.name),Ne=O(ue.name);if(ge&&!Ne)return-1;if(!ge&&Ne)return 1;if(Q==="date")return ke(ue)-ke(j);{const He=j.displayName||j.name,Ze=ue.displayName||ue.name;return He.localeCompare(Ze)}}),at=j=>{ae(j.name),ve(j.displayName||j.name||"")},pe=()=>{ae(null),ve("")},ze=async j=>{const ue=de.trim();if(Oe!==j)try{if(Be(j),(await api.renameProject(j,ue)).ok)if(ue&&typeof s=="function"&&s(j,ue),typeof x=="function")await x();else if(window.refreshProjects)await window.refreshProjects();else{window.location.reload();return}else console.error("Failed to rename project")}catch(ge){console.error("Error renaming project:",ge)}finally{Be(null),ae(null),ve("")}},Je=(j,ue,ge,Ne="claude")=>{T({projectName:j,sessionId:ue,sessionTitle:ge,provider:Ne})},it=async()=>{if(!C)return;const{projectName:j,sessionId:ue,provider:ge}=C;T(null);try{console.log("[Sidebar] Deleting session:",{projectName:j,sessionId:ue,provider:ge});const Ne=await Df(api,{provider:ge,projectName:j,sessionId:ue});if(console.log("[Sidebar] Delete response:",{ok:Ne.ok,status:Ne.status}),Ne.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),c?c(ue):console.warn("[Sidebar] No onSessionDelete callback provided");else{const He=await Ne.text();console.error("[Sidebar] Failed to delete session:",{status:Ne.status,error:He}),alert(_("messages.deleteSessionFailed"))}}catch(Ne){console.error("[Sidebar] Error deleting session:",Ne),alert(_("messages.deleteSessionError"))}},Ct=j=>{const ue=ne(j).length;st({project:j,sessionCount:ue})},Mt=async()=>{if(!Me)return;const{project:j,sessionCount:ue}=Me,ge=ue===0;st(null),ot(Ne=>new Set([...Ne,j.name]));try{const Ne=await api.deleteProject(j.name,!ge);if(Ne.ok)d&&d(j.name);else{const He=await Ne.json();console.error("Failed to delete project"),alert(He.error||_("messages.deleteProjectFailed"))}}catch(Ne){console.error("Error deleting project:",Ne),alert(_("messages.deleteProjectError"))}finally{ot(Ne=>{const He=new Set(Ne);return He.delete(j.name),He})}},v=async j=>{if(!j.detailsLoaded&&typeof f=="function"){await f(j.name,{background:!0,force:!0});return}if(!(!(j.sessionMeta?.hasMore!==!1)||fe[j.name])){U(ge=>({...ge,[j.name]:!0}));try{const ge=(j.sessions?.length||0)+(le[j.name]?.length||0),Ne=await api.sessions(j.name,5,ge);if(Ne.ok){const He=await Ne.json();oe(Ze=>({...Ze,[j.name]:[...Ze[j.name]||[],...He.sessions]})),He.hasMore===!1&&(j.sessionMeta={...j.sessionMeta,hasMore:!1})}}catch(ge){console.error("Error loading more sessions:",ge)}finally{U(ge=>({...ge,[j.name]:!1}))}}},M=!!E,G=Rf({isProjectLockedMode:M}),be=M?Ge.filter(j=>j.name===E):Ge,b=t||be[0]||null,J=Z?"bottom":"right",ee=Z?"end":"start",Ae=Z?4:8,Qe="flex items-center justify-center p-1 text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50";return n.jsxs(n.Fragment,{children:[B&&Jr.createPortal(n.jsx(Pf,{onClose:()=>I(!1),onProjectCreated:j=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),Me&&Jr.createPortal(n.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:n.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[n.jsx("div",{className:"p-6",children:n.jsxs("div",{className:"flex items-start gap-4",children:[n.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:n.jsx(Qr,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:_("deleteConfirmation.deleteProject")}),n.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[_("deleteConfirmation.confirmDelete")," ",n.jsx("span",{className:"font-medium text-foreground",children:Me.project.displayName||Me.project.name}),"?"]}),Me.sessionCount>0&&n.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:[n.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:_("deleteConfirmation.sessionCount",{count:Me.sessionCount})}),n.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:_("deleteConfirmation.allConversationsDeleted")})]}),n.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:_("deleteConfirmation.cannotUndo")})]})]})}),n.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[n.jsx(Le,{variant:"outline",className:"flex-1",onClick:()=>st(null),children:_("actions.cancel")}),n.jsxs(Le,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:Mt,children:[n.jsx(In,{className:"w-4 h-4 mr-2"}),_("actions.delete")]})]})]})}),document.body),C&&Jr.createPortal(n.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:n.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[n.jsx("div",{className:"p-6",children:n.jsxs("div",{className:"flex items-start gap-4",children:[n.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:n.jsx(Qr,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:_("deleteConfirmation.deleteSession")}),n.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[_("deleteConfirmation.confirmDelete")," ",n.jsx("span",{className:"font-medium text-foreground",children:C.sessionTitle||_("sessions.unnamed")}),"?"]}),n.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:_("deleteConfirmation.cannotUndo")})]})]})}),n.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[n.jsx(Le,{variant:"outline",className:"flex-1",onClick:()=>T(null),children:_("actions.cancel")}),n.jsxs(Le,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:it,children:[n.jsx(In,{className:"w-4 h-4 mr-2"}),_("actions.delete")]})]})]})}),document.body),n.jsxs("div",{className:"h-full flex flex-col bg-muted/10 border-r border-border/60 md:select-none",style:F&&Z?{paddingTop:"44px"}:{},children:[n.jsxs("div",{className:"flex flex-col border-b border-border/60 bg-muted/10 dark:bg-background/50 pb-2 md:pb-2 pt-1 md:pt-2 px-2 md:px-3",style:F&&Z?{paddingTop:"16px"}:{},children:[n.jsxs("div",{className:"flex h-10 items-center justify-between px-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-6 h-6 rounded-md flex-shrink-0"}),n.jsx("div",{className:"min-w-0",children:n.jsx("h1",{className:"text-sm font-semibold leading-none text-foreground truncate",children:_("app.title")})})]}),z&&!M&&n.jsx(Le,{variant:"ghost",size:"sm",className:"flex h-auto w-auto bg-transparent p-1 text-muted-foreground transition-colors hover:text-foreground",onClick:z,title:_("tooltips.hideSidebar"),children:n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),n.jsxs("div",{className:"mt-1 flex flex-col px-1 space-y-0.5",children:[G.primaryActionIds.includes(bt.NEW_SESSION)&&n.jsxs("button",{className:"flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground disabled:pointer-events-none disabled:opacity-50",onClick:()=>b&&l(b),disabled:!b||u,children:[n.jsx(hr,{className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:_("sessions.newSession")})]}),G.primaryActionIds.includes(bt.REMOTE_ACCESS)&&n.jsxs("button",{className:"flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",onClick:Y,children:[n.jsx(ys,{className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:_("ccConnect.actions.open")||"Remote Access"})]})]}),n.jsxs("div",{className:"mt-3 flex items-center justify-between px-1",children:[n.jsx("div",{className:"text-sm font-medium text-foreground/85",children:_(G.titleKey)}),n.jsxs("div",{className:"flex items-center gap-1",children:[G.projectActionIds.includes(bt.NEW_PROJECT)&&n.jsx("button",{className:Qe,onClick:()=>I(!0),title:_("projects.newProject"),"aria-label":_("projects.newProject"),children:n.jsx(Gn,{className:"h-4 w-4"})}),G.projectActionIds.includes(bt.REFRESH)&&n.jsx("button",{className:Qe,onClick:async()=>{ye(!0);try{await x()}finally{ye(!1)}},disabled:Ie,title:_("actions.refresh")||"Refresh","aria-label":_("actions.refresh")||"Refresh",children:n.jsx(Vo,{className:xt("h-4 w-4",Ie&&"animate-spin")})}),G.projectActionIds.includes(bt.THEME_TOGGLE)&&n.jsx(hi,{variant:"icon",className:Qe})]})]})]}),n.jsx(jl,{className:"flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-2 py-2 md:px-3 md:py-2",children:n.jsx("div",{className:"space-y-1 overflow-x-hidden pb-safe-area-inset-bottom",children:u?n.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:n.jsx("div",{className:"w-full max-w-[320px] text-center space-y-4",children:n.jsxs("div",{className:"space-y-2.5",children:[n.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:m&&m.total>0?n.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${m.current/m.total*100}%`}}):n.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),m?.currentProject&&n.jsx("p",{className:"mx-auto max-w-[260px] break-words text-base font-medium leading-6 text-foreground",title:m.currentProject,children:m.currentProject.split("-").slice(-2).join("/")}),m&&m.total>0?n.jsxs("p",{className:"text-sm text-muted-foreground",children:[m.current,"/",m.total,n.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:_("projects.projects")})]}):n.jsx("p",{className:"text-sm text-muted-foreground",children:_("projects.loadingProjects")})]})})}):e.length===0?n.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[n.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:n.jsx(Co,{className:"w-6 h-6 text-muted-foreground"})}),n.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:_("projects.noProjects")}),n.jsx("p",{className:"text-sm text-muted-foreground",children:_("projects.runClaudeCli")})]}):be.map(j=>{const ue=re.has(j.name),ge=t?.name===j.name,Ne=!!p?.[j.name],He=O(j.name),Ze=We.has(j.name),Dt=M&&j.name===E,De=Dt||ue,Lt=j.displayName||j.name,jt=Of(Lt,Z?22:28);return n.jsxs("div",{className:xt("space-y-2",Ze&&"pointer-events-none opacity-50"),children:[!Dt&&n.jsxs("div",{className:"group md:group",children:[n.jsx("div",{className:"md:hidden",children:n.jsxs("div",{className:xt("mx-1 flex min-h-10 items-center gap-2 px-2 py-2 text-muted-foreground transition-colors active:scale-[0.98]",ge?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==j.name&&o(j),D(j)},onTouchEnd:y(()=>{t?.name!==j.name&&o(j),D(j)}),children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ue?n.jsx(cr,{className:xt("h-4 w-4",He?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):n.jsx(Co,{className:xt("h-4 w-4",He?"text-yellow-600 dark:text-yellow-400":ge?"text-foreground":"text-muted-foreground")})}),n.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:V===j.name?n.jsx("input",{type:"text",value:de,onChange:K=>ve(K.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:_("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:K=>K.stopPropagation(),onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),K.stopPropagation(),ze(j.name)),K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),pe())},style:{fontSize:"16px"}}):n.jsx("div",{className:xt(_o,ge&&"font-semibold"),children:jt})})]}),n.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:V===j.name?n.jsxs(n.Fragment,{children:[n.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(),ze(j.name)},title:_("tooltips.save"),disabled:Oe===j.name,children:n.jsx(jn,{className:"h-3.5 w-3.5"})}),n.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(),pe()},title:_("tooltips.cancel"),children:n.jsx(Wt,{className:"h-3.5 w-3.5"})})]}):n.jsxs(Rr,{children:[n.jsx(Mr,{asChild:!0,children:n.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:K=>K.stopPropagation(),"aria-label":_("actions.settings"),children:n.jsx(Tr,{className:"h-4 w-4"})})}),n.jsx(Dr,{children:n.jsxs(Lr,{side:J,align:ee,sideOffset:Ae,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:[n.jsxs(on,{className:qn,onSelect:K=>{K.preventDefault(),at(j)},children:[n.jsx(Zs,{className:"h-4 w-4"}),_("tooltips.renameProject")]}),n.jsxs(on,{className:qn,onSelect:K=>{K.preventDefault(),L(j.name)},children:[n.jsx(ta,{className:xt("h-4 w-4",He&&"fill-yellow-400 text-yellow-500")}),_(He?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),n.jsx(ra,{className:"my-1 h-px bg-border"}),n.jsxs(on,{className:Or,onSelect:K=>{K.preventDefault(),Ct(j)},children:[n.jsx(In,{className:"h-4 w-4"}),_("tooltips.deleteProject")]})]})})]})})]})}),n.jsxs("div",{role:"button",tabIndex:0,className:xt("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",V===j.name?"h-auto":"h-9",ge?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==j.name&&o(j),D(j)},onTouchEnd:y(()=>{t?.name!==j.name&&o(j),D(j)}),onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),t?.name!==j.name&&o(j),D(j))},title:j.fullPath||Lt,children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:ue?n.jsx(cr,{className:xt("h-4 w-4",He?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):n.jsx(Co,{className:xt("h-4 w-4",He?"text-yellow-600 dark:text-yellow-400":ge?"text-foreground":"text-muted-foreground")})}),n.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:V===j.name?n.jsx("input",{type:"text",value:de,onChange:K=>ve(K.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:_("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:K=>{K.key==="Enter"&&(K.preventDefault(),K.stopPropagation(),ze(j.name)),K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),pe())},onClick:K=>K.stopPropagation()}):n.jsx("div",{className:xt(_o,ge&&"font-semibold"),children:jt})})]}),n.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:V===j.name?n.jsxs(n.Fragment,{children:[n.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(),ze(j.name)},title:_("tooltips.save"),disabled:Oe===j.name,children:n.jsx(jn,{className:"h-3.5 w-3.5"})}),n.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(),pe()},title:_("tooltips.cancel"),children:n.jsx(Wt,{className:"h-3.5 w-3.5"})})]}):n.jsxs(Rr,{children:[n.jsx(Mr,{asChild:!0,children:n.jsx("button",{className:xt("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:K=>K.stopPropagation(),"aria-label":_("actions.settings"),children:n.jsx(Tr,{className:"h-4 w-4"})})}),n.jsx(Dr,{children:n.jsxs(Lr,{side:J,align:ee,sideOffset:Ae,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:[n.jsxs(on,{className:qn,onSelect:K=>{K.preventDefault(),at(j)},children:[n.jsx(Zs,{className:"h-4 w-4"}),_("tooltips.renameProject")]}),n.jsxs(on,{className:qn,onSelect:K=>{K.preventDefault(),L(j.name)},children:[n.jsx(ta,{className:xt("h-4 w-4",He&&"fill-yellow-400 text-yellow-500")}),_(He?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),n.jsx(ra,{className:"my-1 h-px bg-border"}),n.jsxs(on,{className:Or,onSelect:K=>{K.preventDefault(),Ct(j)},children:[n.jsx(In,{className:"h-4 w-4"}),_("tooltips.deleteProject")]})]})})]})})]})]}),De&&n.jsxs("div",{className:xt("space-y-1",Dt?"px-1 md:px-0":"px-0"),children:[!j.detailsLoaded||Ne?Array.from({length:3}).map((K,Ot)=>n.jsx("div",{className:"flex h-9 items-center rounded-lg px-3",children:n.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-muted",style:{width:`${60+Ot*15}%`}})},Ot)):ne(j).length===0&&!fe[j.name]?n.jsx("div",{className:"px-3 py-2 text-left",children:n.jsx("p",{className:"text-xs text-muted-foreground",children:_("sessions.noSessions")})}):ne(j).map(K=>{const Ot=K.__provider==="codex",un=K.__provider==="gemini",vn=K.__provider==="opencode",en=Ot||un||vn,tn=$e===K.id&&!Ot,nn=r?.id===K.id,_t=Ot?K.summary||K.name||_("projects.codexSession"):vn?K.summary||K.name||_("projects.opencodeSession"):K.summary||K.name||_("projects.newSession"),Bn=en&&K.createdAt||K.lastActivity,yn=Xe===K.id||Re===K.id;return n.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>Fe(K.id),onMouseLeave:()=>Fe(Se=>Se===K.id?null:Se),children:[n.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:n.jsxs("div",{className:xt("mx-1 grid min-h-9 min-w-0 grid-cols-[auto,minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-2xl px-3 py-2 transition-all duration-200",nn?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),onClick:()=>{o(j),H(K,j.name)},onTouchEnd:y(()=>{o(j),H(K,j.name)}),children:[n.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:n.jsx(ia,{provider:K.__provider})}),n.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:tn?n.jsx("input",{type:"text",value:et,onChange:Se=>_e(Se.target.value),onKeyDown:Se=>{Se.stopPropagation(),Se.key==="Enter"?updateSessionSummary(j.name,K.id,et):Se.key==="Escape"&&(he(null),_e(""))},onClick:Se=>Se.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}):n.jsx("div",{className:_o,title:_t,children:_t})}),n.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:tn?n.jsxs(n.Fragment,{children:[n.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:Se=>{Se.stopPropagation(),updateSessionSummary(j.name,K.id,et)},title:_("tooltips.save"),children:n.jsx(jn,{className:"h-3.5 w-3.5"})}),n.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:Se=>{Se.stopPropagation(),he(null),_e("")},title:_("tooltips.cancel"),children:n.jsx(Wt,{className:"h-3.5 w-3.5"})})]}):n.jsx(n.Fragment,{children:n.jsxs(Rr,{children:[n.jsx(Mr,{asChild:!0,children:n.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:Se=>Se.stopPropagation(),"aria-label":_("actions.settings"),children:n.jsx(Tr,{className:"h-4 w-4"})})}),n.jsx(Dr,{children:n.jsxs(Lr,{side:J,align:ee,sideOffset:Ae,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:Se=>Se.stopPropagation(),children:[!Ot&&n.jsxs(on,{className:qn,onSelect:Se=>{Se.preventDefault(),he(K.id),_e(K.summary||K.name||_("projects.newSession"))},children:[n.jsx(ea,{className:"h-4 w-4"}),_("tooltips.editSessionName")]}),n.jsxs(on,{className:Or,onSelect:Se=>{Se.preventDefault(),Je(j.name,K.id,_t,K.__provider)},children:[n.jsx(In,{className:"h-4 w-4"}),_("tooltips.deleteSession")]})]})})]})})})]})}),n.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:n.jsxs("div",{className:xt("grid min-h-9 min-w-0 grid-cols-[minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-2xl px-2 py-1.5 transition-all duration-200",nn?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),children:[n.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 overflow-hidden text-left",onClick:()=>H(K,j.name),onTouchEnd:y(()=>H(K,j.name)),children:[n.jsx("span",{className:xt("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",nn||tn?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:n.jsx(ia,{provider:K.__provider})}),tn?n.jsx("input",{type:"text",value:et,onChange:Se=>_e(Se.target.value),onKeyDown:Se=>{Se.stopPropagation(),Se.key==="Enter"?updateSessionSummary(j.name,K.id,et):Se.key==="Escape"&&(he(null),_e(""))},onClick:Se=>Se.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}):n.jsx("span",{className:"block min-w-0 w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-sm text-foreground",title:_t,children:_t})]}),n.jsx("div",{className:"relative flex shrink-0 items-center justify-end pl-1 min-w-[28px]",children:tn?n.jsxs(n.Fragment,{children:[n.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:Se=>{Se.stopPropagation(),updateSessionSummary(j.name,K.id,et)},title:_("tooltips.save"),children:n.jsx(jn,{className:"h-3.5 w-3.5"})}),n.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:Se=>{Se.stopPropagation(),he(null),_e("")},title:_("tooltips.cancel"),children:n.jsx(Wt,{className:"h-3.5 w-3.5"})})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:xt("text-[11px] text-muted-foreground whitespace-nowrap transition-opacity duration-200",yn?"opacity-0":"opacity-100"),children:Lf(Bn,Te,_)}),yn&&n.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 flex items-center justify-end",children:n.jsxs(Rr,{onOpenChange:Se=>ut(Se?K.id:null),children:[n.jsx(Mr,{asChild:!0,children:n.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:Se=>Se.stopPropagation(),onFocus:()=>Fe(K.id),"aria-label":_("actions.settings"),children:n.jsx(Tr,{className:"h-4 w-4"})})}),n.jsx(Dr,{children:n.jsxs(Lr,{side:J,align:ee,sideOffset:Ae,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:Se=>Se.stopPropagation(),children:[!Ot&&n.jsxs(on,{className:qn,onSelect:Se=>{Se.preventDefault(),he(K.id),_e(K.summary||K.name||_("projects.newSession"))},children:[n.jsx(ea,{className:"h-4 w-4"}),_("tooltips.editSessionName")]}),n.jsxs(on,{className:Or,onSelect:Se=>{Se.preventDefault(),Je(j.name,K.id,_t,K.__provider)},children:[n.jsx(In,{className:"h-4 w-4"}),_("tooltips.deleteSession")]})]})})]})})]})})]})})]},K.id)}),j.detailsLoaded&&ne(j).length>0&&j.sessionMeta?.hasMore!==!1&&n.jsx(Le,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>v(j),disabled:fe[j.name],children:fe[j.name]?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),_("sessions.loading")]}):n.jsxs(n.Fragment,{children:[n.jsx(Ko,{className:"w-3 h-3"}),_("sessions.showMore")]})})]})]},j.name)})})}),h&&n.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[n.jsx("div",{className:"hidden md:block",children:n.jsxs(Le,{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:$,children:[n.jsxs("div",{className:"relative",children:[n.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:S?.title||`Version ${N}`}),n.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:_("version.updateAvailable")})]})]})}),n.jsx("div",{className:"md:hidden p-3 pb-2",children:n.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:$,children:[n.jsxs("div",{className:"relative",children:[n.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),n.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[n.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:S?.title||`Version ${N}`}),n.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:_("version.updateAvailable")})]})]})})]})]})]})}function Ff(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ca(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:Ff(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function da(e,t){return e||""}function $f(e){const t=String(e||"").replace(/\\\s*\n\s*/g," ").trim();if(!t)return"";const o=t.split(/\s*(?:&&|\|\||;|\|)\s*/).map(s=>s.trim()).filter(Boolean).map(s=>s.split(/\s+/)[0]).filter(Boolean);return o.length===0?t:o.slice(0,4).join(" · ")+(o.length>4?"…":"")}function zf(e,t,r){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof r=="string"?r:""}function Bf(e,t,r,o){const s=zf(e,t,t),a=da(s);if(e==="Bash"){const l=t?.command||"";return{activityKind:"command",title:o("activity.actions.runCommand"),summary:$f(l)||o("activity.actions.commandPending"),filePath:s,icon:Vu,heavy:!0}}if(e==="Grep"||e==="Glob"){const l=t?.pattern||t?.glob||"",c=da(t?.path||""),d=[];return l&&d.push(l),c&&d.push(c),{activityKind:"search",title:o("activity.actions.searchContent"),summary:d.join(" · ")||o("activity.actions.searchPending"),filePath:t?.path||"",icon:Nd,heavy:!1}}return e==="Read"?{activityKind:"read",title:o("activity.actions.readFile"),summary:a||o("activity.actions.readPending"),filePath:s,icon:wu,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:o("activity.actions.updateFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:gu,heavy:!0}:e==="Write"?{activityKind:"write",title:o("activity.actions.createFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:yu,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:o("activity.actions.updateTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:Qs,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:o("activity.actions.readTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:Qs,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:o("activity.actions.generatePlan"),summary:o("activity.actions.planSummary"),filePath:"",icon:gi,heavy:!0}:{activityKind:"tool",title:o("activity.actions.runTool"),summary:e,filePath:s,icon:Cd,heavy:!0}}function Uf({status:e,messages:t=[],pendingPermissionRequests:r=[],t:o}){if(r.length>0){const a=r[0];return{phaseText:o("activity.stage.waitingPermission"),detailText:o("activity.requestTool",{tool:a.toolName||o("messageTypes.tool")}),canAbort:!0,startedAt:e?.startedAt||Date.now()}}const s=[...t].reverse().find(a=>a?.isToolUse);if(s&&!ca(s.toolResult)&&!s.toolEndedAt){const a=xi(s.toolInput)||{},l=ca(s.toolResult),c=Bf(s.toolName,a,null,o);return{phaseText:l?.isError?o("activity.stage.toolFailed"):c.activityKind==="search"?o("activity.stage.searching"):c.activityKind==="command"?o("activity.stage.runningCommand"):c.activityKind==="edit"||c.activityKind==="write"?o("activity.stage.editingFile"):c.activityKind==="read"?o("activity.stage.readingFile"):c.activityKind.startsWith("todo")?o("activity.stage.updatingTodo"):o("activity.stage.working"),detailText:c.summary,canAbort:e?.canAbort??!0,startedAt:e?.startedAt||Date.now()}}return e||null}const ce={USER_MESSAGE:"user_message",ASSISTANT_TEXT_START:"assistant_text_start",ASSISTANT_TEXT_DELTA:"assistant_text_delta",ASSISTANT_TEXT_END:"assistant_text_end",ASSISTANT_CONTENT_BLOCK:"assistant_content_block",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",PLAN_UPDATE:"plan_update",MODE_UPDATE:"mode_update",AVAILABLE_COMMANDS_UPDATE:"available_commands_update",CONFIG_OPTION_UPDATE:"config_option_update",SESSION_INFO_UPDATE:"session_info_update",USAGE_UPDATE:"usage_update",APPROVAL_REQUEST:"approval_request",APPROVAL_RESOLVED:"approval_resolved",SESSION_STATE_CHANGED:"session_state_changed",SYSTEM_NOTICE:"system_notice",ERROR:"error"};function qt(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function Sl(e){if(!e)return new Date().toISOString();if(e instanceof Date)return e.toISOString();const t=new Date(e);return Number.isNaN(t.getTime())?new Date().toISOString():t.toISOString()}function Pt({kind:e,provider:t="claude",sessionId:r=null,timestamp:o,payload:s={},extensions:a={},rawRef:l=null,eventId:c=null}){return{eventId:c||qt(e),kind:e,provider:t,sessionId:r,timestamp:Sl(o),payload:s,extensions:a,rawRef:l}}function Is(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function Ao({kindPrefix:e="assistant_text",text:t,provider:r,sessionId:o,timestamp:s,messageId:a,extensions:l={},rawRef:c=null}){if(typeof t!="string"||!t.trim())return[];const d=a||qt(e),u={...l,messageId:d};return[Pt({kind:`${e}_start`,provider:r,sessionId:o,timestamp:s,payload:{messageId:d},extensions:u,rawRef:c}),Pt({kind:`${e}_delta`,provider:r,sessionId:o,timestamp:s,payload:{messageId:d,text:t},extensions:u,rawRef:c}),Pt({kind:`${e}_end`,provider:r,sessionId:o,timestamp:s,payload:{messageId:d},extensions:u,rawRef:c})]}function Nl(e){const t=String(e||"").trim();if(!t)return null;const r=t.match(/<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message(?:\s[^>]*)?>\s*([\s\S]*?)\s*<\/user_message>/i);return r?String(r[1]||"").trim():null}function Wf(e){return/<\/?(?:subagent_notification|environment_context|dynamic_context|user_message)(?:\s[^>]*)?>/i.test(String(e||""))}function Qo(e){if(typeof e!="string")return e;const t=Nl(e);if(t!=null)return t;const r=Wf(e);let o=e;return o=o.replace(/<subagent_notification(?:\s[^>]*)?>[\s\S]*?<\/subagent_notification>/gi,""),o=o.replace(/<environment_context(?:\s[^>]*)?>[\s\S]*?<\/environment_context>/gi,""),o=o.replace(/<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>/gi,""),o=o.replace(/<\/?(?:subagent_notification|environment_context|dynamic_context|user_message)(?:\s[^>]*)?>/gi,""),r&&(o=o.replace(/["']?\s*\}\s*\}\s*$/g,"")),o.trim()}function Cl(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>")||t.startsWith("<subagent_notification>")||t.startsWith("</subagent_notification>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const o=`
187
+
188
+ [USER MESSAGE]
189
+ `,s=t.indexOf(o);return s>=0?t.slice(s+o.length).trim():""}const r=Nl(t);return r??t}function Io(e){const t=String(e||"").trim();return!t||t.startsWith("[System Context]")||t.startsWith("[Attached Context]")||t.startsWith("[Dynamic Context]")||t.startsWith("[Hidden Context]")||t.startsWith("# AGENTS.md instructions for ")||t.startsWith("[DYNAMIC CONTEXT V1]")||t.startsWith("<subagent_notification>")||t.startsWith("</subagent_notification>")?!0:/^<dynamic_context(?:\s|>)/i.test(t)||t.includes("<environment_context>")||/<subagent_notification(?:\s|>)/i.test(t)}function Rn(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function Gt(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function Ts(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map(t=>Gt(t)):[]}function El(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function Kf(e){const t=e?.clientRequestId||e?.extensions?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function Hf(e={}){return[...Array.isArray(e?.images)?e.images.map(r=>({type:"image",data:r?.data||r?.image||"",mimeType:r?.mimeType||"application/octet-stream",name:r?.name||r?.filename||""})):[],...Ts(e?.contentBlocks)]}function qf(e,t,r={}){const o=El(t);if(!o)return-1;const s=JSON.stringify(Ts(r.contentBlocks));return Mn(e,a=>String(a?.type||"").trim().toLowerCase()!=="user"||Kf(a)!==o||String(a?.content||"")!==String(r.text||"")?!1:JSON.stringify(Hf(a))===s)}function Gf(e){if(!e||typeof e!="object")return null;const t=Array.isArray(e.availableModes)?e.availableModes.filter(o=>o&&typeof o=="object"&&String(o.id||"").trim()).map(o=>({id:String(o.id).trim(),name:String(o.name||o.id||"").trim()||String(o.id).trim(),description:o.description==null?null:String(o.description)})):[],r=typeof e.currentModeId=="string"&&e.currentModeId.trim()?e.currentModeId.trim():null;return!t.length&&!r?null:{availableModes:t,currentModeId:r||t[0]?.id||null}}function Vf(e){return(Array.isArray(e?.availableCommands)?e.availableCommands:Array.isArray(e)?e:[]).filter(r=>r&&typeof r=="object"&&String(r.name||"").trim()).map(r=>({name:String(r.name).trim(),description:r.description==null?"":String(r.description),input:r.input&&typeof r.input=="object"?Gt(r.input):null,source:"acp",namespace:"acp",type:"acp"}))}function Jf(e){return(Array.isArray(e?.configOptions)?e.configOptions:Array.isArray(e)?e:[]).filter(r=>r&&typeof r=="object"&&String(r.key||"").trim()).map(r=>({key:String(r.key).trim(),description:typeof r.description=="string"?r.description:"",value:Gt(r.value),schema:r.schema&&typeof r.schema=="object"?Gt(r.schema):null}))}function Yf(e){if(!e||typeof e!="object")return null;const t=Object.prototype.hasOwnProperty.call(e,"title")?e.title==null?null:String(e.title):void 0,r=Object.prototype.hasOwnProperty.call(e,"updatedAt")?e.updatedAt==null?null:String(e.updatedAt):void 0;return t===void 0&&r===void 0?null:{...t!==void 0?{title:t}:{},...r!==void 0?{updatedAt:r}:{}}}function Xf(e){if(!e||typeof e!="object")return null;const t=Number(e.used),r=Number(e.size);if(!Number.isFinite(t)||t<0||!Number.isFinite(r)||r<0)return null;const o=Math.round(t),s=Math.round(r),a=s>0?Math.min(100,Math.max(0,Math.round(o/s*100))):0;return{used:o,total:s,percentage:a,remaining:Math.max(0,s-o),cost:e.cost&&typeof e.cost=="object"?Gt(e.cost):null}}function Fr(e=null,t={}){const r=e&&typeof e=="object"?{...e}:{};return t.title!=null&&(r.title=String(t.title)),t.kind!=null&&(r.kind=String(t.kind)),t.status!=null&&(r.status=String(t.status)),t.rawInput!==void 0&&(r.rawInput=Gt(t.rawInput)),t.rawOutput!==void 0&&(r.rawOutput=Gt(t.rawOutput)),Array.isArray(t.contentBlocks)&&(r.content=Gt(t.contentBlocks)),Array.isArray(t.locations)&&(r.locations=Gt(t.locations)),Object.keys(r).length>0?r:null}function Qf(e){const t=new Map;for(const r of e||[])if(!(r?.message?.role!=="user"||!Array.isArray(r?.message?.content)))for(const o of r.message.content)o?.type==="tool_result"&&o.tool_use_id&&t.set(o.tool_use_id,{content:o.content,isError:!!o.is_error,timestamp:r.timestamp,toolUseResult:r.toolUseResult||null});return t}function Mn(e,t){for(let r=e.length-1;r>=0;r-=1)if(t(e[r],r))return r;return-1}function ua(e="",t=""){return t?e?e.endsWith(t)?e:`${e}${t}`:t:e}function $r(e,{messageId:t,timestamp:r,provider:o,isThinking:s=!1,kind:a="assistant"}){const l=Mn(e,d=>d?.eventMessageId===t&&!d.isToolUse&&!!d.isThinking==!!s);if(l>=0){const d={...e[l]};return d.isStreaming=!0,o&&(d.provider=o),r&&(d.timestamp=d.timestamp||r),e[l]=d,{messages:e,index:l}}const c={type:a,content:"",timestamp:r,provider:o,isStreaming:!0,eventMessageId:t};return s&&(c.isThinking=!0),e.push(c),{messages:e,index:e.length-1}}function Zf(e,{messageId:t,timestamp:r,provider:o,role:s="assistant"}){const a=Mn(e,l=>l?.eventMessageId===t&&!l.isToolUse&&!l.isThinking&&String(l?.type||"").trim().toLowerCase()===String(s||"assistant").trim().toLowerCase());if(a>=0){const l={...e[a]};return o&&(l.provider=o),r&&!l.timestamp&&(l.timestamp=r),e[a]=l,{messages:e,index:a}}return e.push({type:s,content:"",timestamp:r,provider:o,isStreaming:!1,eventMessageId:t,contentBlocks:[]}),{messages:e,index:e.length-1}}function zr(e,{toolCallId:t,toolName:r,timestamp:o,provider:s}){const a=Mn(e,l=>l?.isToolUse&&(l.toolId===t||l.toolCallId===t));if(a>=0){const l={...e[a]};return r&&(l.toolName=r),s&&(l.provider=s),o&&!l.timestamp&&(l.timestamp=o),e[a]=l,{messages:e,index:a}}return e.push({type:"assistant",content:"",timestamp:o,provider:s,isToolUse:!0,toolName:r||"Unknown Tool",toolId:t,toolCallId:t}),{messages:e,index:e.length-1}}function eh(e=[],t="claude",r=null){if(!Array.isArray(e))return[];const o=[],s=Qf(e);for(const a of e){const l=Sl(a?.timestamp),c={provider:t,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(p=>p?.type==="text").map(p=>p?.text||"").join(`
190
+ `):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=Cl(d);u&&(!Io(d)||u!==d)&&o.push(Pt({kind:ce.USER_MESSAGE,provider:t,sessionId:r,timestamp:l,payload:{text:u},rawRef:c}));continue}if(a?.type==="thinking"&&a?.message?.content){o.push(...Ao({kindPrefix:"reasoning",text:a.message.content,provider:t,sessionId:r,timestamp:l,rawRef:c}));continue}if(a?.type==="tool_use"&&a?.toolName){const d=a.toolCallId||qt("tool"),u=a.toolResult||null;o.push(Pt({kind:ce.TOOL_CALL_START,provider:t,sessionId:r,timestamp:l,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),o.push(Pt({kind:ce.TOOL_CALL_INPUT,provider:t,sessionId:r,timestamp:l,payload:{toolCallId:d,input:a.toolInput||""},rawRef:c})),o.push(Pt({kind:ce.TOOL_CALL_END,provider:t,sessionId:r,timestamp:l,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),u&&o.push(Pt({kind:ce.TOOL_RESULT,provider:t,sessionId:r,timestamp:u.timestamp||l,payload:{toolCallId:d,content:Rn(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:c}));continue}if(a?.type==="tool_result"){o.push(Pt({kind:ce.TOOL_RESULT,provider:t,sessionId:r,timestamp:l,payload:{toolCallId:a.toolCallId||null,content:Rn(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"){const u=Qo(d.text);u&&!Io(u)&&o.push(...Ao({text:u,provider:t,sessionId:r,timestamp:l,rawRef:c}))}else if(d?.type==="tool_use"){const u=d.id||qt("tool"),p=s.get(d.id);o.push(Pt({kind:ce.TOOL_CALL_START,provider:t,sessionId:r,timestamp:l,payload:{toolCallId:u,toolName:d.name},rawRef:c})),o.push(Pt({kind:ce.TOOL_CALL_INPUT,provider:t,sessionId:r,timestamp:l,payload:{toolCallId:u,input:Rn(d.input||{})},rawRef:c})),o.push(Pt({kind:ce.TOOL_CALL_END,provider:t,sessionId:r,timestamp:l,payload:{toolCallId:u,toolName:d.name},rawRef:c})),p&&o.push(Pt({kind:ce.TOOL_RESULT,provider:t,sessionId:r,timestamp:p.timestamp||l,payload:{toolCallId:u,content:Rn(p.content),isError:!!p.isError,toolUseResult:p.toolUseResult||null},rawRef:c}))}}else{const d=Qo(a.message.content);d&&!Io(d)&&o.push(...Ao({text:d,provider:t,sessionId:r,timestamp:l,rawRef:c}))}continue}a?.type&&/error/i.test(a.type)&&o.push(Pt({kind:ce.ERROR,provider:t,sessionId:r,timestamp:l,payload:{message:a.error||a.message||"Provider error"},rawRef:c}))}return o.sort((a,l)=>new Date(a.timestamp)-new Date(l.timestamp))}function _l(e=[],t,r="claude"){const o=Array.isArray(e)?[...e]:[];if(!Is(t))return o;const s=t.provider||r,a=t.timestamp||new Date().toISOString(),l=t.payload||{};switch(t.kind){case ce.USER_MESSAGE:{const c=El(t),d=qf(o,t,l),u=Ts(l.contentBlocks),p=typeof l.text=="string"?l.text:"",m=p?Cl(p):"";if(p.trim()&&!m&&u.length===0)break;if(d>=0){const f=o[d]||{},x=Array.isArray(f.images)&&f.images.length>0?u.filter(h=>h?.type!=="image"):u;o[d]={...f,type:"user",content:m||f.content||"",timestamp:f.timestamp||a,provider:s,contentBlocks:x,clientRequestId:c||f.clientRequestId||null,eventId:t.eventId||f.eventId,id:f.id||t.eventId||f.id};break}o.push({type:"user",content:m,timestamp:a,provider:s,contentBlocks:u,clientRequestId:c});break}case ce.ASSISTANT_TEXT_START:{const c=l.messageId||t.extensions?.messageId||qt("assistant_text");$r(o,{messageId:c,timestamp:a,provider:s,isThinking:!1});break}case ce.ASSISTANT_TEXT_DELTA:{const c=l.messageId||t.extensions?.messageId||qt("assistant_text"),{index:d}=$r(o,{messageId:c,timestamp:a,provider:s,isThinking:!1}),u={...o[d]};u.content=ua(u.content||"",l.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||s,o[d]=u;break}case ce.ASSISTANT_TEXT_END:{const c=l.messageId||t.extensions?.messageId;if(!c)break;const d=Mn(o,u=>u?.eventMessageId===c&&!u.isToolUse&&!u.isThinking);d>=0&&(o[d]={...o[d],isStreaming:!1});break}case ce.ASSISTANT_CONTENT_BLOCK:{const c=l.messageId||t.extensions?.messageId||qt("assistant_content"),{index:d}=Zf(o,{messageId:c,timestamp:a,provider:s,role:"assistant"}),u={...o[d]},p=Array.isArray(u.contentBlocks)?[...u.contentBlocks]:[];l.contentBlock&&typeof l.contentBlock=="object"&&p.push(Gt(l.contentBlock)),u.contentBlocks=p,u.provider=u.provider||s,u.timestamp=u.timestamp||a,o[d]=u;break}case ce.REASONING_START:{const c=l.messageId||t.extensions?.messageId||qt("reasoning");$r(o,{messageId:c,timestamp:a,provider:s,isThinking:!0});break}case ce.REASONING_DELTA:{const c=l.messageId||t.extensions?.messageId||qt("reasoning"),{index:d}=$r(o,{messageId:c,timestamp:a,provider:s,isThinking:!0}),u={...o[d]};u.content=ua(u.content||"",l.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||s,u.isThinking=!0,o[d]=u;break}case ce.REASONING_END:{const c=l.messageId||t.extensions?.messageId;if(!c)break;const d=Mn(o,u=>u?.eventMessageId===c&&!!u.isThinking);d>=0&&(o[d]={...o[d],isStreaming:!1,isThinking:!0});break}case ce.TOOL_CALL_START:{const c=l.toolCallId||qt("tool"),{index:d}=zr(o,{toolCallId:c,toolName:l.toolName,timestamp:a,provider:s});o[d]={...o[d],toolName:l.toolName||o[d].toolName,acpToolCall:Fr(o[d].acpToolCall,l)};break}case ce.TOOL_CALL_INPUT:{const c=l.toolCallId||qt("tool"),{index:d}=zr(o,{toolCallId:c,toolName:l.toolName,timestamp:a,provider:s});o[d]={...o[d],toolInput:l.input!==void 0?Rn(l.input):l.rawInput!==void 0?Rn(l.rawInput):o[d].toolInput,provider:o[d].provider||s,acpToolCall:Fr(o[d].acpToolCall,l)};break}case ce.TOOL_CALL_END:{const c=l.toolCallId||t.extensions?.toolCallId;if(!c)break;const{index:d}=zr(o,{toolCallId:c,toolName:l.toolName,timestamp:a,provider:s});o[d]={...o[d],toolName:l.toolName||o[d].toolName,toolEndedAt:a,acpToolCall:Fr(o[d].acpToolCall,l)};break}case ce.TOOL_RESULT:{const c=l.toolCallId||t.extensions?.toolCallId||qt("tool"),{index:d}=zr(o,{toolCallId:c,toolName:l.toolName,timestamp:a,provider:s});o[d]={...o[d],toolResult:{content:Rn(l.content??""),isError:!!l.isError,toolUseResult:l.toolUseResult||null,rawOutput:l.rawOutput,contentBlocks:Array.isArray(l.contentBlocks)?Gt(l.contentBlocks):null,status:l.status||null,timestamp:a},toolError:!!l.isError,toolEndedAt:o[d].toolEndedAt||a,provider:o[d].provider||s,acpToolCall:Fr(o[d].acpToolCall,l)};break}case ce.PLAN_UPDATE:{const c=Array.isArray(l.entries)?Gt(l.entries):[],d=Mn(o,p=>!!p?.isPlanUpdate),u={...d>=0?o[d]:{},id:(d>=0?o[d]?.id:null)||`plan:${t.sessionId||s}`,type:"assistant",content:String(l.message||"Plan updated"),timestamp:a,provider:s,isPlanUpdate:!0,planEntries:c};d>=0?o[d]=u:o.push(u);break}case ce.APPROVAL_REQUEST:l.message&&o.push({type:"assistant",content:l.message,timestamp:a,provider:s,isApprovalRequest:!0,approvalRequest:l});break;case ce.APPROVAL_RESOLVED:l.message&&o.push({type:"assistant",content:l.message,timestamp:a,provider:s,approvalResolution:l});break;case ce.SYSTEM_NOTICE:if(l.message){const c=o[o.length-1];c&&c.type==="assistant"&&!c.isToolUse&&(c.content||"").trim()===String(l.message).trim()||o.push({type:"assistant",content:l.message,timestamp:a,provider:s,isSystemNotice:!0})}break;case ce.ERROR:o.push({type:"error",content:l.message||"Provider error",timestamp:a,provider:s,rawRef:t.rawRef||null,extensions:t.extensions||{}});break}return o}function Al(e=[],t="claude"){return Array.isArray(e)?e.length>0&&!Is(e[0])?Al(eh(e,t),t):e.reduce((r,o)=>_l(r,o,t),[]):[]}function th(e=[]){const t={modeState:null,availableCommands:[],configOptions:[],sessionInfo:null,tokenUsage:null};for(const r of Array.isArray(e)?e:[])if(Is(r)){if(r.kind===ce.MODE_UPDATE){const o=Gf(r.payload||{});o&&(t.modeState=t.modeState?{availableModes:o.availableModes.length>0?o.availableModes:t.modeState.availableModes,currentModeId:o.currentModeId||t.modeState.currentModeId||null}:o)}if(r.kind===ce.AVAILABLE_COMMANDS_UPDATE&&(t.availableCommands=Vf(r.payload||{})),r.kind===ce.CONFIG_OPTION_UPDATE&&(t.configOptions=Jf(r.payload||{})),r.kind===ce.SESSION_INFO_UPDATE){const o=Yf(r.payload||{});o&&(t.sessionInfo={...t.sessionInfo&&typeof t.sessionInfo=="object"?t.sessionInfo:{},...o})}if(r.kind===ce.USAGE_UPDATE){const o=Xf(r.payload||{});o&&(t.tokenUsage=o)}}return t}const se={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},ro=new Set([se.CONNECTING,se.QUEUED,se.STREAMING,se.AWAITING_APPROVAL]),Il=new Set([se.COMPLETED,se.ABORTED,se.ERRORED]);function hn(e){return e==null?"":String(e).replace(/\r\n/g,`
191
+ `).trim()}function pa(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:hn(e.content),isError:!!e.isError}}function nh(e,t){if(!e||!t)return!1;const r=String(e.type||""),o=String(t.type||"");if(r!==o)return!1;const s=!!e.isToolUse,a=!!t.isToolUse;if(s!==a)return!1;if(s&&a){const l=pa(e.toolResult),c=pa(t.toolResult);return hn(e.toolName)===hn(t.toolName)&&hn(e.toolInput)===hn(t.toolInput)&&l.content===c.content&&l.isError===c.isError}return!!e.isThinking!=!!t.isThinking?!1:hn(e.content)===hn(t.content)}function rh(e,t){const r=Math.min(e.length,t.length);let o=0;for(;o<r&&nh(e[o],t[o]);)o+=1;return o}function oh(e=[],t=[],r={}){const o=Array.isArray(e)?e:[],s=Array.isArray(t)?t:[],a=!!r.preserveLocalTail;if(o.length===0)return s;if(s.length===0)return a?o:s;const l=rh(o,s);return l===o.length&&l===s.length?s:a&&l===s.length&&o.length>s.length?o:s}function Br(e,t){return typeof t=="function"?t(e):t}function ma(e,t={}){const r=ro.has(e),o=ro.has(e);return{isLoading:r,canAbortSession:o,...t}}function mr(e,t=se.IDLE){const r=String(e||"").trim().toLowerCase();return Object.values(se).includes(r)?r:t}function Zo(e){return String(e?.rawRef?.type||"").trim().toLowerCase()==="session-status"}function Tl(e){return e===ce.APPROVAL_REQUEST||e===ce.APPROVAL_RESOLVED||e===ce.ASSISTANT_TEXT_START||e===ce.ASSISTANT_TEXT_DELTA||e===ce.ASSISTANT_CONTENT_BLOCK||e===ce.REASONING_START||e===ce.REASONING_DELTA||e===ce.TOOL_CALL_START||e===ce.TOOL_CALL_INPUT||e===ce.TOOL_CALL_END||e===ce.TOOL_RESULT||e===ce.PLAN_UPDATE||e===ce.SYSTEM_NOTICE}function sh(e=[]){let t=!1;for(let r=e.length-1;r>=0;r-=1){const o=e[r];if(!(!o||typeof o!="object")){if(o.kind===ce.ERROR)return se.ERRORED;if(o.kind===ce.SESSION_STATE_CHANGED){const s=mr(o.payload?.state,null);if(!s)continue;if(s===se.IDLE){Zo(o)&&(t=!0);continue}if(Il.has(s))return s;if(Zo(o))continue;return t?se.IDLE:s}if(o.kind===ce.APPROVAL_REQUEST)return t?se.IDLE:se.AWAITING_APPROVAL;if(o.kind===ce.APPROVAL_RESOLVED||Tl(o.kind))return t?se.IDLE:se.STREAMING}}return t?se.IDLE:null}function ah(e=[]){for(let t=e.length-1;t>=0;t-=1){const r=e[t];if(!(!r||typeof r!="object")){if(r.kind===ce.ERROR)return se.ERRORED;if(r.kind===ce.SESSION_STATE_CHANGED){const o=mr(r.payload?.state,null);if(!o||o===se.IDLE||Zo(r))continue;return Il.has(o)?o:null}if(Tl(r.kind))return null}}return null}function ih(e,t){return!e||typeof e!="object"?t:e.kind===ce.SESSION_STATE_CHANGED?mr(e.payload?.state,t):e.kind===ce.APPROVAL_REQUEST?se.AWAITING_APPROVAL:e.kind===ce.APPROVAL_RESOLVED?se.STREAMING:e.kind===ce.ERROR?se.ERRORED:e.kind===ce.ASSISTANT_TEXT_START||e.kind===ce.ASSISTANT_TEXT_DELTA||e.kind===ce.ASSISTANT_CONTENT_BLOCK||e.kind===ce.REASONING_START||e.kind===ce.REASONING_DELTA||e.kind===ce.TOOL_CALL_START||e.kind===ce.TOOL_CALL_INPUT||e.kind===ce.TOOL_CALL_END||e.kind===ce.TOOL_RESULT||e.kind===ce.PLAN_UPDATE||e.kind===ce.SYSTEM_NOTICE?se.STREAMING:t}function lh(e,t){const r=t?.payload||{},o=r.requestId||t?.extensions?.requestId||null,s=r.toolCall&&typeof r.toolCall=="object"?r.toolCall:null,a=Array.isArray(r.options)?r.options:Array.isArray(r.context?.options)?r.context.options:[];return!o||e.some(l=>l?.requestId===o)?e:[...e,{requestId:o,toolName:s?.title||r.toolName||"UnknownTool",input:s?.rawInput??r.input,context:{...r.context||{},kind:s?.kind||r.context?.kind||null,options:a},toolCall:s,options:a,message:r.message||null,sessionId:t?.sessionId||r.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function ch(e,t){const o=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return o?e.filter(s=>s?.requestId!==o):e}function dh(e,t){return t?e===se.AWAITING_APPROVAL||ro.has(e)?e:se.STREAMING:e===se.COMPLETED||e===se.ABORTED||e===se.ERRORED?e:se.IDLE}function uh(e=[]){return{messages:e,pendingPermissionRequests:[],phase:se.IDLE,isLoading:!1,canAbortSession:!1}}function ph(e,t){switch(t.type){case"replace_messages":return{...e,messages:Br(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Br(e.pendingPermissionRequests,t.value)};case"set_phase":{const r=mr(t.phase,e.phase);return{...e,phase:r,...ma(r,t.overrides)}}case"set_loading":{const r=!!Br(e.isLoading,t.value),o=dh(e.phase,r);return{...e,phase:o,isLoading:r,canAbortSession:r?e.canAbortSession||ro.has(o):!1}}case"set_can_abort":return{...e,canAbortSession:!!Br(e.canAbortSession,t.value)};case"apply_conversation_event":{const r=_l(e.messages,t.event,t.provider),o=ih(t.event,e.phase);let s=e.pendingPermissionRequests;if(t.event?.kind===ce.APPROVAL_REQUEST)s=lh(s,t.event);else if(t.event?.kind===ce.APPROVAL_RESOLVED)s=ch(s,t.event);else if(t.event?.kind===ce.SESSION_STATE_CHANGED){const a=mr(t.event?.payload?.state,"");(a===se.COMPLETED||a===se.ABORTED||a===se.ERRORED||a===se.IDLE)&&(s=[])}return{...e,messages:r,pendingPermissionRequests:s,phase:o,...ma(o)}}default:return e}}function _n(e){return e&&e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function mh(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function es(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(t,r)=>{let o=parseInt(r,10);if(!Number.isFinite(o))return t;o<1e12&&(o*=1e3);const s=new Date(o),a=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(s),l=-s.getTimezoneOffset(),c=l>=0?"+":"-",d=Math.abs(l),u=Math.floor(d/60),p=d%60,m=`GMT${c}${u}${p?`:${String(p).padStart(2,"0")}`:""}`,h=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,$=>$.toUpperCase()),N=h?`${m} (${h})`:m,w=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],S=`${s.getDate()} ${w[s.getMonth()]} ${s.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${N}** - ${S}`})}catch{return e}}function Pl(e){return Qo(e)}function fh(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const o=`
192
+
193
+ [USER MESSAGE]
194
+ `,s=t.indexOf(o);return s>=0?t.slice(s+o.length).trim():""}const r=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return r?String(r[1]||"").trim():t}function Ps(e=[]){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];if(t.isToolUse||t.isPlanUpdate||t.approvalRequest||t.approvalResolution)return[t];if(typeof t.content!="string")return[t];if(t.type==="assistant"||t.role==="assistant"){const s=Pl(t.content);return s?s===t.content?[t]:[{...t,content:s}]:[]}const o=fh(t.content);return o?o===t.content?[t]:[{...t,content:o}]:[]}):[]}function hh(e=[],t=[]){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1){const o=e[r],s=t[r];if(o?.type!==s?.type||o?.role!==s?.role||o?.content!==s?.content||o?.timestamp!==s?.timestamp||!!o?.isToolUse!=!!s?.isToolUse)return!1}return!0}function Rs({phaseText:e,detailText:t="",canAbort:r=!0,startedAt:o=Date.now(),elapsedSeconds:s}={}){return{phaseText:e,detailText:t,canAbort:r,startedAt:o,elapsedSeconds:s}}function xh(e,t,r=null){const o=r?.startedAt||Date.now(),s=typeof e=="string"?e:e?.message||e?.status||e?.text||"",a=String(s||"").trim(),l=a.toLowerCase();let c=t("activity.stage.working");return l.includes("permission")?c=t("activity.stage.waitingPermission"):l.includes("think")?c=t("activity.stage.thinking"):l.includes("search")||l.includes("grep")||l.includes("glob")?c=t("activity.stage.searching"):l.includes("command")||l.includes("bash")?c=t("activity.stage.runningCommand"):l.includes("read")?c=t("activity.stage.readingFile"):l.includes("write")||l.includes("edit")||l.includes("patch")?c=t("activity.stage.editingFile"):l.includes("todo")?c=t("activity.stage.updatingTodo"):(l.includes("respond")||l.includes("reply"))&&(c=t("activity.stage.generatingReply")),Rs({phaseText:c,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:o,elapsedSeconds:e?.elapsedSeconds})}const gh=({node:e,inline:t,className:r,children:o,...s})=>{const{t:a}=Et("chat"),[l,c]=i.useState(!1),d=Array.isArray(o)?o.join(""):String(o??""),u=/[\r\n]/.test(d);if(t||e&&e.type==="inlineCode"||!u)return n.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 ${r||""}`,...s,children:o});const f=/language-(\w+)/.exec(r||""),x=f?f[1]:"text",h=d,N=()=>{const w=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator?.clipboard?.writeText)navigator.clipboard.writeText(h).then(w).catch(()=>{const S=document.createElement("textarea");S.value=h,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select();try{document.execCommand("copy")}catch{}document.body.removeChild(S),w()});else{const S=document.createElement("textarea");S.value=h,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select();try{document.execCommand("copy")}catch{}document.body.removeChild(S),w()}}catch{}};return n.jsxs("div",{className:"relative group my-2",children:[x&&x!=="text"&&n.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:x}),n.jsx("button",{type:"button",onClick:N,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?n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:n.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")]}):n.jsxs("span",{className:"flex items-center gap-1",children:[n.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:[n.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),n.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),a("codeBlock.copy")]})}),n.jsx(Td,{language:x,style:Pd,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:x&&x!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},vh={code:gh,blockquote:({children:e})=>n.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),a:({href:e,children:t})=>n.jsx("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:t}),p:({children:e})=>n.jsx("div",{className:"mb-2 last:mb-0",children:e}),table:({children:e})=>n.jsx("div",{className:"overflow-x-auto my-2",children:n.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>n.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>n.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})=>n.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})},ts=({children:e,className:t})=>{const r=mh(String(e??"")),o=i.useMemo(()=>[Ed,_d],[]),s=i.useMemo(()=>[Ad],[]);return n.jsx("div",{className:t,children:n.jsx(Id,{remarkPlugins:o,rehypePlugins:s,components:vh,children:r})})};i.memo(({message:e,prevMessage:t,provider:r,showThinking:o,isActiveStreamingCard:s})=>{const{t:a}=Et("chat"),l=e.provider||e.__provider||r||"claude",c=l==="codex",d=l==="gemini",u=l==="opencode",p=t&&t.type===e.type&&(t.type==="assistant"||t.type==="user"||t.type==="tool"||t.type==="error");return n.jsx("div",{className:`chat-message ${e.type} ${p?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?n.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:[n.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:[n.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&n.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((m,f)=>n.jsx("img",{src:m.data,alt:m.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(m.data,"_blank")},f))}),n.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!p&&n.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"})]}):n.jsxs("div",{className:"w-full",children:[!p&&n.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.type==="error"?n.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"?n.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:"🔧"}):n.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:c?n.jsx(kr,{className:"w-full h-full"}):d?n.jsx(jr,{className:"w-full h-full"}):u?n.jsx(Sr,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):n.jsx(wr,{className:"w-full h-full"})}),n.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.type==="error"?a("messageTypes.error"):e.type==="tool"?a("messageTypes.tool"):c?a("messageTypes.codex"):d?a("messageTypes.gemini"):u?"OpenCode":a("messageTypes.claude")})]}),n.jsxs("div",{className:"w-full",children:[e.isToolUse?n.jsx(Rd,{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?n.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:n.jsxs("details",{className:"group",open:s,children:[n.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:[n.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),n.jsx("span",{children:a("thinking.emoji")})]}),n.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:n.jsx(ts,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):n.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[o&&e.reasoning&&n.jsxs("details",{className:"mb-3",open:s,children:[n.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:a("thinking.emoji")}),n.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:n.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const m=Pl(es(String(e.content||""))),f=m.trim();if((f.startsWith("{")||f.startsWith("["))&&(f.endsWith("}")||f.endsWith("]")))try{const x=JSON.parse(f),h=JSON.stringify(x,null,2);return n.jsxs("div",{className:"my-2",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("span",{className:"font-medium",children:"JSON Response"})]}),n.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:n.jsx("pre",{className:"p-4 overflow-x-auto",children:n.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:h})})})]})}catch{}return e.type==="assistant"?n.jsx(ts,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:m}):n.jsx("div",{className:"whitespace-pre-wrap",children:m})})()]}),n.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${p?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});function yh({hasSelectedProject:e=!1,hasMessages:t=!1,hasSessionContext:r=!1,isLoading:o=!1,isLoadingSessionMessages:s=!1}={}){return e?t?"messages":s?"loading-session-messages":r?o?"running-empty":"continue":"provider-selection":"no-project"}function bh({canAbortSession:e=!1,hasInput:t=!1,isInputDisabled:r=!1,isLoading:o=!1}={}){return e&&o?{kind:"abort",disabled:!1}:{buttonType:"button",kind:"submit",disabled:!t||r}}function wh({modes:e=[],disabled:t=!1}={}){return(Array.isArray(e)?e.filter(o=>o?.id):[]).length>1&&!t}function kh({isOpen:e=!1,commands:t=[]}={}){const r=Array.isArray(t)?t.filter(Boolean):[];return e&&r.length>0}function jh({hasSlashCommands:e=!1}={}){return e?"input.placeholder":"input.placeholderWithoutCommands"}function Sh({hasSlashCommands:e=!1,sendByCtrlEnter:t=!1}={}){return e?t?"input.hintText.ctrlEnter":"input.hintText.enter":t?"input.hintText.ctrlEnterWithoutCommands":"input.hintText.enterWithoutCommands"}function Rl(e,t){return Number.isInteger(e)&&e>=0&&e<t?e:-1}function Nh(e=[],t=-1){const r=Array.isArray(e)?e:[],o=Rl(t,r.length),s=o>=0?r[o]:null;return{activeImage:s,activeIndex:o,isOpen:s!==null}}const Ch=[{id:"claude",label:"Claude Code",Logo:wr},{id:"codex",label:"Codex",Logo:kr},{id:"gemini",label:"Gemini",Logo:jr},{id:"opencode",label:"OpenCode",Logo:Sr}];function Eh({provider:e,onSelect:t}){return n.jsx("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:Ch.map(({id:r,label:o,Logo:s})=>n.jsxs("button",{onMouseDown:a=>a.preventDefault(),onClick:()=>t(r),className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${e===r?"border-primary/50 bg-primary/5 text-foreground shadow-sm":"border-border/60 bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:text-foreground"}`,children:[r==="opencode"?n.jsx(s,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}):n.jsx(s,{className:"h-10 w-10 flex-shrink-0"}),n.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:o})]},r))})}function _h(e,t){const r=e.split(`
195
+ `),o=t.split(`
196
+ `),s=[];let a=0,l=0;for(;a<r.length||l<o.length;){const c=r[a],d=o[l];a>=r.length?(s.push({type:"added",content:d,lineNum:l+1}),l+=1):l>=o.length?(s.push({type:"removed",content:c,lineNum:a+1}),a+=1):c===d?(a+=1,l+=1):(s.push({type:"removed",content:c,lineNum:a+1}),s.push({type:"added",content:d,lineNum:l+1}),a+=1,l+=1)}return s}function Ah({selectedProject:e,selectedSession:t,currentSessionId:r,provider:o,chatMessages:s,threadMessages:a,isLoading:l,isLoadingSessionMessages:c,isLoadingMoreMessages:d,hasMoreMessages:u,totalMessages:p,sessionMessages:m,visibleMessageCount:f,pendingPermissionRequests:x,scrollContainerRef:h,messagesEndRef:N,onScroll:w,onLoadEarlierSessionMessages:S,onLoadEarlierMessages:$,onProviderSelection:F,onFileOpen:Z,onShowSettings:z,onGrantToolPermission:R,onPermissionDecision:E,autoExpandTools:B,showRawParameters:I}){const{t:Y}=Et("chat"),_=o==="codex"?"Codex":o==="gemini"?"Gemini":o==="opencode"?"OpenCode":"Claude",re=i.useMemo(()=>{const de=new Map;return(ve,fe)=>{const U=`${ve.length}-${fe.length}-${ve.slice(0,50)}`;if(de.has(U))return de.get(U);const le=_h(ve,fe);if(de.set(U,le),de.size>100){const oe=de.keys().next().value;de.delete(oe)}return le}},[]),ie=s.length===0?null:n.jsxs(n.Fragment,{children:[d&&n.jsx("div",{className:"pb-3 text-center text-gray-500 dark:text-gray-400",children:n.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),n.jsx("p",{className:"text-sm",children:Y("session.loading.olderMessages")})]})}),u&&!d&&n.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:p>0&&n.jsxs("span",{children:[Y("session.messages.showingOf",{shown:m.length,total:p})," •",n.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:S,children:Y("session.messages.loadEarlier")}),n.jsx("span",{className:"ml-1 text-xs",children:Y("session.messages.scrollToLoad")})]})}),!t&&!u&&s.length>f&&n.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[Y("session.messages.showingLast",{count:f,total:s.length})," •",n.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:$,children:Y("session.messages.loadEarlier")})]})]}),V=s.length===0?null:n.jsx(n.Fragment,{children:x.map(de=>n.jsx(Md,{request:de,className:"mx-1 my-3 sm:mx-0",onSelectOption:ve=>E(de.requestId,{optionId:ve,outcome:{outcome:"selected",optionId:ve}}),onCancel:()=>E(de.requestId,{cancelled:!0,outcome:{outcome:"cancelled"}})},de.requestId))}),ae=yh({hasSelectedProject:!!e,hasMessages:s.length>0,hasSessionContext:!!(t||r),isLoading:l,isLoadingSessionMessages:c});return e?n.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:ae==="loading-session-messages"?n.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:n.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),n.jsx("p",{children:Y("session.loading.sessionMessages")})]})}):ae==="provider-selection"?n.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:n.jsxs("div",{className:"w-full max-w-3xl text-center",children:[n.jsx("h2",{className:"mb-2 text-3xl font-semibold tracking-tight text-foreground sm:text-4xl",children:Y("providerSelection.title")}),n.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:Y("providerSelection.description")}),n.jsx(Eh,{provider:o,onSelect:F})]})}):ae==="continue"?n.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:n.jsxs("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:[n.jsx("p",{className:"mb-3 text-2xl font-semibold text-foreground",children:Y("session.continue.title")}),n.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:Y("session.continue.description")})]})}):ae==="running-empty"?n.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:n.jsx("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:n.jsxs("div",{className:"mb-3 flex items-center justify-center gap-2",children:[n.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-b-2 border-gray-400"}),n.jsx("p",{className:"text-sm sm:text-base",children:Y("session.loading.waitingForFirstReply")})]})})}):n.jsx(Dd,{messages:a,convertMessage:Ld,isRunning:l,scrollContainerRef:h,onScroll:w,messagesEndRef:N,provider:o,providerLabel:_,createDiff:re,onFileOpen:Z,onShowSettings:z,onGrantToolPermission:R,showRawParameters:I,autoExpandTools:B,selectedProject:e,markdownRenderer:ts,topContent:ie,bottomContent:V})}):n.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 sm:px-6",children:n.jsxs("div",{className:"max-w-lg px-8 py-10 text-center text-muted-foreground",children:[n.jsx("div",{className:"mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:n.jsx(ys,{className:"h-7 w-7"})}),n.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})})}const ln=({children:e,content:t,position:r="top",className:o="",delay:s=500})=>{const[a,l]=i.useState(!1),[c,d]=i.useState(null),u=()=>{const x=setTimeout(()=>{l(!0)},s);d(x)},p=()=>{c&&(clearTimeout(c),d(null)),l(!1)},m=()=>{switch(r){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"}},f=()=>{switch(r){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return t?n.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:p,children:[e,a&&n.jsxs("div",{className:xt("absolute z-50 w-max max-w-[min(32rem,calc(100vw-2rem))] px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-normal break-words pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",m(),o),children:[t,n.jsx("div",{className:xt("absolute w-0 h-0 border-4 border-transparent",f())})]})]}):e};function Ih(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Th(e){if(typeof e!="string")return"";const r=e.replace(/\\/g,"/").split("/").filter(Boolean);return r[r.length-1]||e}const Jn="1",fa=5,ha="replace",ns="append";function xn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Zt(e){return typeof e=="string"&&e.trim().length>0}function oo(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function xo(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!xn(e)||typeof e.path!="string"||!t&&!e.path.trim()||e.displayName!==void 0&&typeof e.displayName!="string"?null:{path:e.path,displayName:e.displayName||""}}function On(e){return xo(e)?.path||""}function Ph(e){const t=xo(e);return t?Zt(t.displayName)?t.displayName:Th(t.path):""}function Rh(e,t=72){if(typeof e!="string")return"";const r=e.trim().replace(/\s+/g," ");if(r.length<=t)return r;const o=r.split(/\s*>\s*/).filter(Boolean);if(o.length<=1)return`...${r.slice(-(t-3))}`;const s=[];let a=3;for(let c=o.length-1;c>=0;c-=1){const d=o[c],u=a+d.length+(s.length>0?3:0);if(s.length>0&&u>t)break;s.unshift(d),a=u}const l=`... > ${s.join(" > ")}`;return l.length<=t?l:`...${l.slice(-(t-3))}`}function xa(e){if(!e)return"";const t=[];Zt(e.label)&&t.push(e.label.trim());const r=Rh(e.selector);return r&&t.push(r),t.join(" · ")}function Mh(e){return e?Zt(e.systemContext)||Zt(On(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:xn(e.extensions)&&Object.keys(e.extensions).length>0:!1}function Dh(e){return e?Zt(e.systemContext)||Zt(On(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function Ml(e){if(!xn(e)||e.version!==Jn||typeof e.systemContext!="string")return null;const t=xo(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const r=[];for(const s of e.selectedElements){if(!xn(s)||typeof s.tag!="string"||typeof s.selector!="string"||typeof s.label!="string")return null;r.push({tag:s.tag,selector:s.selector,label:s.label})}if(e.extensions!==void 0&&!xn(e.extensions))return null;const o={version:Jn,systemContext:e.systemContext,currentFile:t,selectedElements:r};return e.extensions!==void 0&&(o.extensions={...e.extensions}),o}function Lh(e){if(!xn(e)||e.version!==void 0&&e.version!==Jn||e.systemContext!==void 0&&typeof e.systemContext!="string"||e.selectedElements!==void 0&&!Array.isArray(e.selectedElements))return null;const t={};if(e.systemContext!==void 0&&(t.systemContext=e.systemContext),e.currentFile!==void 0){const r=xo(e.currentFile);if(!r)return null;t.currentFile=r}if(e.selectedElements!==void 0){const r=[];for(const o of e.selectedElements){if(!xn(o)||typeof o.tag!="string"||typeof o.selector!="string"||typeof o.label!="string")return null;r.push({tag:o.tag,selector:o.selector,label:o.label})}t.selectedElements=r}if(e.extensions!==void 0){if(!xn(e.extensions))return null;t.extensions={...e.extensions}}return t}function Oh(e){return`${e.tag}::${e.selector}::${e.label}`}function Fh(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,r=[];for(const o of e){const s=Oh(o);t.has(s)||(t.add(s),r.push(o))}return r}function $h(){return{version:Jn,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function zh(e,t){const r=Ml(e)||$h(),o=Lh(t);if(!o)return null;const s={...r};return o.systemContext!==void 0&&(s.systemContext=o.systemContext),o.currentFile!==void 0&&Zt(On(o.currentFile))&&(s.currentFile=o.currentFile),o.selectedElements!==void 0&&(s.selectedElements=Fh([...Array.isArray(r.selectedElements)?r.selectedElements:[],...o.selectedElements])),o.extensions!==void 0&&(s.extensions={...xn(r.extensions)?r.extensions:{},...o.extensions}),s}function Bh(e){return typeof e!="string"?ha:e.trim().toLowerCase()===ns?ns:ha}function ga(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const o=oo(e);if(!o)return null;try{t=JSON.parse(o)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const r=Ml(t);return r||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function Uh(e){if(!e)return null;const t={version:Jn,systemContext:e.systemContext||"",currentFile:On(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(t.extensions=e.extensions),t}function Wh(e,t){return`<dynamic_context version="${Jn}">
197
+ ${JSON.stringify(e,null,2)}
198
+ </dynamic_context>
199
+
200
+ <user_message>
201
+ ${t}
202
+ </user_message>`}function Kh({visibleDynamicContext:e,visibleSelectedElements:t,hiddenSelectedElements:r,onDismissSystemContext:o,onDismissCurrentFile:s,onDismissSelectedElement:a}){const{t:l}=Et("chat");return e?n.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Zt(e.systemContext)&&n.jsx(ln,{content:e.systemContext,className:"whitespace-normal break-words max-w-sm",delay:200,children:n.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:[n.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:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 12h16M4 19h16"})}),n.jsx("span",{className:"truncate",children:l("input.dynamicContext.systemChip")}),n.jsx("button",{type:"button",onClick:o,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:l("input.dynamicContext.removeSystem"),"aria-label":l("input.dynamicContext.removeSystem"),children:n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),Zt(On(e.currentFile))&&n.jsx(ln,{content:On(e.currentFile),className:"whitespace-normal break-words max-w-sm",delay:200,children:n.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:[n.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:n.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"})}),n.jsx("span",{className:"truncate",children:Ph(e.currentFile)}),n.jsx("button",{type:"button",onClick:s,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:l("input.dynamicContext.removeCurrentFile"),"aria-label":l("input.dynamicContext.removeCurrentFile"),children:n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),t.map((c,d)=>n.jsx(ln,{content:xa(c),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-normal break-words",delay:200,children:n.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:c.selector,children:[n.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 15l2 5L7 17l3-10 10 3-5 2z"})}),n.jsx("span",{className:"truncate",children:c.tag||l("input.dynamicContext.elementFallback")}),n.jsx("button",{type:"button",onClick:()=>a(c),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:l("input.dynamicContext.removeElement"),"aria-label":l("input.dynamicContext.removeElement"),children:n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},`${c.selector}-${d}`)),r.length>0&&n.jsx(ln,{content:r.map(xa).join(`
203
+ `),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:n.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:["+",r.length]})})]})}):null}function Hh({file:e,index:t,onPreview:r,onRemove:o,uploadProgress:s,error:a}){const[l,c]=i.useState(null);return i.useEffect(()=>{const d=URL.createObjectURL(e);return c(d),()=>URL.revokeObjectURL(d)},[e]),n.jsxs("div",{className:"relative group",children:[n.jsx("button",{type:"button",onClick:()=>r(t),disabled:!l,className:"block touch-manipulation overflow-hidden rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/40 disabled:cursor-default",children:n.jsx("img",{src:l,alt:e.name,className:"h-20 w-20 object-cover rounded-lg"})}),s!==void 0&&s<100&&n.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:n.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),a&&n.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:n.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),n.jsx("button",{type:"button",onClick:o,onMouseDown:d=>d.stopPropagation(),onTouchStart:d=>d.stopPropagation(),className:"absolute -right-2 -top-2 rounded-full bg-red-500 p-1 text-white opacity-100 shadow-sm transition-opacity sm:opacity-0 sm:group-hover:opacity-100",children:n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}function qh({attachedImages:e,uploadingImages:t,imageErrors:r,onRemove:o}){const[s,a]=i.useState(-1),[l,c]=i.useState(null),d=i.useMemo(()=>Nh(e,s),[e,s]);return i.useEffect(()=>{if(!d.isOpen)return;const u=m=>{m.key==="Escape"&&a(-1)},p=document.body.style.overflow;return document.body.style.overflow="hidden",window.addEventListener("keydown",u),()=>{document.body.style.overflow=p,window.removeEventListener("keydown",u)}},[d.isOpen]),i.useEffect(()=>{const u=Rl(s,e.length);u!==s&&a(u)},[e.length,s]),i.useEffect(()=>{if(!d.activeImage){c(null);return}const u=URL.createObjectURL(d.activeImage);return c(u),()=>URL.revokeObjectURL(u)},[d.activeImage]),e.length?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:n.jsx("div",{className:"flex flex-wrap gap-2",children:e.map((u,p)=>n.jsx(Hh,{file:u,index:p,onPreview:a,onRemove:()=>o(p),uploadProgress:t.get(u.name),error:r.get(u.name)},`${u.name}-${p}`))})}),d.isOpen&&l&&n.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/85 p-3 sm:p-6",onClick:()=>a(-1),role:"dialog","aria-modal":"true","aria-label":d.activeImage?.name||"Image preview",children:[n.jsx("button",{type:"button",onClick:()=>a(-1),className:"absolute right-3 top-3 rounded-full bg-white/10 p-2 text-white backdrop-blur-sm transition-colors hover:bg-white/20 sm:right-5 sm:top-5","aria-label":"Close image preview",children:n.jsx(Wt,{className:"h-5 w-5"})}),n.jsxs("div",{className:"flex max-h-full w-full max-w-5xl flex-col items-center gap-3",onClick:u=>u.stopPropagation(),children:[n.jsx("img",{src:l,alt:d.activeImage?.name||"Preview",className:"max-h-[82vh] w-auto max-w-full rounded-2xl object-contain shadow-2xl"}),n.jsx("div",{className:"max-w-full truncate px-4 text-center text-sm text-white/80",children:d.activeImage?.name})]})]})]}):null}function Gh(e){if(typeof e?.percentage=="number")return`${Math.min(100,Math.max(0,e.percentage))}%`;if(typeof e?.used=="number"&&typeof e?.total=="number"&&e.total>0){const t=Math.round(e.used/e.total*100);return`${Math.min(100,Math.max(0,t))}%`}return"0%"}function Vh({composer:e,statusPresentation:t,shouldShowClaudeStatus:r,isLoading:o,chatMessages:s,sendByCtrlEnter:a}){const{t:l}=Et("chat"),{provider:c,currentModel:d,modelOptions:u,selectedModelLabel:p,isModelSelectionLocked:m,isOpencodeModelLoading:f,permissionMode:x,acpModes:h,acpModeId:N,handleAcpModeChange:w,selectedPermissionShortLabel:S,permissionDropdownTitle:$,providerModeConfig:F,getPermissionModeLabel:Z,providerThinkingConfig:z,thinkingMode:R,setThinkingMode:E,tokenBudget:B,input:I,isInputFocused:Y,setIsInputFocused:_,textareaRef:re,inputContainerRef:ie,inputHighlightRef:V,isFileMentionsEnabled:ae,hasSlashCommandsAvailable:de,showFileDropdown:ve,filteredFiles:fe,selectedFileIndex:U,selectFile:le,showCommandMenu:oe,filteredCommands:Te,selectedCommandIndex:te,handleCommandSelect:Q,commandQuery:we,frequentCommands:Ie,slashPosition:ye,setShowCommandMenu:Oe,setSelectedCommandIndex:Be,setSlashPosition:$e,setCommandQuery:he,getRootProps:et,getInputProps:_e,isDragActive:Xe,openImagePicker:Fe,attachedImages:Re,uploadingImages:ut,imageErrors:tt,removeAttachedImage:Ue,visibleDynamicContext:We,visibleSelectedElements:ot,hiddenSelectedElements:Me,handleDismissSystemContext:st,handleDismissCurrentFile:C,handleDismissSelectedElement:T,renderInputWithMentions:me,handleInputChange:xe,handleTextareaClick:y,handleKeyDown:D,handlePaste:H,syncInputOverlayScroll:L,handleTextareaInput:O,activeInputProvider:ne,isActiveProviderNotInstalled:ke,unavailablePlaceholder:Ge,isInputDisabled:at,activeProviderInstallReason:pe,activeProviderInstallHint:ze,isCheckingProviderInstallation:Je,checkProviderInstallation:it,providerCheckLoadingByName:Ct,handleSubmit:Mt,isUserScrolledUp:v,scrollToBottom:M,setProviderModel:G,setPermissionMode:be,selectedSession:b,handleAbortSession:J,canAbortSession:ee,modelSelectorRef:Ae,permissionSelectorRef:Qe,activeProviderInstallState:j,activeInputProviderLabel:ue}=e,ge=bh({canAbortSession:ee,hasInput:!!I.trim(),isInputDisabled:at,isLoading:o}),Ne=wh({disabled:at||!b?.id,modes:h}),He=kh({isOpen:oe,commands:Te}),Ze=jh({hasSlashCommands:de}),Dt=Sh({hasSlashCommands:de,sendByCtrlEnter:a});return n.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:[n.jsx("div",{className:"flex-1",children:n.jsx(Od,{phaseText:t?.phaseText,detailText:t?.detailText,elapsedSeconds:t?.elapsedSeconds,startedAt:t?.startedAt,canAbort:t?.canAbort,isLoading:r,onAbort:J,provider:c})}),n.jsx("div",{ref:ie,className:"mx-auto mb-3 w-full max-w-4xl"}),n.jsxs("form",{onSubmit:Mt,className:"relative mx-auto w-full max-w-4xl",children:[v&&s.length>0&&n.jsx("button",{type:"button",onClick:M,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:n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})}),Xe&&n.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center rounded-2xl border border-dashed border-primary bg-primary/5",children:n.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4",children:[n.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("p",{className:"text-sm font-medium",children:"将图片拖到这里"})]})}),n.jsx(qh,{attachedImages:Re,uploadingImages:ut,imageErrors:tt,onRemove:Ue}),n.jsx(Kh,{visibleDynamicContext:We,visibleSelectedElements:ot,hiddenSelectedElements:Me,onDismissSystemContext:st,onDismissCurrentFile:C,onDismissSelectedElement:T}),ae&&ve&&fe.length>0&&n.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:fe.map((De,Lt)=>n.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${Lt===U?"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:jt=>{jt.preventDefault(),jt.stopPropagation()},onClick:jt=>{jt.preventDefault(),jt.stopPropagation(),le(De)},children:[n.jsx("div",{className:"font-medium text-sm",children:De.name}),n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:De.path})]},De.path))}),n.jsx(Fd,{commands:Te,selectedIndex:te,onSelect:Q,onClose:()=>{Oe(!1),$e(-1),he(""),Be(-1)},position:{top:re.current?Math.max(16,re.current.getBoundingClientRect().top-316):0,left:re.current?re.current.getBoundingClientRect().left:16,bottom:re.current?window.innerHeight-re.current.getBoundingClientRect().top+8:90},isOpen:He,frequentCommands:we?[]:Ie}),n.jsxs("div",{...et(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${e.isTextareaExpanded?"chat-input-expanded":""} ${Y?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[n.jsx("input",{..._e()}),n.jsx("div",{ref:V,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-[24px]",children:n.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:me(I)})}),n.jsxs("div",{className:"relative z-10 flex flex-col",children:[n.jsx("div",{className:"relative px-4 pt-4",children:n.jsx("textarea",{ref:re,value:I,onChange:xe,onClick:y,onKeyDown:D,onPaste:H,onScroll:De=>L(De.target),onFocus:()=>_(!0),onBlur:()=>_(!1),onInput:O,placeholder:ke?Ge:l(Ze,{provider:ne==="codex"?l("messageTypes.codex"):ne==="gemini"?l("messageTypes.gemini"):ne==="opencode"?"OpenCode":l("messageTypes.claude")}),disabled:at,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"}})}),ke&&n.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:[n.jsx("div",{children:pe||Ge}),ze&&n.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:ze}),n.jsx("div",{className:"mt-2",children:n.jsx("button",{type:"button",onClick:()=>it(ne,{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:Je,children:l(Je?"input.checkingInstallation":"input.recheckInstallation")})})]}),n.jsxs("div",{className:"flex items-end justify-between gap-2 px-3 pb-3 pt-2 sm:items-center",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 sm:flex-nowrap sm:gap-2",children:[n.jsxs("button",{type:"button",onClick:()=>{at||Fe()},disabled:at,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:l("input.attachImages"),children:[n.jsx(hr,{className:"h-4 w-4 sm:hidden"}),n.jsx("svg",{className:"hidden h-5 w-5 sm:block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})]}),n.jsx("div",{ref:Ae,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:n.jsxs(Ho,{value:d||void 0,onValueChange:G,disabled:at||f||m,children:[n.jsx(qo,{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:n.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[f&&n.jsx(Tt,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),n.jsx("span",{className:"truncate max-w-[120px] sm:max-w-[240px] md:max-w-[300px] text-xs font-normal text-muted-foreground",children:f?l("input.loadingModels"):p}),n.jsx(Ko,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),n.jsx(Go,{children:f?n.jsx(Yr,{value:"__loading",disabled:!0,children:l("input.loadingModels")}):u.map(({value:De,label:Lt})=>n.jsx(Yr,{value:De,children:Lt},De))})]})}),n.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:Qe,children:n.jsxs(Ho,{value:x,onValueChange:De=>{be(De),b&&localStorage.setItem(`permissionMode-${b.id}`,De)},disabled:at,children:[n.jsx(qo,{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:n.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[n.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:S||$||l("input.clickToChangeMode")}),n.jsx(Ko,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),n.jsx(Go,{children:n.jsxs($d,{children:[n.jsx(zd,{children:$}),F.modes.map(De=>n.jsx(Yr,{value:De,children:Z(De,{short:!0})},De))]})})]})}),Ne?n.jsx(Bd,{modes:h,value:N,onValueChange:w,disabled:at||!b?.id,label:"智能体模式"}):null,z.enabled&&n.jsx(Ud,{selectedMode:R,onModeChange:E,className:"sm:flex-none"}),B!==null&&n.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:[n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("span",{children:Gh(B)})]}),n.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700 mx-1 hidden sm:block"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative group hidden sm:block",children:[n.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:l("input.commands"),children:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.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:n.jsx("p",{children:l(Dt)})})]}),ge.kind==="abort"?n.jsx("button",{type:"button",onClick:J,className:"flex h-9 w-9 items-center justify-center rounded-full bg-red-600 text-white transition-colors hover:bg-red-500",title:l("input.stop"),"aria-label":l("input.stop"),children:n.jsx(Wd,{className:"h-4 w-4 fill-current"})}):n.jsx("button",{type:ge.buttonType,disabled:ge.disabled,onClick:De=>{De.preventDefault(),Mt(De)},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:n.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h12m-5-5 5 5-5 5"})})})]})]})]})]})]})]})}function Dn(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const r=t.replace(/\\/g,"/");return r==="/"?"/":/^[A-Za-z]:\/?$/.test(r)?`${r[0]}:/`:r.replace(/\/+$/,"")}function lr(e){if(typeof e!="string")return!1;const t=e.trim();return t?/^new-session-\d+$/i.test(t)||/^codex-\d+$/i.test(t):!1}function dr(e,t){const r=Dn(t);return r?[e?.fullPath,e?.path].some(o=>Dn(o)===r):!1}function Jh(e,t,r={}){if(!t||!Array.isArray(e))return null;const o=typeof r.provider=="string"?r.provider.trim().toLowerCase():"",s=typeof r.projectName=="string"?r.projectName.trim():"",a=Dn(r.projectPath);for(const l of e){if(!((!s||l?.name===s)&&(!a||dr(l,a))))continue;const d=[{provider:"claude",items:l?.sessions},{provider:"codex",items:l?.codexSessions},{provider:"gemini",items:l?.geminiSessions},{provider:"opencode",items:l?.opencodeSessions}];for(const u of d){if(o&&u.provider!==o)continue;const p=u.items?.find(m=>m?.id===t);if(p)return{project:l,session:p,provider:u.provider}}}return null}function Dl({projects:e,queryProject:t=null,queryCwd:r=null}){if(!Array.isArray(e)||e.length===0)return null;const o=Dn(t),s=Dn(r);return e.find(a=>dr(a,s)?!0:o?[a?.name,a?.fullPath,a?.path].some(l=>Dn(l)===o):!1)||null}function Yh({projects:e,queryProject:t=null,queryCwd:r=null}){const o=Dl({projects:e,queryProject:t,queryCwd:r});return!!(o&&!o.detailsLoaded)}function Xh(e,t){return Object.freeze({value:e,label:t})}function rr(e,t){return Object.freeze({OPTIONS:Object.freeze(t.map(([r,o])=>Xh(r,o))),DEFAULT:e})}const Nr=Object.freeze({claude:rr("sonnet",[["sonnet","Sonnet"],["opus","Opus"],["haiku","Haiku"],["opusplan","Opus Plan"],["sonnet[1m]","Sonnet [1M]"]]),cursor:rr("gpt-5",[["gpt-5","GPT-5"],["gpt-5.2-high","GPT-5.2 High"],["gemini-3-pro","Gemini 3 Pro"],["opus-4.5-thinking","Claude 4.5 Opus (Thinking)"],["gpt-5.2","GPT-5.2"],["gpt-5.1","GPT-5.1"],["gpt-5.1-high","GPT-5.1 High"],["composer-1","Composer 1"],["auto","Auto"],["sonnet-4.5","Claude 4.5 Sonnet"],["sonnet-4.5-thinking","Claude 4.5 Sonnet (Thinking)"],["opus-4.5","Claude 4.5 Opus"],["gpt-5.1-codex","GPT-5.1 Codex"],["gpt-5.1-codex-high","GPT-5.1 Codex High"],["gpt-5.1-codex-max","GPT-5.1 Codex Max"],["gpt-5.1-codex-max-high","GPT-5.1 Codex Max High"],["opus-4.1","Claude 4.1 Opus"],["grok","Grok"]]),codex:rr("gpt-5.2-codex",[["gpt-5","GPT-5"],["gpt-5-codex","GPT-5 Codex"],["gpt-5-codex-mini","GPT-5 Codex Mini"],["gpt-5.1","GPT-5.1"],["gpt-5.1-codex","GPT-5.1 Codex"],["gpt-5.1-codex-max","GPT-5.1 Codex Max"],["gpt-5.1-codex-mini","GPT-5.1 Codex Mini"],["gpt-5.2","GPT-5.2"],["gpt-5.2-codex","GPT-5.2 Codex"],["gpt-5.2-high","GPT-5.2 High"],["gpt-5.2-low","GPT-5.2 Low"],["gpt-5.2-medium","GPT-5.2 Medium"],["gpt-5.2-xhigh","GPT-5.2 XHigh"],["gpt-5.3-codex","GPT-5.3 Codex"],["gpt-5.3-codex-high","GPT-5.3 Codex High"],["gpt-5.3-codex-low","GPT-5.3 Codex Low"],["gpt-5.3-codex-medium","GPT-5.3 Codex Medium"],["gpt-5.3-codex-xhigh","GPT-5.3 Codex XHigh"]]),gemini:rr("gemini-3-pro-preview",[["gemini-2.5-pro","Gemini 2.5 Pro"],["gemini-2.5-flash","Gemini 2.5 Flash"],["gemini-3-pro-preview","Gemini 3 Pro Preview"],["gemini-3-flash-preview","Gemini 3 Flash Preview"]]),opencode:rr("kimi-k2.5",[["kimi-k2.5","Kimi K2.5"]])}),Qh=Nr.claude;Nr.cursor;const Ll=Nr.codex,Zh=Nr.gemini,ex=Nr.opencode,tx=["claude","codex","gemini","opencode"],Ur="unknown",nx="installed",To="not_installed",rx="checking",ox=["claude","codex","gemini","opencode"],sx=300*1e3;function Vt(e){const t=String(e||"").trim().toLowerCase();return tx.includes(t)?t:"claude"}function ax(e){switch(e){case"codex":return Ll;case"gemini":return Zh;case"opencode":return ex;case"claude":default:return Qh}}function go(e){return`${Vt(e)}-model`}function Ms(e){return`${go(e)}-selection-source`}function Wr(e){const t=Vt(e),r=go(t),o=Ms(t);return localStorage.getItem(o)!=="manual"?"":localStorage.getItem(r)||""}function ix(e,t){const r=Vt(e);localStorage.setItem(go(r),t),localStorage.setItem(Ms(r),"manual")}function lx(e){const t=Vt(e);localStorage.removeItem(go(t)),localStorage.removeItem(Ms(t))}function Ol(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const cx=new Set(Ll.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function dx(e){if(!Ol(e))return!1;const t=e.trim().toLowerCase();return cx.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function ux(e,t){return Vt(e)==="codex"?dx(t):Ol(t)}function Kr(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}const va=new WeakMap;let ya=0;function px(e){const t=e instanceof Date?e.getTime():new Date(e||Date.now()).getTime();return Number.isNaN(t)?Date.now():t}function mx(e){return String(e||"").replace(/\s+/g," ").trim().slice(0,120)}function fx(e,t){const r=px(e?.timestamp),o=String(e?.role||e?.type||"assistant").trim().toLowerCase(),s=String(e?.provider||e?.__provider||"").trim().toLowerCase(),a=String(e?.clientRequestId||e?.requestId||"").trim(),l=String(e?.eventId||e?.toolCallId||e?.toolId||"").trim(),c=mx(e?.content||e?.toolName||e?.reasoning||(e?.isThinking?"thinking":"")||(e?.isLoadingIndicator?"loading-indicator":"")),d=[e?.isToolUse?"tool":"message",e?.isThinking?"thinking":"",e?.isPlanUpdate?"plan":"",e?.isLoadingIndicator?"loading":""].filter(Boolean).join(":");return[o,s,r,a,l,d,c,t].join(":")}function hx(e,t){if(e?.__threadMessageId)return String(e.__threadMessageId);const r=e?.id||e?.eventMessageId||e?.messageId||e?.toolCallId||e?.toolId||e?.requestId;if(r)return String(r);if(e&&typeof e=="object"){const o=va.get(e);if(o)return o;const s=fx(e,t);return va.set(e,s),s}return ya+=1,`runtime:${ya}:${t}`}const gt={setItem:(e,t)=>{try{if(e.startsWith("chat_messages_")&&typeof t=="string")try{const r=JSON.parse(t);if(Array.isArray(r)&&r.length>50){const o=r.slice(-50);t=JSON.stringify(o)}}catch(r){console.warn("Could not parse chat messages for truncation:",r)}localStorage.setItem(e,t)}catch(r){if(r.name==="QuotaExceededError"){const o=Object.keys(localStorage),s=o.filter(l=>l.startsWith("chat_messages_")).sort();s.length>3&&s.slice(0,s.length-3).forEach(l=>{localStorage.removeItem(l)}),o.filter(l=>l.startsWith("draft_input_")).forEach(l=>{localStorage.removeItem(l)});try{localStorage.setItem(e,t)}catch(l){if(e.startsWith("chat_messages_")&&typeof t=="string")try{const c=JSON.parse(t);Array.isArray(c)&&c.length>10&&localStorage.setItem(e,JSON.stringify(c.slice(-10)))}catch(c){console.error("Final save attempt failed:",c)}else console.error("Failed to save to localStorage even after cleanup:",l)}}else console.error("localStorage error:",r)}},getItem:e=>{try{return localStorage.getItem(e)}catch(t){return console.error("localStorage getItem error:",t),null}},removeItem:e=>{try{localStorage.removeItem(e)}catch(t){console.error("localStorage removeItem error:",t)}}};function Fl(e){return e?`chat_messages_${e}`:""}function $l(e,t=null){return e?t?`chat_messages_${e}__session_${t}`:Fl(e):""}function xx(e,t=null){const r=$l(e,t);if(!r)return[];const o=gt.getItem(r);if(!o)return[];try{return Ps(JSON.parse(o))}catch(s){return console.warn("Failed to parse cached chat messages:",s),[]}}function zl(e,t=null,r=[]){const o=$l(e,t);if(!o)return;const s=Ps(r);if(s.length===0){gt.removeItem(o);return}gt.setItem(o,JSON.stringify(s)),t&&gt.removeItem(Fl(e))}const Bl="claude-settings";function gx(){const e=gt.getItem(Bl);if(!e)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const t=JSON.parse(e);return{...t,allowedTools:Array.isArray(t.allowedTools)?t.allowedTools:[],disallowedTools:Array.isArray(t.disallowedTools)?t.disallowedTools:[],skipPermissions:!!t.skipPermissions,projectSortOrder:t.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function vx(e){if(!e)return{success:!1};const t=gx(),r=t.allowedTools.includes(e),o=r?t.allowedTools:[...t.allowedTools,e],s=t.disallowedTools.filter(l=>l!==e),a={...t,allowedTools:o,disallowedTools:s,lastUpdated:new Date().toISOString()};return gt.setItem(Bl,JSON.stringify(a)),{success:!0,alreadyAllowed:r,updatedSettings:a}}function yx({autoScrollToBottom:e,hasMessages:t,isLoadingSession:r}){return!!(e&&t&&!r)}const bx=100;function ba(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function wx(e,t){if(!e||!t)return!1;const r=ba(e),o=ba(t);return r&&o&&r===o?e.kind===t.kind&&e.provider===t.provider&&e.sessionId===t.sessionId:e.eventId&&t.eventId&&e.eventId===t.eventId?!0:e.kind===t.kind&&e.provider===t.provider&&e.sessionId===t.sessionId&&e.timestamp===t.timestamp&&JSON.stringify(e.payload||{})===JSON.stringify(t.payload||{})}function kx({selectedProject:e,selectedProjectRef:t,selectedSession:r,currentSessionId:o,setCurrentSessionId:s,provider:a,runtimePhase:l,isLoading:c,isLoadingRef:d,processingSessions:u,autoScrollToBottom:p,externalMessageUpdate:m,ws:f,sendMessage:x,chatMessages:h,setChatMessages:N,setIsLoading:w,setCanAbortSession:S,setRuntimePhase:$,setClaudeStatus:F,setPendingPermissionRequests:Z,resetStreamingState:z,clearLocalRunGuard:R,localRunGuardRef:E,pendingViewSessionRef:B,isSystemSessionChange:I,setIsSystemSessionChange:Y,onSessionInactive:_,onSessionNotProcessing:re,onSessionProcessing:ie}){const[V,ae]=i.useState([]),[de,ve]=i.useState(!1),[fe,U]=i.useState(!1),[le,oe]=i.useState(0),[Te,te]=i.useState(!1),[Q,we]=i.useState(0),[Ie,ye]=i.useState(null),[Oe,Be]=i.useState(!1),[$e,he]=i.useState(100),et=i.useRef(null),_e=i.useRef(null),Xe=i.useRef(!1),Fe=i.useRef(!1),Re=i.useRef(0),ut=i.useRef(!1),tt=i.useRef(null),Ue=i.useRef({height:0,top:0}),We=i.useRef(new Map),ot=i.useRef(m),Me=i.useRef(null),st=i.useRef(r),C=e?.fullPath||e?.path||null;i.useEffect(()=>()=>{We.current.forEach(b=>clearTimeout(b)),We.current.clear(),Me.current&&(clearTimeout(Me.current),Me.current=null)},[]),i.useEffect(()=>{st.current=r},[r]);const T=i.useCallback(async(b,J,ee=!1,Ae="claude",Qe=null)=>{if(!b||!J)return[];const j=!ee;j?ve(!0):U(!0);try{const ue=Qe??(ee?Re.current:0),ge=await mt.sessionEvents(Ae,J,b,C,bx,ue);if(!ge.ok)throw new Error("Failed to load session messages");const Ne=await ge.json();if(j&&Ne.tokenUsage&&ye(Ne.tokenUsage),Ne.hasMore!==void 0){te(Ne.hasMore),we(Ne.total);const Ze=ue+(Ne.events?.length||0);return Re.current=Ze,oe(Ze),Ne.events||[]}const He=Ne.events||Ne.messages||[];return te(!1),we(He.length),Re.current=He.length,oe(He.length),He}catch(ue){return console.error("Error loading session messages:",ue),[]}finally{j?ve(!1):U(!1)}},[C]),me=i.useCallback((b,J="claude")=>Al(b,J).map(ee=>({...ee,provider:ee.provider||J})),[]),xe=r?.__provider||a||"claude",y=i.useMemo(()=>me(V,xe),[xe,me,V]),D=i.useCallback((b=[])=>sh(b),[]),H=i.useCallback((b=[])=>ah(b),[]),L=i.useCallback(b=>!(b===se.COMPLETED||b===se.ABORTED||b===se.ERRORED),[]),O=i.useCallback((b,J)=>J&&($(J),(J===se.COMPLETED||J===se.ABORTED||J===se.ERRORED)&&(R(b),F(null),b&&(_?.(b),re?.(b))),J),[R,_,re,F,$]),ne=i.useCallback(async(b,J)=>{const ee=t.current;if(!ee?.name||!b)return null;const Ae=await T(ee.name,b,!1,J||xe);return Array.isArray(Ae)&&Ae.length>0&&ae(Ae),D(Ae)},[xe,D,T,t]),ke=i.useCallback(async(b,J)=>{const ee=await ne(b,J);return O(b,ee)},[ne,O]),Ge=i.useCallback((b,J=[])=>{const ee=D(J);return O(b,ee),ee},[D,O]),at=i.useCallback((b,J)=>J===se.COMPLETED||J===se.ABORTED||J===se.ERRORED?(O(b,J),J):null,[O]),pe=i.useCallback((b,J)=>{if(!b)return;const ee=We.current.get(b);ee&&clearTimeout(ee);const Ae=setTimeout(()=>{We.current.delete(b);const Qe=r?.id||o||null;!Qe||Qe!==b||(ke(b,J),x&&x({type:"check-session-status",sessionId:b,provider:J||xe}))},1200);We.current.set(b,Ae)},[xe,o,ke,r?.id,x]),ze=i.useCallback(()=>{_e.current&&(_e.current.scrollTop=_e.current.scrollHeight)},[]),Je=i.useCallback(()=>{if(!_e.current)return!1;const{scrollTop:b,scrollHeight:J,clientHeight:ee}=_e.current;return J-b-ee<50},[]),it=i.useCallback(async(b=null)=>{const J=b||_e.current;if(!J||Fe.current||fe||!Te||!r||!e)return!1;const ee=r.__provider||a||"claude";Fe.current=!0;const Ae=J.scrollHeight,Qe=J.scrollTop,j=Re.current;try{const ue=await T(e.name,r.id,!0,ee,j);return ue.length>0&&(tt.current={height:Ae,top:Qe},ae(ge=>[...ue,...ge])),!0}finally{Fe.current=!1}},[Te,fe,T,a,e,r]),Ct=i.useCallback(async()=>{if(_e.current){const b=_e.current,J=Je();Be(!J),b.scrollTop<100?ut.current||await it(b)&&(ut.current=!0):ut.current=!1}},[Je,it]);i.useLayoutEffect(()=>{if(!tt.current||!_e.current)return;const{height:b,top:J}=tt.current,ee=_e.current,Qe=ee.scrollHeight-b;ee.scrollTop=J+Math.max(Qe,0),tt.current=null},[h.length]),i.useEffect(()=>{let b=!1,J=null;return(async()=>{if(r&&e){const Ae=r.__provider||Vt(localStorage.getItem("selected-provider"));Xe.current=!0,sessionStorage.removeItem("pendingSessionId");const Qe=o!==null&&o!==r.id;let j=null;Qe?(I||(z(),R(),B.current=null,N([]),ae([]),F(null),S(!1)),Re.current=0,oe(0),te(!1),we(0),ye(null),w(!1)):o===null&&(Re.current=0,oe(0),te(!1),we(0)),s(r.id);const ue=await T(e.name,r.id,!1,r.__provider||Ae||"claude");if(b)return;ae(ue),j=Ge(r.id,ue),j||$(se.IDLE),f&&x&&L(j)&&x({type:"check-session-status",sessionId:r.id,provider:Ae}),I&&!b&&Y(!1)}else{const Qe=B.current?.sessionId||null||d.current&&(o||E.current.sessionId)||null,j=!!(Qe||d.current);I||j||(z(),R(),B.current=null,N([]),ae([]),F(null),S(!1),w(!1)),s(Qe),Re.current=0,oe(0),te(!1),we(0),ye(null)}J=setTimeout(()=>{b||(Xe.current=!1)},250)})(),()=>{b=!0,J&&clearTimeout(J)}},[r?.id,r?.__provider,e?.name,e?.fullPath,e?.path,T,I,z,R,Ge,x,$,L,f]),i.useEffect(()=>{const b=ot.current;if(m<=b||(ot.current=m,!r||!e))return;const J=r.id,ee=e.name,Ae=e.fullPath||e.path||null,Qe=async()=>{try{const j=r.__provider||Vt(localStorage.getItem("selected-provider")),ue=await T(ee,J,!1,r.__provider||j||"claude"),ge=t.current,Ne=st.current,He=ge?.fullPath||ge?.path||null;if(Ne?.id!==J||ge?.name!==ee||He!==Ae)return;ae(ue),p&&Je()&&setTimeout(()=>ze(),200)}catch(j){console.error("Error reloading messages from external update:",j)}};return Me.current&&clearTimeout(Me.current),Me.current=setTimeout(()=>{Me.current=null,Qe()},500),()=>{Me.current&&(clearTimeout(Me.current),Me.current=null)}},[p,m,Je,T,ze,e,t,r]),i.useEffect(()=>{ot.current=m},[m,e?.name,r?.id]),i.useEffect(()=>{r?.id&&(B.current=null)},[B,r?.id]),i.useEffect(()=>{const b=r?.id||o||null,J=E.current,ee=!!(J.startedAt&&(!J.sessionId||!b||J.sessionId===b)&&l!==se.IDLE);N(Ae=>oh(Ae,y,{preserveLocalTail:ee}))},[y,o,E,l,r?.id,N]),i.useEffect(()=>{e?.name&&zl(e.name,r?.id||null,h)},[h,e?.name,r?.id]),i.useEffect(()=>{const b=Ps(h);hh(h,b)||N(b)},[h,N]),i.useEffect(()=>{o&&c&&ie&&ie(o)},[o,c,ie]),i.useEffect(()=>{if(o&&u){const b=u.has(o),J=H(V);if(b&&J){re?.(o);return}b&&!c&&l!==se.COMPLETED&&l!==se.ABORTED&&l!==se.ERRORED&&$(se.STREAMING,{canAbortSession:!0})}},[o,H,c,re,u,l,V,$]);const Mt=i.useMemo(()=>r||h.length<=$e?h:h.slice(-$e),[h,r,$e]),v=i.useMemo(()=>{const b=Mt.map((ee,Ae)=>({...ee,__threadMessageId:hx(ee,Ae)}));return b.length===0||!c||b.some(ee=>ee?.type==="assistant"&&!!(ee.isStreaming||ee.isToolUse||ee.isThinking||ee.reasoning))?b:[...b,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:r?.__provider||a||"claude"}]},[c,a,r?.__provider,Mt]);i.useEffect(()=>{if(!p&&_e.current){const b=_e.current;Ue.current={height:b.scrollHeight,top:b.scrollTop}}}),i.useEffect(()=>{if(_e.current&&h.length>0)if(p)Oe||setTimeout(()=>ze(),50);else{const b=_e.current,J=Ue.current.height,ee=Ue.current.top,Qe=b.scrollHeight-J;Qe>0&&ee>0&&(b.scrollTop=ee+Qe)}},[p,h.length,Oe,ze]),i.useEffect(()=>{if(!_e.current||!yx({autoScrollToBottom:p,hasMessages:h.length>0,isLoadingSession:Xe.current}))return;Be(!1);const b=setTimeout(()=>{ze()},200);return()=>{clearTimeout(b)}},[p,h.length,ze,e?.name,r?.id]),i.useEffect(()=>{const b=_e.current;if(b)return b.addEventListener("scroll",Ct),()=>b.removeEventListener("scroll",Ct)},[Ct]),i.useEffect(()=>{if(!e||!r?.id||lr(r.id)){ye(null);return}if((r.__provider||a||"claude")!=="claude")return;(async()=>{try{const ee=`/api/projects/${e.name}/sessions/${r.id}/token-usage`,Ae=await Kt(ee);if(Ae.ok){const Qe=await Ae.json();ye(Qe)}else ye(null)}catch(ee){console.error("Failed to fetch initial token usage:",ee)}})()},[a,e,r?.__provider,r?.id]);const M=i.useCallback(()=>{he(b=>b+100)},[]),G=i.useCallback(b=>{!b||typeof b!="object"||ae(J=>{const ee=Array.isArray(J)?J:[];return ee.some(Ae=>wx(Ae,b))?ee:[...ee,b]})},[]),be=i.useCallback(()=>{B.current=null,sessionStorage.removeItem("pendingSessionId"),s(null),ae([]),N([]),Z([]),Y(!1),$(se.IDLE),F(null),S(!1),ye(null),Be(!1),e?.name&&(gt.removeItem(`chat_messages_${e.name}`),gt.removeItem(`draft_input_${e.name}`))},[B,e?.name,S,N,F,s,Y,Z,$]);return{sessionMessages:V,setSessionMessages:ae,isLoadingSessionMessages:de,isLoadingMoreMessages:fe,messagesOffset:le,hasMoreMessages:Te,totalMessages:Q,tokenBudget:Ie,setTokenBudget:ye,scrollContainerRef:_e,messagesEndRef:et,isUserScrolledUp:Oe,setIsUserScrolledUp:Be,visibleMessageCount:$e,threadMessages:v,scrollToBottom:ze,handleScroll:Ct,loadOlderMessages:it,loadEarlierMessages:M,loadSessionMessages:T,appendSessionConversationEvent:G,inferRuntimePhaseFromSessionEvents:D,inferTerminalPhaseFromSessionEvents:H,recoverAndSettleSessionRuntime:ke,recoverTerminalSessionPhase:at,scheduleSessionStatusRecovery:pe,resetSessionHistoryForNewChat:be}}function jx(e=0,t=null){const r=Number(t?.__messageSeq||0);return!Number.isFinite(r)||r<=0?!0:r>Number(e||0)}function wa(e,t={}){const r=Array.isArray(t?.availableModes)?t.availableModes.filter(s=>s&&typeof s=="object"&&String(s.id||"").trim()).map(s=>({id:String(s.id).trim(),name:String(s.name||s.id||"").trim()||String(s.id).trim(),description:typeof s.description=="string"?s.description:""})):[],o=typeof t?.currentModeId=="string"&&t.currentModeId.trim()?t.currentModeId.trim():null;return!o&&r.length===0?e||null:{availableModes:r.length>0?r:Array.isArray(e?.availableModes)?e.availableModes:[],currentModeId:o||e?.currentModeId||null}}function Sx(e={}){return Array.isArray(e?.availableCommands)?e.availableCommands.filter(t=>t&&typeof t=="object"&&String(t.name||"").trim()).map(t=>({name:String(t.name).trim(),description:typeof t.description=="string"?t.description:"",input:t.input&&typeof t.input=="object"?t.input:null,type:"acp",source:"acp",namespace:"acp"})):[]}function Nx(e={}){const t=Number(e?.used),r=Number(e?.size);if(!Number.isFinite(t)||t<0||!Number.isFinite(r)||r<0)return null;const o=Math.round(t),s=Math.round(r);return{used:o,total:s,percentage:s>0?Math.min(100,Math.max(0,Math.round(o/s*100))):0,remaining:Math.max(0,s-o),cost:e?.cost&&typeof e.cost=="object"?e.cost:null}}function Cx({latestMessage:e,provider:t,claudeStatus:r,selectedProject:o,selectedSession:s,currentSessionId:a,setCurrentSessionId:l,isLoading:c,runtimePhase:d,sendMessage:u,persistCurrentChatCache:p,setRuntimePhase:m,setIsSystemSessionChange:f,setPendingPermissionRequests:x,setIsLoading:h,setCanAbortSession:N,setClaudeStatus:w,setChatMessages:S,setTokenBudget:$,setAcpSessionModeState:F,setAcpAvailableCommands:Z,applyRealtimeConversationEvent:z,streamBufferRef:R,streamTimerRef:E,clearLocalRunGuard:B,syncLocalRunGuardSession:I,shouldIgnoreStaleIdleSignal:Y,pendingViewSessionRef:_,appendSessionConversationEvent:re,recoverAndSettleSessionRuntime:ie,recoverTerminalSessionPhase:V,inferRuntimePhaseFromSessionEvents:ae,inferTerminalPhaseFromSessionEvents:de,scheduleSessionStatusRecovery:ve,sessionMessages:fe,setSessionMessages:U,loadSessionMessages:le,onSessionInactive:oe,onSessionNotProcessing:Te,onSessionProcessing:te,onReplaceTemporarySession:Q,onNavigateToSession:we,t:Ie}){const ye=i.useRef(null),Oe=i.useRef(new Set),Be=i.useRef(0),$e=s?.__provider||t||"claude";i.useEffect(()=>()=>{E.current&&(clearTimeout(E.current),E.current=null),R.current=""},[R,E]),i.useEffect(()=>{ye.current=r},[r]),i.useEffect(()=>{if(!e||!jx(Be.current,e))return;Number.isFinite(Number(e.__messageSeq))&&Number(e.__messageSeq)>0&&(Be.current=Number(e.__messageSeq));const he=e.data?.message||e.data,_e=["projects_updated","session-created"].includes(e.type),Xe=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),Fe=e.type==="conversation-event"?String(e.event?.payload?.state||"").trim().toLowerCase():"",Re=e.type==="conversation-event"&&(e.event?.kind==="error"||e.event?.kind==="session_state_changed"&&["streaming","awaiting_approval","completed","aborted","errored"].includes(Fe)),tt=e.type==="claude-response"&&he&&he.type==="system"&&he.subtype==="init"?he?.session_id:null,Ue=sessionStorage.getItem("pendingSessionId");let We=s?.id||a||_.current?.sessionId||null;const ot=tt&&(!We||tt===We),Me=_e||ot,st=!e.sessionId&&_.current&&!_.current.sessionId&&(/error/i.test(e.type||"")||e.type==="conversation-event"&&e.event?.kind==="error"),C=y=>{y&&(oe?.(y),Te?.(y))},T=y=>{y&&te?.(y)};if(!Me){if(!We&&e.sessionId&&!Kr(e.sessionId)&&_.current&&!_.current.sessionId&&(We=e.sessionId,_.current.sessionId=e.sessionId,l(e.sessionId)),!We&&(e.sessionId&&(Xe.has(e.type)||Re)&&(Fe==="streaming"||Fe==="awaiting_approval"?T(e.sessionId):C(e.sessionId)),!st)||!e.sessionId&&!st)return;if(!st&&e.sessionId!==We){const y=Kr(We),D=!!(e.sessionId&&Ue&&e.sessionId===Ue);if(y&&(D||!Kr(e.sessionId||"")))l(e.sessionId),_.current&&(_.current.sessionId=e.sessionId);else{e.sessionId&&(Xe.has(e.type)||Re)&&(Fe==="streaming"||Fe==="awaiting_approval"?T(e.sessionId):C(e.sessionId)),console.log("Skipping message for different session:",e.sessionId,"current:",We);return}}}const me=e?.event?.sessionId||e.sessionId||We||null,xe=!!(me&&Oe.current.has(me));if(e.type==="conversation-event"&&e.event){const y=e.event.sessionId||e.sessionId||We||null,D=e.event.rawRef?.type||null,H=e.event.kind==="session_state_changed"?String(e.event.payload?.state||"").trim().toLowerCase():"";if(y&&Oe.current.add(y),H==="idle"&&Y(y,D)){ve(y,e.event.provider||$e);return}if(!!(y&&(y===(s?.id||null)||y===(a||null)||y===(_.current?.sessionId||null)))&&re(e.event),z(e.event,e.event.provider||$e),e.event.kind==="mode_update"&&F(O=>wa(O,e.event.payload)),e.event.kind==="available_commands_update"&&Z(Sx(e.event.payload)),e.event.kind==="usage_update"){const O=Nx(e.event.payload);O&&$(O)}if(e.event.kind==="approval_request"&&m(se.AWAITING_APPROVAL),e.event.kind==="approval_resolved"&&m(se.STREAMING),(e.event.kind==="assistant_text_start"||e.event.kind==="assistant_text_delta"||e.event.kind==="assistant_content_block"||e.event.kind==="reasoning_start"||e.event.kind==="reasoning_delta"||e.event.kind==="tool_call_start"||e.event.kind==="tool_call_input"||e.event.kind==="tool_call_end"||e.event.kind==="tool_result"||e.event.kind==="plan_update")&&m(se.STREAMING),(e.event.kind==="error"||e.event.payload?.state==="errored")&&(B(y),m(se.ERRORED),w(null),y&&(C(y),ie(y,e.event.provider||$e))),e.event.kind==="session_state_changed"){const O=H;O==="streaming"?(m(se.STREAMING),y&&te&&te(y)):O==="awaiting_approval"?(m(se.AWAITING_APPROVAL),y&&te&&te(y)):O==="completed"?(B(y),m(se.COMPLETED),w(null),y&&(C(y),ie(y,e.event.provider||$e))):O==="aborted"?(B(y),m(se.ABORTED),w(null),y&&(C(y),ie(y,e.event.provider||$e))):O==="errored"&&(B(y),m(se.ERRORED),w(null),y&&(C(y),ie(y,e.event.provider||$e)))}return}switch(e.type){case"ws-connection-state":e.state==="connecting"&&(d===se.QUEUED||c)?m(se.CONNECTING,{canAbortSession:!1}):e.state==="connected"&&d===se.CONNECTING&&m(se.QUEUED);break;case"connection-error":m(se.ERRORED),w(null),S(y=>[...y,{type:"error",content:e.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":m(se.ERRORED),N(!1),w(null),S(y=>[...y,{type:"error",content:e.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(e.sessionId){const y=Vt(e.provider||$e||t||"claude"),D=_.current?.sessionId||a||null,H=Kr(e.sessionId);if(!(!a||y==="codex"&&e.sessionId!==a)||H)break;sessionStorage.setItem("pendingSessionId",e.sessionId);try{const O=localStorage.getItem("session-provider-map"),ne=O?JSON.parse(O):{};ne[e.sessionId]=y,localStorage.setItem("session-provider-map",JSON.stringify(ne))}catch{}p(e.sessionId),e.modes&&F(O=>wa(O,e.modes)),_.current&&(_.current.sessionId=e.sessionId),l(e.sessionId),I(e.sessionId),te?.(e.sessionId),f(!0),Q&&Q(e.sessionId,D),x(O=>O.map(ne=>ne.sessionId?ne:{...ne,sessionId:e.sessionId})),we&&we(e.sessionId,y,o?.fullPath||o?.path||null),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":e.data&&$(e.data);break;case"claude-response":{const y=xe&&!(e.data?.type==="system"&&e.data?.subtype==="init");if(!y&&he&&typeof he=="object"&&he.type){if(he.type==="content_block_delta"&&he.delta?.text){const D=_n(he.delta.text);R.current+=D,E.current||(E.current=setTimeout(()=>{const H=R.current;R.current="",E.current=null,H&&S(L=>{const O=[...L],ne=O[O.length-1];return ne&&ne.type==="assistant"&&!ne.isToolUse&&ne.isStreaming?O[O.length-1]={...ne,content:(ne.content||"")+H}:O.push({type:"assistant",content:H,timestamp:new Date,isStreaming:!0}),O})},100));return}if(he.type==="content_block_stop"){E.current&&(clearTimeout(E.current),E.current=null);const D=R.current;R.current="",D&&S(H=>{const L=[...H],O=L[L.length-1];return O&&O.type==="assistant"&&!O.isToolUse&&O.isStreaming?L[L.length-1]={...O,content:(O.content||"")+D}:L.push({type:"assistant",content:D,timestamp:new Date,isStreaming:!0}),L}),S(H=>{const L=[...H],O=L[L.length-1];return O&&O.type==="assistant"&&O.isStreaming&&(L[L.length-1]={...O,isStreaming:!1}),L});return}}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id!==a&&ot){f(!0),p(e.data.session_id),we?.(e.data.session_id,"claude",o?.fullPath||o?.path||null);return}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&!a&&ot){f(!0),p(e.data.session_id),we?.(e.data.session_id,"claude",o?.fullPath||o?.path||null);return}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id===a&&ot)return;if(y)break;if(Array.isArray(he.content)){for(const D of he.content)if(D.type==="tool_use"){const H=D.input?JSON.stringify(D.input,null,2):"";S(L=>[...L,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:D.name,toolInput:H,toolId:D.id,toolResult:null}])}else if(D.type==="text"&&D.text?.trim()){let H=_n(D.text);H=es(H),S(L=>[...L,{type:"assistant",content:H,timestamp:new Date}])}}else if(typeof he.content=="string"&&he.content.trim()){let D=_n(he.content);D=es(D),S(H=>[...H,{type:"assistant",content:D,timestamp:new Date}])}if(he.role==="user"&&Array.isArray(he.content))for(const D of he.content)D.type==="tool_result"&&S(H=>H.map(L=>L.isToolUse&&L.toolId===D.tool_use_id?{...L,toolResult:{content:D.content,isError:D.is_error,timestamp:new Date}}:L));break}case"claude-output":if(xe)break;{const y=String(e.data||"");y.trim()&&(R.current+=R.current?`
204
+ ${y}`:y,E.current||(E.current=setTimeout(()=>{const D=R.current;R.current="",E.current=null,D&&S(H=>{const L=[...H],O=L[L.length-1];return O&&O.type==="assistant"&&!O.isToolUse&&O.isStreaming?L[L.length-1]={...O,content:O.content?`${O.content}
205
+ ${D}`:D}:L.push({type:"assistant",content:D,timestamp:new Date,isStreaming:!0}),L})},100)))}break;case"claude-interactive-prompt":S(y=>[...y,{type:"assistant",content:e.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":if(xe||t!=="claude"||!e.requestId)break;x(y=>y.some(D=>D.requestId===e.requestId)?y:[...y,{requestId:e.requestId,toolName:e.toolName||"UnknownTool",input:e.input,context:e.context,toolCall:e.toolCall||null,options:Array.isArray(e.options)?e.options:Array.isArray(e.context?.options)?e.context.options:[],message:e.message||null,sessionId:e.sessionId||null,receivedAt:new Date}]),h(!0),N(!0),w(Rs({phaseText:Ie("activity.stage.waitingPermission"),detailText:e.toolName?Ie("activity.requestTool",{tool:Kd(e.toolName)}):Ie("activity.permission.title"),canAbort:!0}));break;case"claude-permission-cancelled":if(xe||!e.requestId)break;x(y=>{const D=y.filter(H=>H.requestId!==e.requestId);return D.length===0&&w(null),D});break;case"claude-error":if(xe)break;B(e.sessionId||a||null),h(!1),N(!1),w(null),S(y=>[...y,{type:"error",content:`出错了:${e.error}`,timestamp:new Date}]);break;case"claude-complete":{if(xe)break;const y=e.sessionId||a||sessionStorage.getItem("pendingSessionId");B(y),(y===a||!a)&&(h(!1),N(!1),w(null)),y&&(oe?.(y),Te?.(y));const D=sessionStorage.getItem("pendingSessionId");D&&!a&&e.exitCode===0&&(l(D),sessionStorage.removeItem("pendingSessionId")),o&&e.exitCode===0&&gt.removeItem(`chat_messages_${o.name}`),x([]);break}case"codex-response":{const y=e.data;if(!y||xe)break;if(y.type==="item_delta"&&y.delta){const D=_n(String(y.delta));if(D){const H=`codex:${y.itemType||"item"}:${y.itemId||"unknown"}`;S(L=>{const O=[...L];let ne=-1;for(let ke=O.length-1;ke>=0;ke-=1){const Ge=O[ke];if(Ge?.codexItemKey===H&&Ge.type==="assistant"&&!Ge.isToolUse){ne=ke;break}}if(ne===-1)O.push({type:"assistant",content:D,timestamp:new Date,isStreaming:!0,isThinking:!!y.isReasoning,codexItemKey:H});else{const ke=O[ne],Ge=ke.content||"";Ge.endsWith(D)||(ke.content=Ge+D),ke.isStreaming=!0}return O})}break}if(y.type==="item_done"){const D=`codex:${y.itemType||"item"}:${y.itemId||"unknown"}`,H=typeof y.content=="string"?_n(y.content):"";S(L=>{const O=[...L];let ne=-1;for(let ke=O.length-1;ke>=0;ke-=1){const Ge=O[ke];if(Ge?.codexItemKey===D&&Ge.type==="assistant"&&!Ge.isToolUse){ne=ke;break}}if(ne!==-1){const ke=O[ne];H&&H!==(ke.content||"")&&(ke.content=H),ke.isStreaming=!1}else H.trim()&&O.push({type:"assistant",content:H,timestamp:new Date,isStreaming:!1,isThinking:!!y.isReasoning});return O});break}if(y.type==="item")switch(y.itemType){case"agent_message":if(y.message?.content?.trim()){const D=_n(y.message.content);S(H=>{const L=H[H.length-1];return L&&L.type==="assistant"&&!L.isToolUse&&!L.isThinking&&(L.content||"").trim()===D.trim()?H:[...H,{type:"assistant",content:D,timestamp:new Date}]})}break;case"reasoning":if(y.message?.content?.trim()){const D=_n(y.message.content);S(H=>{const L=H[H.length-1];return L&&L.type==="assistant"&&!L.isToolUse&&L.isThinking&&(L.content||"").trim()===D.trim()?H:[...H,{type:"assistant",content:D,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":y.command&&S(D=>[...D,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:y.command,toolResult:y.output||null,exitCode:y.exitCode}]);break;case"file_change":if(y.changes?.length>0){const D=y.changes.map(H=>`${H.kind}: ${H.path}`).join(`
206
+ `);S(H=>[...H,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:D,toolResult:`Status: ${y.status}`}])}break;case"mcp_tool_call":S(D=>[...D,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${y.server}:${y.tool}`,toolInput:JSON.stringify(y.arguments,null,2),toolResult:y.result?JSON.stringify(y.result,null,2):y.error?.message||null}]);break;case"error":y.message?.content&&S(D=>[...D,{type:"error",content:y.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",y.itemType,y)}y.type==="turn_complete"&&h(!1),y.type==="turn_failed"&&(h(!1),S(D=>[...D,{type:"error",content:y.error?.message||"Turn failed",timestamp:new Date}]));break}case"codex-complete":{if(xe)break;const y=e.sessionId||a||sessionStorage.getItem("pendingSessionId");B(y),(y===a||!a)&&(h(!1),N(!1),w(null),S(L=>L.map(O=>O?.codexItemKey&&O.isStreaming?{...O,isStreaming:!1}:O))),y&&(oe?.(y),Te?.(y));const D=sessionStorage.getItem("pendingSessionId"),H=e.actualSessionId||D;D&&!a&&(l(H),f(!0),we?.(H,"codex",o?.fullPath||o?.path||null),sessionStorage.removeItem("pendingSessionId")),o&&y&&le(o.name,y,!1,"codex").then(L=>{Array.isArray(L)&&L.length>0&&U(L)}).catch(L=>{console.error("Error reloading Codex session after completion:",L)}),o&&gt.removeItem(`chat_messages_${o.name}`);break}case"codex-error":if(xe)break;B(e.sessionId||a||null),h(!1),N(!1),S(y=>y.map(D=>D?.codexItemKey&&D.isStreaming?{...D,isStreaming:!1}:D)),S(y=>[...y,{type:"error",content:e.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(xe)break;const y=e.sessionId||a;B(y),y===a&&(h(!1),N(!1),w(null)),y&&(oe?.(y),Te?.(y)),x([]),S(D=>[...D,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(xe)break;const y=e.sessionId,D=e.provider||s?.__provider||$e,H=y===a||s&&y===s.id,L=ae(fe),O=de(fe);if(H&&e.isProcessing){if(O){V(y,O);break}h(!0),N(!0),te?.(y)}else if(H&&e.isProcessing===!1){if(Y(y,"session-status")){ve(y,D);break}ie(y,D).then(ne=>{if(!(ne===se.COMPLETED||ne===se.ABORTED||ne===se.ERRORED)){if(L===se.STREAMING||L===se.AWAITING_APPROVAL){m(L);return}h(!1),N(!1),w(null)}})}break}case"claude-status":{const y=e.data;if(y){let D={text:"Working...",tokens:0,can_interrupt:!0};y.message?D.text=y.message:y.status?D.text=y.status:typeof y=="string"&&(D.text=y),y.tokens?D.tokens=y.tokens:y.token_count&&(D.tokens=y.token_count),y.can_interrupt!==void 0&&(D.can_interrupt=y.can_interrupt);const H=xh(y,Ie,ye.current);ye.current=H,w(H),h(!0),N(D.can_interrupt)}break}}},[$e,re,z,B,a,ae,de,c,e,le,we,Q,oe,Te,te,_,p,t,ie,V,d,ve,o,s,fe,Z,F,N,S,w,l,h,f,x,U,$,Y,I,Ie])}function gn(e){return Array.isArray?Array.isArray(e):Kl(e)==="[object Array]"}function Ex(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function _x(e){return e==null?"":Ex(e)}function cn(e){return typeof e=="string"}function Ul(e){return typeof e=="number"}function Ax(e){return e===!0||e===!1||Ix(e)&&Kl(e)=="[object Boolean]"}function Wl(e){return typeof e=="object"}function Ix(e){return Wl(e)&&e!==null}function Ut(e){return e!=null}function Po(e){return!e.trim().length}function Kl(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Tx="Incorrect 'index' type",Px=e=>`Invalid value for key ${e}`,Rx=e=>`Pattern length exceeds max of ${e}.`,Mx=e=>`Missing ${e} property in key`,Dx=e=>`Property 'weight' in key '${e}' must be a positive integer`,ka=Object.prototype.hasOwnProperty;class Lx{constructor(t){this._keys=[],this._keyMap={};let r=0;t.forEach(o=>{let s=Hl(o);this._keys.push(s),this._keyMap[s.id]=s,r+=s.weight}),this._keys.forEach(o=>{o.weight/=r})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Hl(e){let t=null,r=null,o=null,s=1,a=null;if(cn(e)||gn(e))o=e,t=ja(e),r=rs(e);else{if(!ka.call(e,"name"))throw new Error(Mx("name"));const l=e.name;if(o=l,ka.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(Dx(l));t=ja(l),r=rs(l),a=e.getFn}return{path:t,id:r,weight:s,src:o,getFn:a}}function ja(e){return gn(e)?e:e.split(".")}function rs(e){return gn(e)?e.join("."):e}function Ox(e,t){let r=[],o=!1;const s=(a,l,c)=>{if(Ut(a))if(!l[c])r.push(a);else{let d=l[c];const u=a[d];if(!Ut(u))return;if(c===l.length-1&&(cn(u)||Ul(u)||Ax(u)))r.push(_x(u));else if(gn(u)){o=!0;for(let p=0,m=u.length;p<m;p+=1)s(u[p],l,c+1)}else l.length&&s(u,l,c+1)}};return s(e,cn(t)?t.split("."):t,0),o?r:r[0]}const Fx={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},$x={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},zx={location:0,threshold:.6,distance:100},Bx={useExtendedSearch:!1,getFn:Ox,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Pe={...$x,...Fx,...zx,...Bx};const Ux=/[^ ]+/g;function Wx(e=1,t=3){const r=new Map,o=Math.pow(10,t);return{get(s){const a=s.match(Ux).length;if(r.has(a))return r.get(a);const l=1/Math.pow(a,.5*e),c=parseFloat(Math.round(l*o)/o);return r.set(a,c),c},clear(){r.clear()}}}class Ds{constructor({getFn:t=Pe.getFn,fieldNormWeight:r=Pe.fieldNormWeight}={}){this.norm=Wx(r,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((r,o)=>{this._keysMap[r.id]=o})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,cn(this.docs[0])?this.docs.forEach((t,r)=>{this._addString(t,r)}):this.docs.forEach((t,r)=>{this._addObject(t,r)}),this.norm.clear())}add(t){const r=this.size();cn(t)?this._addString(t,r):this._addObject(t,r)}removeAt(t){this.records.splice(t,1);for(let r=t,o=this.size();r<o;r+=1)this.records[r].i-=1}getValueForItemAtKeyId(t,r){return t[this._keysMap[r]]}size(){return this.records.length}_addString(t,r){if(!Ut(t)||Po(t))return;let o={v:t,i:r,n:this.norm.get(t)};this.records.push(o)}_addObject(t,r){let o={i:r,$:{}};this.keys.forEach((s,a)=>{let l=s.getFn?s.getFn(t):this.getFn(t,s.path);if(Ut(l)){if(gn(l)){let c=[];const d=[{nestedArrIndex:-1,value:l}];for(;d.length;){const{nestedArrIndex:u,value:p}=d.pop();if(Ut(p))if(cn(p)&&!Po(p)){let m={v:p,i:u,n:this.norm.get(p)};c.push(m)}else gn(p)&&p.forEach((m,f)=>{d.push({nestedArrIndex:f,value:m})})}o.$[a]=c}else if(cn(l)&&!Po(l)){let c={v:l,n:this.norm.get(l)};o.$[a]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function ql(e,t,{getFn:r=Pe.getFn,fieldNormWeight:o=Pe.fieldNormWeight}={}){const s=new Ds({getFn:r,fieldNormWeight:o});return s.setKeys(e.map(Hl)),s.setSources(t),s.create(),s}function Kx(e,{getFn:t=Pe.getFn,fieldNormWeight:r=Pe.fieldNormWeight}={}){const{keys:o,records:s}=e,a=new Ds({getFn:t,fieldNormWeight:r});return a.setKeys(o),a.setIndexRecords(s),a}function Hr(e,{errors:t=0,currentLocation:r=0,expectedLocation:o=0,distance:s=Pe.distance,ignoreLocation:a=Pe.ignoreLocation}={}){const l=t/e.length;if(a)return l;const c=Math.abs(o-r);return s?l+c/s:c?1:l}function Hx(e=[],t=Pe.minMatchCharLength){let r=[],o=-1,s=-1,a=0;for(let l=e.length;a<l;a+=1){let c=e[a];c&&o===-1?o=a:!c&&o!==-1&&(s=a-1,s-o+1>=t&&r.push([o,s]),o=-1)}return e[a-1]&&a-o>=t&&r.push([o,a-1]),r}const Tn=32;function qx(e,t,r,{location:o=Pe.location,distance:s=Pe.distance,threshold:a=Pe.threshold,findAllMatches:l=Pe.findAllMatches,minMatchCharLength:c=Pe.minMatchCharLength,includeMatches:d=Pe.includeMatches,ignoreLocation:u=Pe.ignoreLocation}={}){if(t.length>Tn)throw new Error(Rx(Tn));const p=t.length,m=e.length,f=Math.max(0,Math.min(o,m));let x=a,h=f;const N=c>1||d,w=N?Array(m):[];let S;for(;(S=e.indexOf(t,h))>-1;){let E=Hr(t,{currentLocation:S,expectedLocation:f,distance:s,ignoreLocation:u});if(x=Math.min(E,x),h=S+p,N){let B=0;for(;B<p;)w[S+B]=1,B+=1}}h=-1;let $=[],F=1,Z=p+m;const z=1<<p-1;for(let E=0;E<p;E+=1){let B=0,I=Z;for(;B<I;)Hr(t,{errors:E,currentLocation:f+I,expectedLocation:f,distance:s,ignoreLocation:u})<=x?B=I:Z=I,I=Math.floor((Z-B)/2+B);Z=I;let Y=Math.max(1,f-I+1),_=l?m:Math.min(f+I,m)+p,re=Array(_+2);re[_+1]=(1<<E)-1;for(let V=_;V>=Y;V-=1){let ae=V-1,de=r[e.charAt(ae)];if(N&&(w[ae]=+!!de),re[V]=(re[V+1]<<1|1)&de,E&&(re[V]|=($[V+1]|$[V])<<1|1|$[V+1]),re[V]&z&&(F=Hr(t,{errors:E,currentLocation:ae,expectedLocation:f,distance:s,ignoreLocation:u}),F<=x)){if(x=F,h=ae,h<=f)break;Y=Math.max(1,2*f-h)}}if(Hr(t,{errors:E+1,currentLocation:f,expectedLocation:f,distance:s,ignoreLocation:u})>x)break;$=re}const R={isMatch:h>=0,score:Math.max(.001,F)};if(N){const E=Hx(w,c);E.length?d&&(R.indices=E):R.isMatch=!1}return R}function Gx(e){let t={};for(let r=0,o=e.length;r<o;r+=1){const s=e.charAt(r);t[s]=(t[s]||0)|1<<o-r-1}return t}const so=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 Gl{constructor(t,{location:r=Pe.location,threshold:o=Pe.threshold,distance:s=Pe.distance,includeMatches:a=Pe.includeMatches,findAllMatches:l=Pe.findAllMatches,minMatchCharLength:c=Pe.minMatchCharLength,isCaseSensitive:d=Pe.isCaseSensitive,ignoreDiacritics:u=Pe.ignoreDiacritics,ignoreLocation:p=Pe.ignoreLocation}={}){if(this.options={location:r,threshold:o,distance:s,includeMatches:a,findAllMatches:l,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:p},t=d?t:t.toLowerCase(),t=u?so(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const m=(x,h)=>{this.chunks.push({pattern:x,alphabet:Gx(x),startIndex:h})},f=this.pattern.length;if(f>Tn){let x=0;const h=f%Tn,N=f-h;for(;x<N;)m(this.pattern.substr(x,Tn),x),x+=Tn;if(h){const w=f-Tn;m(this.pattern.substr(w),w)}}else m(this.pattern,0)}searchIn(t){const{isCaseSensitive:r,ignoreDiacritics:o,includeMatches:s}=this.options;if(t=r?t:t.toLowerCase(),t=o?so(t):t,this.pattern===t){let N={isMatch:!0,score:0};return s&&(N.indices=[[0,t.length-1]]),N}const{location:a,distance:l,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:p}=this.options;let m=[],f=0,x=!1;this.chunks.forEach(({pattern:N,alphabet:w,startIndex:S})=>{const{isMatch:$,score:F,indices:Z}=qx(t,N,w,{location:a+S,distance:l,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:s,ignoreLocation:p});$&&(x=!0),f+=F,$&&Z&&(m=[...m,...Z])});let h={isMatch:x,score:x?f/this.chunks.length:1};return x&&s&&(h.indices=m),h}}class Nn{constructor(t){this.pattern=t}static isMultiMatch(t){return Sa(t,this.multiRegex)}static isSingleMatch(t){return Sa(t,this.singleRegex)}search(){}}function Sa(e,t){const r=e.match(t);return r?r[1]:null}class Vx extends Nn{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const r=t===this.pattern;return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Jx extends Nn{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const o=t.indexOf(this.pattern)===-1;return{isMatch:o,score:o?0:1,indices:[0,t.length-1]}}}class Yx extends Nn{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const r=t.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,this.pattern.length-1]}}}class Xx extends Nn{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const r=!t.startsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class Qx extends Nn{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const r=t.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Zx extends Nn{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const r=!t.endsWith(this.pattern);return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class Vl extends Nn{constructor(t,{location:r=Pe.location,threshold:o=Pe.threshold,distance:s=Pe.distance,includeMatches:a=Pe.includeMatches,findAllMatches:l=Pe.findAllMatches,minMatchCharLength:c=Pe.minMatchCharLength,isCaseSensitive:d=Pe.isCaseSensitive,ignoreDiacritics:u=Pe.ignoreDiacritics,ignoreLocation:p=Pe.ignoreLocation}={}){super(t),this._bitapSearch=new Gl(t,{location:r,threshold:o,distance:s,includeMatches:a,findAllMatches:l,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:p})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Jl extends Nn{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let r=0,o;const s=[],a=this.pattern.length;for(;(o=t.indexOf(this.pattern,r))>-1;)r=o+a,s.push([o,r-1]);const l=!!s.length;return{isMatch:l,score:l?0:1,indices:s}}}const os=[Vx,Jl,Yx,Xx,Zx,Qx,Jx,Vl],Na=os.length,eg=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,tg="|";function ng(e,t={}){return e.split(tg).map(r=>{let o=r.trim().split(eg).filter(a=>a&&!!a.trim()),s=[];for(let a=0,l=o.length;a<l;a+=1){const c=o[a];let d=!1,u=-1;for(;!d&&++u<Na;){const p=os[u];let m=p.isMultiMatch(c);m&&(s.push(new p(m,t)),d=!0)}if(!d)for(u=-1;++u<Na;){const p=os[u];let m=p.isSingleMatch(c);if(m){s.push(new p(m,t));break}}}return s})}const rg=new Set([Vl.type,Jl.type]);class og{constructor(t,{isCaseSensitive:r=Pe.isCaseSensitive,ignoreDiacritics:o=Pe.ignoreDiacritics,includeMatches:s=Pe.includeMatches,minMatchCharLength:a=Pe.minMatchCharLength,ignoreLocation:l=Pe.ignoreLocation,findAllMatches:c=Pe.findAllMatches,location:d=Pe.location,threshold:u=Pe.threshold,distance:p=Pe.distance}={}){this.query=null,this.options={isCaseSensitive:r,ignoreDiacritics:o,includeMatches:s,minMatchCharLength:a,findAllMatches:c,ignoreLocation:l,location:d,threshold:u,distance:p},t=r?t:t.toLowerCase(),t=o?so(t):t,this.pattern=t,this.query=ng(this.pattern,this.options)}static condition(t,r){return r.useExtendedSearch}searchIn(t){const r=this.query;if(!r)return{isMatch:!1,score:1};const{includeMatches:o,isCaseSensitive:s,ignoreDiacritics:a}=this.options;t=s?t:t.toLowerCase(),t=a?so(t):t;let l=0,c=[],d=0;for(let u=0,p=r.length;u<p;u+=1){const m=r[u];c.length=0,l=0;for(let f=0,x=m.length;f<x;f+=1){const h=m[f],{isMatch:N,indices:w,score:S}=h.search(t);if(N){if(l+=1,d+=S,o){const $=h.constructor.type;rg.has($)?c=[...c,...w]:c.push(w)}}else{d=0,l=0,c.length=0;break}}if(l){let f={isMatch:!0,score:d/l};return o&&(f.indices=c),f}}return{isMatch:!1,score:1}}}const ss=[];function sg(...e){ss.push(...e)}function as(e,t){for(let r=0,o=ss.length;r<o;r+=1){let s=ss[r];if(s.condition(e,t))return new s(e,t)}return new Gl(e,t)}const ao={AND:"$and",OR:"$or"},is={PATH:"$path",PATTERN:"$val"},ls=e=>!!(e[ao.AND]||e[ao.OR]),ag=e=>!!e[is.PATH],ig=e=>!gn(e)&&Wl(e)&&!ls(e),Ca=e=>({[ao.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Yl(e,t,{auto:r=!0}={}){const o=s=>{let a=Object.keys(s);const l=ag(s);if(!l&&a.length>1&&!ls(s))return o(Ca(s));if(ig(s)){const d=l?s[is.PATH]:a[0],u=l?s[is.PATTERN]:s[d];if(!cn(u))throw new Error(Px(d));const p={keyId:rs(d),pattern:u};return r&&(p.searcher=as(u,t)),p}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=s[d];gn(u)&&u.forEach(p=>{c.children.push(o(p))})}),c};return ls(e)||(e=Ca(e)),o(e)}function lg(e,{ignoreFieldNorm:t=Pe.ignoreFieldNorm}){e.forEach(r=>{let o=1;r.matches.forEach(({key:s,norm:a,score:l})=>{const c=s?s.weight:null;o*=Math.pow(l===0&&c?Number.EPSILON:l,(c||1)*(t?1:a))}),r.score=o})}function cg(e,t){const r=e.matches;t.matches=[],Ut(r)&&r.forEach(o=>{if(!Ut(o.indices)||!o.indices.length)return;const{indices:s,value:a}=o;let l={indices:s,value:a};o.key&&(l.key=o.key.src),o.idx>-1&&(l.refIndex=o.idx),t.matches.push(l)})}function dg(e,t){t.score=e.score}function ug(e,t,{includeMatches:r=Pe.includeMatches,includeScore:o=Pe.includeScore}={}){const s=[];return r&&s.push(cg),o&&s.push(dg),e.map(a=>{const{idx:l}=a,c={item:t[l],refIndex:l};return s.length&&s.forEach(d=>{d(a,c)}),c})}class Qn{constructor(t,r={},o){this.options={...Pe,...r},this.options.useExtendedSearch,this._keyStore=new Lx(this.options.keys),this.setCollection(t,o)}setCollection(t,r){if(this._docs=t,r&&!(r instanceof Ds))throw new Error(Tx);this._myIndex=r||ql(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Ut(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const r=[];for(let o=0,s=this._docs.length;o<s;o+=1){const a=this._docs[o];t(a,o)&&(this.removeAt(o),o-=1,s-=1,r.push(a))}return r}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:r=-1}={}){const{includeMatches:o,includeScore:s,shouldSort:a,sortFn:l,ignoreFieldNorm:c}=this.options;let d=cn(t)?cn(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return lg(d,{ignoreFieldNorm:c}),a&&d.sort(l),Ul(r)&&r>-1&&(d=d.slice(0,r)),ug(d,this._docs,{includeMatches:o,includeScore:s})}_searchStringList(t){const r=as(t,this.options),{records:o}=this._myIndex,s=[];return o.forEach(({v:a,i:l,n:c})=>{if(!Ut(a))return;const{isMatch:d,score:u,indices:p}=r.searchIn(a);d&&s.push({item:a,idx:l,matches:[{score:u,value:a,norm:c,indices:p}]})}),s}_searchLogical(t){const r=Yl(t,this.options),o=(c,d,u)=>{if(!c.children){const{keyId:m,searcher:f}=c,x=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(d,m),searcher:f});return x&&x.length?[{idx:u,item:d,matches:x}]:[]}const p=[];for(let m=0,f=c.children.length;m<f;m+=1){const x=c.children[m],h=o(x,d,u);if(h.length)p.push(...h);else if(c.operator===ao.AND)return[]}return p},s=this._myIndex.records,a={},l=[];return s.forEach(({$:c,i:d})=>{if(Ut(c)){let u=o(r,c,d);u.length&&(a[d]||(a[d]={idx:d,item:c,matches:[]},l.push(a[d])),u.forEach(({matches:p})=>{a[d].matches.push(...p)}))}}),l}_searchObjectList(t){const r=as(t,this.options),{keys:o,records:s}=this._myIndex,a=[];return s.forEach(({$:l,i:c})=>{if(!Ut(l))return;let d=[];o.forEach((u,p)=>{d.push(...this._findMatches({key:u,value:l[p],searcher:r}))}),d.length&&a.push({idx:c,item:l,matches:d})}),a}_findMatches({key:t,value:r,searcher:o}){if(!Ut(r))return[];let s=[];if(gn(r))r.forEach(({v:a,i:l,n:c})=>{if(!Ut(a))return;const{isMatch:d,score:u,indices:p}=o.searchIn(a);d&&s.push({score:u,key:t,value:a,idx:l,norm:c,indices:p})});else{const{v:a,n:l}=r,{isMatch:c,score:d,indices:u}=o.searchIn(a);c&&s.push({score:d,key:t,value:a,norm:l,indices:u})}return s}}Qn.version="7.1.0";Qn.createIndex=ql;Qn.parseIndex=Kx;Qn.config=Pe;Qn.parseQuery=Yl;sg(og);var Ro={exports:{}},Mo,Ea;function pg(){if(Ea)return Mo;Ea=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Mo=e,Mo}var Do,_a;function mg(){if(_a)return Do;_a=1;var e=pg();function t(){}function r(){}return r.resetWarningCache=t,Do=function(){function o(l,c,d,u,p,m){if(m!==e){var f=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 f.name="Invariant Violation",f}}o.isRequired=o;function s(){return o}var a={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:s,element:o,elementType:o,instanceOf:s,node:o,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:r,resetWarningCache:t};return a.PropTypes=a,a},Do}var Aa;function fg(){return Aa||(Aa=1,Ro.exports=mg()()),Ro.exports}var hg=fg();const pt=ui(hg),xg=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 Yn(e,t,r){const o=gg(e),{webkitRelativePath:s}=e,a=typeof t=="string"?t:typeof s=="string"&&s.length>0?s:`./${e.name}`;return typeof o.path!="string"&&Ia(o,"path",a),Ia(o,"relativePath",a),o}function gg(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const o=t.split(".").pop().toLowerCase(),s=xg.get(o);s&&Object.defineProperty(e,"type",{value:s,writable:!1,configurable:!1,enumerable:!0})}return e}function Ia(e,t,r){Object.defineProperty(e,t,{value:r,writable:!1,configurable:!1,enumerable:!0})}const vg=[".DS_Store","Thumbs.db"];function yg(e){return Fn(this,void 0,void 0,function*(){return io(e)&&bg(e.dataTransfer)?Sg(e.dataTransfer,e.type):wg(e)?kg(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?jg(e):[]})}function bg(e){return io(e)}function wg(e){return io(e)&&io(e.target)}function io(e){return typeof e=="object"&&e!==null}function kg(e){return cs(e.target.files).map(t=>Yn(t))}function jg(e){return Fn(this,void 0,void 0,function*(){return(yield Promise.all(e.map(r=>r.getFile()))).map(r=>Yn(r))})}function Sg(e,t){return Fn(this,void 0,void 0,function*(){if(e.items){const r=cs(e.items).filter(s=>s.kind==="file");if(t!=="drop")return r;const o=yield Promise.all(r.map(Ng));return Ta(Xl(o))}return Ta(cs(e.files).map(r=>Yn(r)))})}function Ta(e){return e.filter(t=>vg.indexOf(t.name)===-1)}function cs(e){if(e===null)return[];const t=[];for(let r=0;r<e.length;r++){const o=e[r];t.push(o)}return t}function Ng(e){if(typeof e.webkitGetAsEntry!="function")return Pa(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?Ql(t):Pa(e,t)}function Xl(e){return e.reduce((t,r)=>[...t,...Array.isArray(r)?Xl(r):[r]],[])}function Pa(e,t){return Fn(this,void 0,void 0,function*(){var r;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,Yn(l)}}const o=e.getAsFile();if(!o)throw new Error(`${e} is not a File`);return Yn(o,(r=t?.fullPath)!==null&&r!==void 0?r:void 0)})}function Cg(e){return Fn(this,void 0,void 0,function*(){return e.isDirectory?Ql(e):Eg(e)})}function Ql(e){const t=e.createReader();return new Promise((r,o)=>{const s=[];function a(){t.readEntries(l=>Fn(this,void 0,void 0,function*(){if(l.length){const c=Promise.all(l.map(Cg));s.push(c),a()}else try{const c=yield Promise.all(s);r(c)}catch(c){o(c)}}),l=>{o(l)})}a()})}function Eg(e){return Fn(this,void 0,void 0,function*(){return new Promise((t,r)=>{e.file(o=>{const s=Yn(o,e.fullPath);t(s)},o=>{r(o)})})})}var qr={},Ra;function _g(){return Ra||(Ra=1,qr.__esModule=!0,qr.default=function(e,t){if(e&&t){var r=Array.isArray(t)?t:t.split(",");if(r.length===0)return!0;var o=e.name||"",s=(e.type||"").toLowerCase(),a=s.replace(/\/.*$/,"");return r.some(function(l){var c=l.trim().toLowerCase();return c.charAt(0)==="."?o.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):s===c})}return!0}),qr}var Ag=_g();const Lo=ui(Ag);function Ma(e){return Pg(e)||Tg(e)||ec(e)||Ig()}function Ig(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
207
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tg(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Pg(e){if(Array.isArray(e))return ds(e)}function Da(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,o)}return r}function La(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Da(Object(r),!0).forEach(function(o){Zl(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Da(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Zl(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fr(e,t){return Dg(e)||Mg(e,t)||ec(e,t)||Rg()}function Rg(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
208
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ec(e,t){if(e){if(typeof e=="string")return ds(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ds(e,t)}}function ds(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function Mg(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o=[],s=!0,a=!1,l,c;try{for(r=r.call(e);!(s=(l=r.next()).done)&&(o.push(l.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,c=d}finally{try{!s&&r.return!=null&&r.return()}finally{if(a)throw c}}return o}}function Dg(e){if(Array.isArray(e))return e}var Lg=typeof Lo=="function"?Lo:Lo.default,Og="file-invalid-type",Fg="file-too-large",$g="file-too-small",zg="too-many-files",Bg=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=t.split(","),o=r.length>1?"one of ".concat(r.join(", ")):r[0];return{code:Og,message:"File type must be ".concat(o)}},Oa=function(t){return{code:Fg,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},Fa=function(t){return{code:$g,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Ug={code:zg,message:"Too many files"};function tc(e,t){var r=e.type==="application/x-moz-file"||Lg(e,t);return[r,r?null:Bg(t)]}function nc(e,t,r){if(Pn(e.size))if(Pn(t)&&Pn(r)){if(e.size>r)return[!1,Oa(r)];if(e.size<t)return[!1,Fa(t)]}else{if(Pn(t)&&e.size<t)return[!1,Fa(t)];if(Pn(r)&&e.size>r)return[!1,Oa(r)]}return[!0,null]}function Pn(e){return e!=null}function Wg(e){var t=e.files,r=e.accept,o=e.minSize,s=e.maxSize,a=e.multiple,l=e.maxFiles,c=e.validator;return!a&&t.length>1||a&&l>=1&&t.length>l?!1:t.every(function(d){var u=tc(d,r),p=fr(u,1),m=p[0],f=nc(d,o,s),x=fr(f,1),h=x[0],N=c?c(d):null;return m&&h&&!N})}function lo(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Gr(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function $a(e){e.preventDefault()}function Kg(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Hg(e){return e.indexOf("Edge/")!==-1}function qg(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Kg(e)||Hg(e)}function sn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(o){for(var s=arguments.length,a=new Array(s>1?s-1:0),l=1;l<s;l++)a[l-1]=arguments[l];return t.some(function(c){return!lo(o)&&c&&c.apply(void 0,[o].concat(a)),lo(o)})}}function Gg(){return"showOpenFilePicker"in window}function Vg(e){if(Pn(e)){var t=Object.entries(e).filter(function(r){var o=fr(r,2),s=o[0],a=o[1],l=!0;return rc(s)||(console.warn('Skipped "'.concat(s,'" 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(oc))&&(console.warn('Skipped "'.concat(s,'" because an invalid file extension was provided.')),l=!1),l}).reduce(function(r,o){var s=fr(o,2),a=s[0],l=s[1];return La(La({},r),{},Zl({},a,l))},{});return[{description:"Files",accept:t}]}return e}function Jg(e){if(Pn(e))return Object.entries(e).reduce(function(t,r){var o=fr(r,2),s=o[0],a=o[1];return[].concat(Ma(t),[s],Ma(a))},[]).filter(function(t){return rc(t)||oc(t)}).join(",")}function Yg(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function Xg(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function rc(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function oc(e){return/^.*\.[\w]+$/.test(e)}var Qg=["children"],Zg=["open"],e0=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],t0=["refKey","onChange","onClick"];function n0(e){return s0(e)||o0(e)||sc(e)||r0()}function r0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
209
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function o0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function s0(e){if(Array.isArray(e))return us(e)}function Oo(e,t){return l0(e)||i0(e,t)||sc(e,t)||a0()}function a0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
210
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sc(e,t){if(e){if(typeof e=="string")return us(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return us(e,t)}}function us(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function i0(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o=[],s=!0,a=!1,l,c;try{for(r=r.call(e);!(s=(l=r.next()).done)&&(o.push(l.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,c=d}finally{try{!s&&r.return!=null&&r.return()}finally{if(a)throw c}}return o}}function l0(e){if(Array.isArray(e))return e}function za(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,o)}return r}function vt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?za(Object(r),!0).forEach(function(o){ps(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):za(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function ps(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function co(e,t){if(e==null)return{};var r=c0(e,t),o,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)o=a[s],!(t.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}function c0(e,t){if(e==null)return{};var r={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(r[s]=e[s]);return r}var Ls=i.forwardRef(function(e,t){var r=e.children,o=co(e,Qg),s=ic(o),a=s.open,l=co(s,Zg);return i.useImperativeHandle(t,function(){return{open:a}},[a]),wt.createElement(i.Fragment,null,r(vt(vt({},l),{},{open:a})))});Ls.displayName="Dropzone";var ac={disabled:!1,getFilesFromEvent:yg,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};Ls.defaultProps=ac;Ls.propTypes={children:pt.func,accept:pt.objectOf(pt.arrayOf(pt.string)),multiple:pt.bool,preventDropOnDocument:pt.bool,noClick:pt.bool,noKeyboard:pt.bool,noDrag:pt.bool,noDragEventsBubbling:pt.bool,minSize:pt.number,maxSize:pt.number,maxFiles:pt.number,disabled:pt.bool,getFilesFromEvent:pt.func,onFileDialogCancel:pt.func,onFileDialogOpen:pt.func,useFsAccessApi:pt.bool,autoFocus:pt.bool,onDragEnter:pt.func,onDragLeave:pt.func,onDragOver:pt.func,onDrop:pt.func,onDropAccepted:pt.func,onDropRejected:pt.func,onError:pt.func,validator:pt.func};var ms={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function ic(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=vt(vt({},ac),e),r=t.accept,o=t.disabled,s=t.getFilesFromEvent,a=t.maxSize,l=t.minSize,c=t.multiple,d=t.maxFiles,u=t.onDragEnter,p=t.onDragLeave,m=t.onDragOver,f=t.onDrop,x=t.onDropAccepted,h=t.onDropRejected,N=t.onFileDialogCancel,w=t.onFileDialogOpen,S=t.useFsAccessApi,$=t.autoFocus,F=t.preventDropOnDocument,Z=t.noClick,z=t.noKeyboard,R=t.noDrag,E=t.noDragEventsBubbling,B=t.onError,I=t.validator,Y=i.useMemo(function(){return Jg(r)},[r]),_=i.useMemo(function(){return Vg(r)},[r]),re=i.useMemo(function(){return typeof w=="function"?w:Ba},[w]),ie=i.useMemo(function(){return typeof N=="function"?N:Ba},[N]),V=i.useRef(null),ae=i.useRef(null),de=i.useReducer(d0,ms),ve=Oo(de,2),fe=ve[0],U=ve[1],le=fe.isFocused,oe=fe.isFileDialogActive,Te=i.useRef(typeof window<"u"&&window.isSecureContext&&S&&Gg()),te=function(){!Te.current&&oe&&setTimeout(function(){if(ae.current){var T=ae.current.files;T.length||(U({type:"closeDialog"}),ie())}},300)};i.useEffect(function(){return window.addEventListener("focus",te,!1),function(){window.removeEventListener("focus",te,!1)}},[ae,oe,ie,Te]);var Q=i.useRef([]),we=function(T){V.current&&V.current.contains(T.target)||(T.preventDefault(),Q.current=[])};i.useEffect(function(){return F&&(document.addEventListener("dragover",$a,!1),document.addEventListener("drop",we,!1)),function(){F&&(document.removeEventListener("dragover",$a),document.removeEventListener("drop",we))}},[V,F]),i.useEffect(function(){return!o&&$&&V.current&&V.current.focus(),function(){}},[V,$,o]);var Ie=i.useCallback(function(C){B?B(C):console.error(C)},[B]),ye=i.useCallback(function(C){C.preventDefault(),C.persist(),We(C),Q.current=[].concat(n0(Q.current),[C.target]),Gr(C)&&Promise.resolve(s(C)).then(function(T){if(!(lo(C)&&!E)){var me=T.length,xe=me>0&&Wg({files:T,accept:Y,minSize:l,maxSize:a,multiple:c,maxFiles:d,validator:I}),y=me>0&&!xe;U({isDragAccept:xe,isDragReject:y,isDragActive:!0,type:"setDraggedFiles"}),u&&u(C)}}).catch(function(T){return Ie(T)})},[s,u,Ie,E,Y,l,a,c,d,I]),Oe=i.useCallback(function(C){C.preventDefault(),C.persist(),We(C);var T=Gr(C);if(T&&C.dataTransfer)try{C.dataTransfer.dropEffect="copy"}catch{}return T&&m&&m(C),!1},[m,E]),Be=i.useCallback(function(C){C.preventDefault(),C.persist(),We(C);var T=Q.current.filter(function(xe){return V.current&&V.current.contains(xe)}),me=T.indexOf(C.target);me!==-1&&T.splice(me,1),Q.current=T,!(T.length>0)&&(U({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Gr(C)&&p&&p(C))},[V,p,E]),$e=i.useCallback(function(C,T){var me=[],xe=[];C.forEach(function(y){var D=tc(y,Y),H=Oo(D,2),L=H[0],O=H[1],ne=nc(y,l,a),ke=Oo(ne,2),Ge=ke[0],at=ke[1],pe=I?I(y):null;if(L&&Ge&&!pe)me.push(y);else{var ze=[O,at];pe&&(ze=ze.concat(pe)),xe.push({file:y,errors:ze.filter(function(Je){return Je})})}}),(!c&&me.length>1||c&&d>=1&&me.length>d)&&(me.forEach(function(y){xe.push({file:y,errors:[Ug]})}),me.splice(0)),U({acceptedFiles:me,fileRejections:xe,isDragReject:xe.length>0,type:"setFiles"}),f&&f(me,xe,T),xe.length>0&&h&&h(xe,T),me.length>0&&x&&x(me,T)},[U,c,Y,l,a,d,f,x,h,I]),he=i.useCallback(function(C){C.preventDefault(),C.persist(),We(C),Q.current=[],Gr(C)&&Promise.resolve(s(C)).then(function(T){lo(C)&&!E||$e(T,C)}).catch(function(T){return Ie(T)}),U({type:"reset"})},[s,$e,Ie,E]),et=i.useCallback(function(){if(Te.current){U({type:"openDialog"}),re();var C={multiple:c,types:_};window.showOpenFilePicker(C).then(function(T){return s(T)}).then(function(T){$e(T,null),U({type:"closeDialog"})}).catch(function(T){Yg(T)?(ie(T),U({type:"closeDialog"})):Xg(T)?(Te.current=!1,ae.current?(ae.current.value=null,ae.current.click()):Ie(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."))):Ie(T)});return}ae.current&&(U({type:"openDialog"}),re(),ae.current.value=null,ae.current.click())},[U,re,ie,S,$e,Ie,_,c]),_e=i.useCallback(function(C){!V.current||!V.current.isEqualNode(C.target)||(C.key===" "||C.key==="Enter"||C.keyCode===32||C.keyCode===13)&&(C.preventDefault(),et())},[V,et]),Xe=i.useCallback(function(){U({type:"focus"})},[]),Fe=i.useCallback(function(){U({type:"blur"})},[]),Re=i.useCallback(function(){Z||(qg()?setTimeout(et,0):et())},[Z,et]),ut=function(T){return o?null:T},tt=function(T){return z?null:ut(T)},Ue=function(T){return R?null:ut(T)},We=function(T){E&&T.stopPropagation()},ot=i.useMemo(function(){return function(){var C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},T=C.refKey,me=T===void 0?"ref":T,xe=C.role,y=C.onKeyDown,D=C.onFocus,H=C.onBlur,L=C.onClick,O=C.onDragEnter,ne=C.onDragOver,ke=C.onDragLeave,Ge=C.onDrop,at=co(C,e0);return vt(vt(ps({onKeyDown:tt(sn(y,_e)),onFocus:tt(sn(D,Xe)),onBlur:tt(sn(H,Fe)),onClick:ut(sn(L,Re)),onDragEnter:Ue(sn(O,ye)),onDragOver:Ue(sn(ne,Oe)),onDragLeave:Ue(sn(ke,Be)),onDrop:Ue(sn(Ge,he)),role:typeof xe=="string"&&xe!==""?xe:"presentation"},me,V),!o&&!z?{tabIndex:0}:{}),at)}},[V,_e,Xe,Fe,Re,ye,Oe,Be,he,z,R,o]),Me=i.useCallback(function(C){C.stopPropagation()},[]),st=i.useMemo(function(){return function(){var C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},T=C.refKey,me=T===void 0?"ref":T,xe=C.onChange,y=C.onClick,D=co(C,t0),H=ps({accept:Y,multiple:c,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:ut(sn(xe,he)),onClick:ut(sn(y,Me)),tabIndex:-1},me,ae);return vt(vt({},H),D)}},[ae,r,c,he,o]);return vt(vt({},fe),{},{isFocused:le&&!o,getRootProps:ot,getInputProps:st,rootRef:V,inputRef:ae,open:ut(et)})}function d0(e,t){switch(t.type){case"focus":return vt(vt({},e),{},{isFocused:!0});case"blur":return vt(vt({},e),{},{isFocused:!1});case"openDialog":return vt(vt({},ms),{},{isFileDialogActive:!0});case"closeDialog":return vt(vt({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return vt(vt({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return vt(vt({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"reset":return vt({},ms);default:return e}}function Ba(){}function u0(e){const t=String(e||"").trim();if(!t)return"";const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(t.length/4)*4,"=");if(typeof Buffer<"u")return Buffer.from(r,"base64").toString("utf8");if(typeof atob=="function"){const o=atob(r),s=Uint8Array.from(o,a=>a.charCodeAt(0));return new TextDecoder().decode(s)}throw new Error("No base64 decoder available")}function p0(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=String(e.name||e.command||e.id||"").trim(),o=typeof e.prompt=="string"?e.prompt.trim():"";if(!r||!o)return null;const s=r.startsWith("/")?r:`/${r}`;return{id:String(e.id||s||`url-${t}`).trim(),name:s,description:typeof e.description=="string"?e.description:"",prompt:o,autoSend:e.autoSend===!0,type:"url",source:"url",namespace:"url"}}function m0(e){if(e==null||e==="")return[];const t=oo(e);if(!t)return[];let r=t;if(!(t.startsWith("[")||t.startsWith("{")))try{r=u0(t)}catch{return[]}let o;try{o=JSON.parse(r)}catch{return[]}return Array.isArray(o)?o.map((s,a)=>p0(s,a)).filter(Boolean):[]}const Ua={claude:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions","plan"]},codex:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions"]},gemini:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions"]},opencode:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions","plan"]}},Wa={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 Ka(e){return Ua[e]||Ua.claude}function Ha(e){return Wa[e]||Wa.claude}function f0(e){return e==="claude"||e==="codex"}function h0(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}let qa=!1;const x0=!1;function g0(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function v0(e){return new Promise((t,r)=>{if(!(e instanceof Blob)){r(new Error("无效的图片文件"));return}const o=new FileReader;o.onload=()=>t(typeof o.result=="string"?o.result:""),o.onerror=()=>r(o.error||new Error("读取图片失败")),o.readAsDataURL(e)})}async function y0(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(r,o)=>{const s=await v0(r);if(!s)throw new Error("图片编码失败");return{name:r?.name||`image-${o+1}.png`,data:s,size:Number(r?.size)||0,mimeType:r?.type||"application/octet-stream"}}))}function b0(e){const t=String(e||"").trim();if(!t)return"";const r=t.split(/[\\/]/);return r[r.length-1]||t}function w0(e=[]){return Array.from(new Set(Array.isArray(e)?e.filter(Boolean):[])).map(t=>{const r=String(t||"").trim();return r?{type:"resource_link",uri:r,name:b0(r)}:null}).filter(Boolean)}function k0(e,t=0){if(!e||typeof e!="object")return null;const r=String(e.modeId||e.id||e.value||"").trim();if(!r)return null;const o=`Mode ${t+1}`;return{id:r,name:String(e.name||e.label||r||o).trim()||o,description:typeof e.description=="string"?e.description:""}}function Fo(e=null){const t=e?.acpModes?.availableModes||e?.modes?.availableModes||e?.availableModes||[],r=Array.isArray(t)?t.map((s,a)=>k0(s,a)).filter(Boolean):[],o=String(e?.acpModes?.currentModeId||e?.acpModes?.currentMode?.modeId||e?.modes?.currentModeId||e?.modes?.currentMode?.modeId||e?.currentModeId||e?.currentMode?.modeId||"").trim();return{availableModes:r,currentModeId:o}}function or(e){return String(e||"").trim().replace(/^\//,"").toLowerCase()}function j0(e,t=0){if(!e||typeof e!="object")return null;const r=String(e.name||e.command||e.id||"").trim();if(!r)return null;const o=r.startsWith("/")?r:`/${r}`;return{...e,id:String(e.id||o||`acp-${t}`).trim(),name:o,description:typeof e.description=="string"?e.description:"",type:"acp",source:"acp"}}function S0(e=null){const t=e?.acpAvailableCommands||e?.availableCommands||e?.acpCommands||[];return Array.isArray(t)?t.map((r,o)=>j0(r,o)).filter(Boolean):[]}function N0(e=[],t=[],r=[]){const o=Array.isArray(r)?r:[],s=Array.isArray(t)?t:[],a=Array.isArray(e)?e:[],l=new Set(o.map(p=>or(p?.name)).filter(Boolean)),c=new Set(s.map(p=>or(p?.name)).filter(Boolean)),d=s.filter(p=>!l.has(or(p?.name))),u=a.filter(p=>!l.has(or(p?.name))&&!c.has(or(p?.name)));return[...o,...d,...u]}function Ga({command:e,handleSubmitRef:t,setCommandQuery:r,setInput:o,setSelectedCommandIndex:s,setShowCommandMenu:a,setSlashPosition:l}){return!e||e.source!=="url"?!1:(o(e.prompt),a(!1),l(-1),r(""),s(-1),e.autoSend===!0&&setTimeout(()=>{t.current?.({preventDefault:()=>{}})},0),!0)}function C0({selectedProject:e,selectedSession:t,selectedProjectRef:r,currentSessionId:o,canAbortSession:s,isLoading:a,setChatMessages:l,setCanAbortSession:c,setRuntimePhase:d,setClaudeStatus:u,pendingPermissionRequests:p,setPendingPermissionRequests:m,sendMessage:f,onSessionActive:x,onInputFocusChange:h,onShowSettings:N,onFileOpen:w,appendSessionConversationEvent:S,startLocalRunGuard:$,pendingViewSessionRef:F,scrollToBottom:Z,setIsUserScrolledUp:z,tokenBudget:R,chatMessages:E,setSessionMessages:B,resetRuntimeForNewChat:I,urlContext:Y,urlPrompt:_,urlSlashCommands:re,integrationClientId:ie,latestIntegrationMessage:V,sendIntegrationMessage:ae,sendByCtrlEnter:de}){const{t:ve}=Et("chat"),fe=x0,U=i.useMemo(()=>m0(re),[re]),[le,oe]=i.useState(()=>typeof window<"u"&&e?.name&&gt.getItem(`draft_input_${e.name}`)||""),[Te,te]=i.useState(!1),[Q,we]=i.useState([]),[Ie,ye]=i.useState(new Map),[Oe,Be]=i.useState(new Map),[$e,he]=i.useState(!1),[et,_e]=i.useState([]),[Xe,Fe]=i.useState([]),[Re,ut]=i.useState([]),[tt,Ue]=i.useState(-1),[We,ot]=i.useState(0),[Me,st]=i.useState(-1),[C,T]=i.useState(!1),[me,xe]=i.useState([]),[y,D]=i.useState([]),[H,L]=i.useState([]),[O,ne]=i.useState(""),[ke,Ge]=i.useState(!1),[at,pe]=i.useState(-1),[ze,Je]=i.useState(-1),[it,Ct]=i.useState(()=>{const g=Vt(localStorage.getItem("selected-provider"));return Ka(g).defaultMode}),Mt=i.useMemo(()=>Fo(t),[t]),[v,M]=i.useState(()=>Mt.currentModeId),[G,be]=i.useState("none"),[b,J]=i.useState(()=>Vt(localStorage.getItem("selected-provider"))),[ee,Ae]=i.useState(()=>Wr("claude")),[Qe,j]=i.useState(()=>Wr("codex")),[ue,ge]=i.useState(()=>Wr("gemini")),[Ne,He]=i.useState(()=>Wr("opencode")),[Ze,Dt]=i.useState({}),[De,Lt]=i.useState({}),[jt,K]=i.useState({}),[Ot,un]=i.useState({}),[vn,en]=i.useState({}),[tn,nn]=i.useState({}),_t=i.useMemo(()=>ga(Y),[Y]),[Bn,yn]=i.useState(_t),[Se,pn]=i.useState(_t),[Cn,En]=i.useState(!1),Ft=i.useRef(null),k=i.useRef(null),W=i.useRef(null),X=i.useRef(null),Ce=i.useRef(null),je=i.useRef(null),Ye=i.useRef(_t),rt=i.useRef(!1),kt=i.useRef(null),$t=i.useRef(b),nt=i.useMemo(()=>Ka(b),[b]),St=i.useMemo(()=>N0(me,y,U),[y,me,U]),ht=St.length>0,yt=i.useMemo(()=>Ha(b),[b]),bn=b==="claude"?ee:b==="codex"?Qe:b==="gemini"?ue:Ne,Ht=i.useMemo(()=>ax(b).OPTIONS,[b]),wn=i.useMemo(()=>(Ze[b]||[]).map(g=>({value:g,label:g})),[Ze,b]),It=t?.__provider===b&&ux(b,t?.model)?t.model.trim():"",lt=It||bn,Cr=i.useMemo(()=>{const g=wn.length>0?wn:Ht;return!It||g.some(A=>A.value===It)?g:[{value:It,label:It},...g]},[wn,Ht,It]),yc=Cr.find(g=>g.value===lt)?.label||lt||ve("providerSelection.selectModel"),bc=!!It,wc=b==="opencode"&&!!jt.opencode,vo=i.useCallback((g,{short:A=!1}={})=>{let P=ve("codex.modes.default");return g==="acceptEdits"?P=ve("codex.modes.acceptEdits"):g==="bypassPermissions"?P=ve("codex.modes.bypassPermissions"):g==="plan"&&(P=ve("codex.modes.plan")),A?P.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):P},[ve]),kc=i.useMemo(()=>vo(it,{short:!0}),[vo,it]),jc=i.useMemo(()=>ve("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[ve]),yo=i.useCallback(async(g,{force:A=!1}={})=>{if(!ox.includes(g))return null;en(P=>({...P,[g]:!0})),nn(P=>({...P,[g]:null})),un(P=>({...P,[g]:{status:rx}}));try{const q=await Kt(`/api/cli/providers/${g}/installation-status${A?"?force=true":""}`),Ee=await q.json().catch(()=>({}));if(!q.ok||Ee?.success!==!0)throw new Error(Ee?.error||`Failed to check ${g} installation`);const Ke=Ee.installed?nx:To;return un(ft=>({...ft,[g]:{status:Ke,command:Ee.command||null,resolvedPath:Ee.resolvedPath||null,reason:Ee.reason||null,installHint:Ee.installHint||null,checkedAt:Ee.checkedAt||null,cacheHit:!!Ee.cacheHit}})),Ke}catch(P){return un(q=>({...q,[g]:{status:Ur}})),nn(q=>({...q,[g]:P.message})),Ur}finally{en(P=>({...P,[g]:!1}))}},[nn,en,un]),Sc=i.useCallback(g=>{if(!g)return;const A=Vt(g);J(A),localStorage.setItem("selected-provider",A),yo(A)},[yo]);i.useEffect(()=>{const g=Cr.map(A=>A.value);!bn||g.includes(bn)||(b==="claude"?Ae(""):b==="codex"?j(""):b==="gemini"?ge(""):b==="opencode"&&He(""),lx(b))},[b,bn,Cr]),i.useEffect(()=>{if(!e)return;const g=e.fullPath||e.path;if(!g)return;const A=`runtime-models:v2:${b}:${g}`,P=xi(gt.getItem(A)),q=Array.isArray(P?.models)?P.models:[],Ee=typeof P?.currentModel=="string"?P.currentModel.trim():"",Ke=Number(P?.timestamp||0);if(q.length>0&&Date.now()-Ke<sx){Dt(ct=>({...ct,[b]:q})),Ee&&Lt(ct=>({...ct,[b]:{...ct?.[b]||{},currentModel:Ee}}));return}let zt=!1;return K(ct=>({...ct,[b]:!0})),mt.providerDiscovery(b,g).then(async ct=>{if(!ct.ok)throw new Error(`HTTP ${ct.status}`);return ct.json()}).then(ct=>{if(zt)return;const Bt=Array.isArray(ct?.models)?ct.models.map(kn=>kn.id):[],rn=typeof ct?.currentModel=="string"?ct.currentModel.trim():"";Lt(kn=>({...kn,[b]:ct})),Dt(kn=>({...kn,[b]:Bt})),Bt.length>0&&gt.setItem(A,JSON.stringify({models:Bt,currentModel:rn||"",timestamp:Date.now()}))}).catch(()=>{zt||Dt(ct=>({...ct,[b]:q}))}).finally(()=>{zt||K(ct=>({...ct,[b]:!1}))}),()=>{zt=!0}},[b,e]),i.useEffect(()=>{Ye.current=Se},[Se]);const $s=i.useRef(qa);i.useEffect(()=>{if($s.current)return;const g=oo(_);g&&(oe(g),rt.current=!0,$s.current=!0,qa=!0)},[_]),i.useEffect(()=>{yn(_t),pn(_t),En(!1)},[_t]);const Qt=i.useCallback((g,A,P={})=>{!A||typeof ae!="function"||ae({type:g,requestId:A,payload:{...P,clientId:ie||null}})},[ie,ae]),zs=i.useCallback((g,A=null)=>{if(typeof g?.context!="object"||g.context==null||Array.isArray(g.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),Qt("integration.error",A,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(Bh(g.mode)===ns){const Ee=zh(Ye.current,g.context);if(!Ee){console.warn("[DynamicContext] Ignored invalid append context payload."),Qt("integration.error",A,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}yn(Ee),pn(Ee),En(!1),Qt("integration.ack",A,{accepted:!0,applied:!0});return}const q=ga(g.context);if(!q){Qt("integration.error",A,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}yn(q),pn(q),En(!1),Qt("integration.ack",A,{accepted:!0,applied:!0})},[Qt]),Bs=i.useCallback((g,A=null)=>{if(typeof g?.prompt!="string"){Qt("integration.error",A,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const P=oo(g.prompt);if(oe(P),rt.current=!0,g.autoSend===!0&&P&&r.current&&!a&&je.current){const q={preventDefault:()=>{}};je.current(q,P)}Qt("integration.ack",A,{accepted:!0,applied:!0})},[a,r,Qt]),Us=i.useCallback((g=null)=>{Qt("integration.ack",g,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,Qt]);i.useEffect(()=>{if(!V?.__messageSeq)return;const A=V?.type;if(A==="integration.context.update"){zs(V.payload||{},V.requestId||null);return}if(A==="integration.prompt.update"){Bs(V.payload||{},V.requestId||null);return}A==="integration.ping"&&Us(V.requestId||null)},[zs,Bs,V,Us]);const Zn=i.useMemo(()=>Cn||!Se||!Dh(Se)?null:Se,[Cn,Se]),Nc=i.useMemo(()=>Zn?.selectedElements?.slice(0,fa)||[],[Zn]),Cc=i.useMemo(()=>Zn?.selectedElements?.slice(fa)||[],[Zn]),Ec=i.useCallback(()=>{pn(g=>!g||!Zt(g.systemContext)?g:{...g,systemContext:""})},[]),_c=i.useCallback(()=>{pn(g=>!g||!Zt(On(g.currentFile))?g:{...g,currentFile:{path:"",displayName:""}})},[]),Ac=i.useCallback(g=>{pn(A=>{if(!A||!Array.isArray(A.selectedElements)||A.selectedElements.length===0)return A;const P=A.selectedElements.findIndex(q=>q.tag===g.tag&&q.selector===g.selector&&q.label===g.label);return P<0?A:{...A,selectedElements:A.selectedElements.filter((q,Ee)=>Ee!==P)}})},[]);i.useEffect(()=>{if(t?.id){const g=localStorage.getItem(`permissionMode-${t.id}`);g&&nt.modes.includes(g)?Ct(g):Ct(nt.defaultMode)}},[t?.id,nt]),i.useEffect(()=>{nt.modes.includes(it)||Ct(nt.defaultMode)},[it,nt]),i.useEffect(()=>{if(!yt.enabled){G!==yt.defaultMode&&be(yt.defaultMode);return}yt.modes.includes(G)||be(yt.defaultMode)},[yt,G]),i.useEffect(()=>{if(t&&t.__provider&&t.__provider!==b){const g=Vt(t.__provider);J(g),localStorage.setItem("selected-provider",g)}if(t?.id&&t?.__provider)try{const g=localStorage.getItem("session-provider-map"),A=g?JSON.parse(g):{};A[t.id]!==t.__provider&&(A[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify(A)))}catch{}},[b,t]),i.useEffect(()=>{$t.current!==b&&(m([]),$t.current=b)},[b,m]),i.useEffect(()=>{m(g=>g.filter(A=>!A.sessionId||A.sessionId===t?.id))},[t?.id,m]),i.useEffect(()=>{const g=Fo(t),A=new Set(g.availableModes.map(P=>P.id));M(P=>g.currentModeId&&A.has(g.currentModeId)?g.currentModeId:P&&A.has(P)?P:"")},[t]),i.useEffect(()=>{D(S0(t))},[t]),i.useEffect(()=>{(async()=>{if(e)try{const A=await Kt("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!A.ok)throw new Error("Failed to fetch commands");const P=await A.json(),q=[...(P.builtIn||[]).map(ft=>({...ft,type:"built-in"})),...(P.custom||[]).map(ft=>({...ft,type:"custom"}))];xe(q);const Ee=`command_history_${e.name}`,Ke=gt.getItem(Ee);if(Ke)try{const ft=JSON.parse(Ke),zt=[...q].sort((ct,Bt)=>{const rn=ft[ct.name]||0;return(ft[Bt.name]||0)-rn});xe(zt)}catch(ft){console.error("Error parsing command history:",ft)}}catch(A){console.error("Error fetching slash commands:",A),xe([])}})()},[e]);const bo=i.useMemo(()=>St.length?new Qn(St,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[St]);i.useEffect(()=>{if(!O){L(St);return}if(!bo){L([]);return}const g=bo.search(O);L(g.map(A=>A.item))},[O,St,bo]);const Ic=i.useMemo(()=>{if(!e||St.length===0)return[];const g=`command_history_${e.name}`,A=gt.getItem(g);if(!A)return[];try{const P=JSON.parse(A);return St.map(q=>({...q,usageCount:P[q.name]||0})).filter(q=>q.usageCount>0).sort((q,Ee)=>Ee.usageCount-q.usageCount).slice(0,5)}catch(P){return console.error("Error parsing command history:",P),[]}},[St,e]),Ws=i.useCallback(g=>{const{action:A,data:P}=g;switch(A){case"clear":l([]),B([]);break;case"help":l(q=>[...q,{role:"assistant",content:P.content,timestamp:Date.now()}]);break;case"model":{const q=Object.entries(P.available||{}).filter(([,Ke])=>Array.isArray(Ke)&&Ke.length>0).map(([Ke,ft])=>`**${Ke.charAt(0).toUpperCase()+Ke.slice(1)}**: ${ft.join(", ")}`).join(`
211
+
212
+ `),Ee=P.current.provider==="opencode"?P.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";l(Ke=>[...Ke,{role:"assistant",content:`**Current Model**: ${P.current.model}
213
+
214
+ **Available Models**:
215
+
216
+ ${q}${Ee?`
217
+
218
+ ${Ee}`:""}`,timestamp:Date.now()}]);break}case"cost":{const q=`**Token Usage**: ${P.tokenUsage.used.toLocaleString()} / ${P.tokenUsage.total.toLocaleString()} (${P.tokenUsage.percentage}%)
219
+
220
+ **Estimated Cost**:
221
+ - Input: $${P.cost.input}
222
+ - Output: $${P.cost.output}
223
+ - **Total**: $${P.cost.total}
224
+
225
+ **Model**: ${P.model}`;l(Ee=>[...Ee,{role:"assistant",content:q,timestamp:Date.now()}]);break}case"status":{const q=`**System Status**
226
+
227
+ - Version: ${P.version}
228
+ - Uptime: ${P.uptime}
229
+ - Model: ${P.model}
230
+ - Provider: ${P.provider}
231
+ - Node.js: ${P.nodeVersion}
232
+ - Platform: ${P.platform}`;l(Ee=>[...Ee,{role:"assistant",content:q,timestamp:Date.now()}]);break}case"memory":P.error?l(q=>[...q,{role:"assistant",content:`⚠️ ${P.message}`,timestamp:Date.now()}]):(l(q=>[...q,{role:"assistant",content:`📝 ${P.message}
233
+
234
+ Path: \`${P.path}\``,timestamp:Date.now()}]),P.exists&&w&&w(P.path));break;case"config":N&&N();break;case"rewind":P.error?l(q=>[...q,{role:"assistant",content:`⚠️ ${P.message}`,timestamp:Date.now()}]):(l(q=>q.slice(0,-P.steps*2)),l(q=>[...q,{role:"assistant",content:`⏪ ${P.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",A)}},[w,N,l,B]),Ks=i.useCallback(async g=>{const{content:A,hasBashCommands:P}=g;if(P&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){l(Ee=>[...Ee,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}oe(A),setTimeout(()=>{if(je.current){const q={preventDefault:()=>{}};je.current(q)}},50)},[l]),Er=i.useCallback(async g=>{if(!(!g||!e))try{const A=le.match(new RegExp(`${g.name}\\s*(.*)`)),P=A&&A[1]?A[1].trim().split(/\s+/):[],q={projectPath:e.path,projectName:e.name,sessionId:o,provider:b,...lt?{model:lt}:{},tokenUsage:R},Ee=await Kt("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:g.name,commandPath:g.path,args:P,context:q})});if(!Ee.ok)throw new Error("Failed to execute command");const Ke=await Ee.json();Ke.type==="builtin"?Ws(Ke):Ke.type==="custom"&&await Ks(Ke,P),oe(""),T(!1),Je(-1),ne(""),pe(-1)}catch(A){console.error("Error executing command:",A),l(P=>[...P,{role:"assistant",content:`Error executing command: ${A.message}`,timestamp:Date.now()}])}},[lt,o,Ws,Ks,le,b,e,l,R]),Tc=i.useCallback(g=>{const A=String(g||"").trim();if(!A||A===v)return;M(A);const P=t?.id||o;if(!P)return;const q=t?.__provider||b||"claude";f({type:"set-session-mode",provider:q,sessionId:P,modeId:A})},[v,o,b,t?.__provider,t?.id,f]),er=i.useCallback(g=>{if(!g||!e?.name)return;const A=`command_history_${e.name}`,P=gt.getItem(A);let q={};try{q=P?JSON.parse(P):{}}catch(Ee){console.error("Error parsing command history:",Ee)}q[g.name]=(q[g.name]||0)+1,gt.setItem(A,JSON.stringify(q))},[e?.name]),Pc=i.useCallback((g,A,P)=>{if(!(!g||!e)){if(P){pe(A);return}if(er(g),!Ga({command:g,handleSubmitRef:je,setCommandQuery:ne,setInput:oe,setSelectedCommandIndex:pe,setShowCommandMenu:T,setSlashPosition:Je})){if(g?.source==="acp"){const q=String(g.name||"").trim(),Ee=q.startsWith("/")?`${q} `:`/${q} `;oe(Ee),T(!1),Je(-1),ne(""),pe(-1);return}Er(g)}}},[Er,er,e,ne,pe,T,Je]),wo=i.useCallback(g=>{if(!g)return;if(Ga({command:g,handleSubmitRef:je,setCommandQuery:ne,setInput:oe,setSelectedCommandIndex:pe,setShowCommandMenu:T,setSlashPosition:Je})){er(g);return}const A=g?.source==="acp",P=String(g.name||"").trim(),q=A&&P&&!P.startsWith("/")?`/${P}`:P,Ee=le.slice(0,ze),Ke=le.slice(ze),ft=Ke.indexOf(" "),zt=ft!==-1?Ke.slice(ft):"",ct=`${Ee}${q} ${zt}`;oe(ct),T(!1),Je(-1),ne(""),pe(-1),kt.current&&clearTimeout(kt.current),er(g),A||Er(g)},[Er,er,le,ze,ne,pe,T,Je]);i.useEffect(()=>{{_e([]);return}},[fe,e]),i.useEffect(()=>{{he(!1),st(-1),ut([]),Ue(-1);return}},[We,et,le,fe]);const tr=i.useMemo(()=>[],[Xe,le,fe]),nr=i.useMemo(()=>tr.length===0?[]:Array.from(new Set(tr)).sort((g,A)=>A.length-g.length),[tr]),Rc=i.useMemo(()=>nr.length===0?null:new RegExp(`(${nr.map(Ih).join("|")})`,"g"),[nr]),Mc=i.useMemo(()=>new Set(nr),[nr]),Dc=i.useCallback(g=>g||"",[Rc,Mc,fe]),_r=i.useCallback(g=>{const A=g.filter(P=>{try{if(!P||typeof P!="object"||!P.type||!P.type.startsWith("image/"))return!1;if(!P.size||P.size>5242880){const q=P.name||"Unknown file";return Be(Ee=>{const Ke=new Map(Ee);return Ke.set(q,"File too large (max 5MB)"),Ke}),!1}return!0}catch(q){return console.error("Error validating file:",q,P),!1}});A.length>0&&we(P=>[...P,...A].slice(0,5))},[]),Lc=i.useCallback(g=>{const A=Array.from(g.clipboardData.items);for(const P of A)if(P.type.startsWith("image/")){const q=P.getAsFile();q&&_r([q])}if(A.length===0&&g.clipboardData.files.length>0){const q=Array.from(g.clipboardData.files).filter(Ee=>Ee.type.startsWith("image/"));q.length>0&&_r(q)}},[_r]),{getRootProps:Oc,getInputProps:Fc,isDragActive:$c,open:zc}=ic({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:_r,noClick:!0,noKeyboard:!0}),Un=i.useCallback(async(g,A=null)=>{g.preventDefault();const P=typeof A=="string"?A:le,q=t?.__provider||b||"claude";if((Ot[q]?.status||Ur)===To||!P.trim()||a||!e)return;let Ke=P;const ft=Ha(q),zt=ft.enabled?Hd.find(Nt=>Nt.id===G):null;ft.strategy==="prompt-prefix"&&zt?.prefix&&(Ke=`${zt.prefix}: ${P}`);const ct=!Cn&&Mh(Se)?Uh(Se):null;ct&&(Ke=Wh(ct,Ke)),d("queued"),u(Rs({phaseText:ve("activity.stage.generatingReply"),detailText:ve("activity.detail.preparingReply"),canAbort:!0}));let Bt=[];if(Q.length>0){if(!f0(q)){d("idle"),c(!1),u(null),l(Nt=>[...Nt,{type:"error",content:`${q} 当前不支持图片输入`,timestamp:new Date}]);return}try{Bt=await y0(Q)}catch(Nt){console.error("Image preparation failed:",Nt),d("idle"),c(!1),u(null),l(Ir=>[...Ir,{type:"error",content:`图片处理失败:${Nt.message}`,timestamp:new Date}]);return}}const rn=w0(tr),kn=[...Bt.map(Nt=>({type:"image",data:Nt.data,mimeType:Nt.mimeType,name:Nt.name})),...rn],Kn=g0(),Vs={type:"user",content:P,provider:q,images:Bt,contentBlocks:rn,timestamp:new Date,clientRequestId:Kn};l(Nt=>[...Nt,Vs]),z(!1),setTimeout(()=>Z(),100);const At=o||t?.id;$(At||t?.id||null),At&&S(Pt({kind:"user_message",provider:q,sessionId:At,timestamp:Vs.timestamp,payload:{text:P,contentBlocks:kn},extensions:{clientRequestId:Kn,optimistic:!0}}));const rd=At||`new-session-${Date.now()}`;!At&&!t?.id&&(F.current={sessionId:null,startedAt:Date.now()}),x&&x(rd);const od=(()=>{try{const Nt=b==="codex"?"codex-settings":"claude-settings",Ir=gt.getItem(Nt);if(Ir)return JSON.parse(Ir)}catch(Nt){console.error("Error loading tools settings:",Nt)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(q==="codex"){const Nt=ft.enabled&&ft.strategy==="native-effort"?h0(G):void 0;f({type:"codex-command",clientRequestId:Kn,command:Ke,sessionId:At,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:At,resume:!!At,permissionMode:it==="plan"?"default":it,...lt?{model:lt}:{},...Nt?{modelReasoningEffort:Nt}:{},images:Bt,resourceLinks:rn}})}else f(q==="gemini"?{type:"gemini-command",clientRequestId:Kn,command:Ke,sessionId:At,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:At,resume:!!At,permissionMode:it==="plan"?"default":it,...lt?{model:lt}:{},images:Bt,resourceLinks:rn}}:q==="opencode"?{type:"opencode-command",clientRequestId:Kn,command:Ke,sessionId:At,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:At,resume:!!At,permissionMode:it==="plan"?"default":it,...lt?{model:lt}:{},images:Bt,resourceLinks:rn}}:{type:"claude-command",clientRequestId:Kn,command:Ke,options:{projectPath:e.path,cwd:e.fullPath,sessionId:At,resume:!!At,toolsSettings:od,permissionMode:it,...lt?{model:lt}:{},images:Bt,resourceLinks:rn}});ct&&En(!0),oe(""),we([]),ye(new Map),Be(new Map),Ge(!1),be("none"),Ft.current&&(Ft.current.style.height="auto"),e&&gt.removeItem(`draft_input_${e.name}`)},[tr,S,Q,lt,o,Cn,le,a,x,Se,F,it,b,Ot,Z,e,t,f,c,l,u,z,d,$,ve,G]);i.useEffect(()=>{je.current=Un},[Un]);const Bc=i.useCallback(g=>!g||b!=="claude"?{success:!1}:vx(g.entry),[b]),Uc=i.useCallback((g,A)=>{const q=(Array.isArray(g)?g:[g]).filter(Boolean);q.length!==0&&(q.forEach(Ee=>{f({type:"permission-response",requestId:Ee,optionId:A?.optionId,outcome:A?.outcome,cancelled:!!A?.cancelled,allow:!!A?.allow,updatedInput:A?.updatedInput,message:A?.message,rememberEntry:A?.rememberEntry})}),m(Ee=>{const Ke=Ee.filter(ft=>!q.includes(ft.requestId));return Ke.length===0&&u(null),Ke}))},[f,u,m]),Ar=i.useCallback(g=>{},[Me,le,fe]),Wc=i.useCallback(g=>{const A=g.target.value,P=g.target.selectionStart;if(oe(A),ot(P),!A.trim()){g.target.style.height="auto",Ge(!1),T(!1),Je(-1),ne("");return}const q=A.slice(0,P);if((q.match(/```/g)||[]).length%2===1){T(!1),Je(-1),ne("");return}const Ke=q.match(/(^|\s)\/(\S*)$/);if(Ke){const ft=Ke.index+Ke[1].length,zt=Ke[2];Je(ft),T(!0),pe(-1),kt.current&&clearTimeout(kt.current),kt.current=setTimeout(()=>{ne(zt)},150)}else T(!1),Je(-1),ne(""),kt.current&&clearTimeout(kt.current)},[]),ko=i.useCallback(g=>{!W.current||!g||(W.current.scrollTop=g.scrollTop,W.current.scrollLeft=g.scrollLeft)},[]),Kc=i.useCallback(g=>{ot(g.target.selectionStart)},[]),Hc=i.useCallback(g=>{g.target.style.height="auto",g.target.style.height=`${g.target.scrollHeight}px`,ot(g.target.selectionStart),ko(g.target);const A=parseInt(window.getComputedStyle(g.target).lineHeight,10),P=g.target.scrollHeight>A*2;Ge(P)},[ko]),qc=i.useCallback(g=>{if(C&&H.length>0){if(g.key==="ArrowDown"){g.preventDefault(),pe(A=>A<H.length-1?A+1:0);return}if(g.key==="ArrowUp"){g.preventDefault(),pe(A=>A>0?A-1:H.length-1);return}if(g.key==="Tab"||g.key==="Enter"){g.preventDefault(),at>=0?wo(H[at]):H.length>0&&wo(H[0]);return}if(g.key==="Escape"){g.preventDefault(),T(!1),Je(-1),ne(""),pe(-1),kt.current&&clearTimeout(kt.current);return}}if($e&&Re.length>0){if(g.key==="ArrowDown"){g.preventDefault(),Ue(A=>A<Re.length-1?A+1:0);return}if(g.key==="ArrowUp"){g.preventDefault(),Ue(A=>A>0?A-1:Re.length-1);return}if(g.key==="Tab"||g.key==="Enter"){g.preventDefault(),tt>=0?Ar(Re[tt]):Re.length>0&&Ar(Re[0]);return}if(g.key==="Escape"){g.preventDefault(),he(!1);return}}if(g.key==="Tab"&&!$e&&!C){g.preventDefault();const A=nt.modes,q=(A.indexOf(it)+1)%A.length,Ee=A[q];Ct(Ee),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,Ee);return}if(g.key==="Enter"){if(g.nativeEvent.isComposing)return;(g.ctrlKey||g.metaKey)&&!g.shiftKey?(g.preventDefault(),Un(g)):!g.shiftKey&&!g.ctrlKey&&!g.metaKey&&(de||(g.preventDefault(),Un(g)))}},[H,Re,Un,it,nt.modes,wo,Ar,at,tt,t?.id,de,C,$e]),Wn=t?.__provider||b||"claude",jo=Ot[Wn],Hs=jo?.status||Ur,qs=Hs===To,Gc=jo?.reason||tn[Wn]||null,Vc=jo?.installHint||null,Jc=!!vn[Wn],Yc=a||qs,Gs=Wn==="opencode"?"OpenCode":ve(`messageTypes.${Wn}`),Xc=ve("input.providerNotInstalledWithName",{provider:Gs}),Qc=i.useMemo(()=>Fo(t),[t]);i.useEffect(()=>{e&&le!==""?gt.setItem(`draft_input_${e.name}`,le):e&&le===""&&gt.removeItem(`draft_input_${e.name}`)},[le,e]),i.useEffect(()=>{if(e){if(rt.current){rt.current=!1;return}const g=gt.getItem(`draft_input_${e.name}`)||"";g!==le&&oe(g)}},[le,e?.name]),i.useEffect(()=>{h&&h(Te)},[Te,h]),i.useEffect(()=>{if(Ft.current){Ft.current.style.height="auto",Ft.current.style.height=`${Ft.current.scrollHeight}px`;const g=parseInt(window.getComputedStyle(Ft.current).lineHeight,10);Ge(Ft.current.scrollHeight>g*2)}},[]),i.useEffect(()=>{Ft.current&&!le.trim()&&(Ft.current.style.height="auto",Ge(!1))},[le]);const Zc=i.useCallback(g=>{we(A=>A.filter((P,q)=>q!==g))},[]),ed=i.useCallback(g=>{b==="claude"?Ae(g):b==="codex"?j(g):b==="gemini"?ge(g):b==="opencode"&&He(g),ix(b,g)},[b]),td=i.useCallback(()=>{const g=o||t?.id,A=t?.__provider||b;g&&s&&f({type:"abort-session",sessionId:g,provider:A})},[s,o,b,t?.__provider,t?.id,f]),nd=i.useCallback(()=>{oe(""),we([]),ye(new Map),Be(new Map),Ge(!1),be("none"),T(!1),he(!1),ne(""),Je(-1),pe(-1),Ue(-1),e?.name&&gt.removeItem(`draft_input_${e.name}`),typeof I=="function"&&I()},[I,e?.name]);return{input:le,setInput:oe,provider:b,setProvider:J,handleProviderSelection:Sc,permissionMode:it,setPermissionMode:Ct,acpModes:Qc.availableModes,acpModeId:v,handleAcpModeChange:Tc,selectedPermissionShortLabel:kc,permissionDropdownTitle:jc,providerModeConfig:nt,getPermissionModeLabel:vo,providerThinkingConfig:yt,thinkingMode:G,setThinkingMode:be,currentModel:lt,modelOptions:Cr,selectedModelLabel:yc,isModelSelectionLocked:bc,isOpencodeModelLoading:wc,setProviderModel:ed,textareaRef:Ft,inputContainerRef:k,inputHighlightRef:W,isFileMentionsEnabled:fe,hasSlashCommandsAvailable:ht,modelSelectorRef:X,permissionSelectorRef:Ce,showFileDropdown:$e,filteredFiles:Re,selectedFileIndex:tt,selectFile:Ar,showCommandMenu:C,filteredCommands:H,selectedCommandIndex:at,handleCommandSelect:Pc,commandQuery:O,frequentCommands:Ic,slashPosition:ze,setShowCommandMenu:T,setSelectedCommandIndex:pe,setSlashPosition:Je,setCommandQuery:ne,getRootProps:Oc,getInputProps:Fc,isDragActive:$c,openImagePicker:zc,attachedImages:Q,uploadingImages:Ie,imageErrors:Oe,removeAttachedImage:Zc,visibleDynamicContext:Zn,visibleSelectedElements:Nc,hiddenSelectedElements:Cc,handleDismissSystemContext:Ec,handleDismissCurrentFile:_c,handleDismissSelectedElement:Ac,renderInputWithMentions:Dc,handleInputChange:Wc,handleTextareaClick:Kc,handleKeyDown:qc,handlePaste:Lc,syncInputOverlayScroll:ko,handleTextareaInput:Hc,activeInputProvider:Wn,activeInputProviderLabel:Gs,activeProviderInstallState:Hs,isActiveProviderNotInstalled:qs,unavailablePlaceholder:Xc,isInputDisabled:Yc,activeProviderInstallReason:Gc,activeProviderInstallHint:Vc,isCheckingProviderInstallation:Jc,checkProviderInstallation:yo,providerCheckLoadingByName:vn,isInputFocused:Te,setIsInputFocused:te,isTextareaExpanded:ke,tokenBudget:R,handleSubmit:Un,canAbortSession:s,handleAbortSession:td,handleSubmitRef:je,handleGrantToolPermission:Bc,handlePermissionDecision:Uc,dynamicContext:Bn,pendingDynamicContext:Se,setPendingDynamicContext:pn,dynamicContextSent:Cn,setDynamicContextSent:En,resetComposerForNewChat:nd}}function E0({selectedProject:e,selectedSession:t,ws:r,sendMessage:o,latestMessage:s,onFileOpen:a,onInputFocusChange:l,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:p,processingSessions:m,onReplaceTemporarySession:f,onNavigateToSession:x,onShowSettings:h,autoExpandTools:N,showRawParameters:w,showThinking:S,autoScrollToBottom:$,sendByCtrlEnter:F,externalMessageUpdate:Z,urlContext:z,urlPrompt:R,urlSlashCommands:E,integrationClientId:B,latestIntegrationMessage:I,sendIntegrationMessage:Y,newSessionResetNonce:_=0}){const{t:re}=Et("chat"),ie=i.useMemo(()=>typeof window<"u"&&e?.name?xx(e.name,t?.id||null):[],[e?.name,t?.id]),[V,ae]=i.useReducer(ph,ie,uh),[de,ve]=i.useState(t?.id||null),[fe,U]=i.useState(!1),[le,oe]=i.useState(null),[Te,te]=i.useState(null),[Q,we]=i.useState([]),Ie=i.useRef(e),ye=i.useRef(V.messages),Oe=i.useRef(V.isLoading),Be=i.useRef({sessionId:null,startedAt:0}),$e=i.useRef(null),he=i.useRef(_),et=i.useRef(""),_e=i.useRef(null),Xe=V.messages,Fe=V.phase,Re=V.isLoading,ut=V.canAbortSession,tt=V.pendingPermissionRequests;i.useEffect(()=>{Ie.current=e},[e]),i.useEffect(()=>{ye.current=Xe},[Xe]),i.useEffect(()=>{Oe.current=Re},[Re]);const Ue=i.useCallback(pe=>{ae({type:"replace_messages",value:pe})},[]),We=i.useCallback(pe=>{ae({type:"replace_permissions",value:pe})},[]),ot=i.useCallback(pe=>{ae({type:"set_loading",value:pe})},[]),Me=i.useCallback(pe=>{ae({type:"set_can_abort",value:pe})},[]),st=i.useCallback((pe,ze)=>{ae({type:"set_phase",phase:pe,overrides:ze})},[]),C=i.useCallback((pe,ze)=>{ae({type:"apply_conversation_event",event:pe,provider:ze})},[]),T=i.useCallback(pe=>{Be.current={sessionId:pe||null,startedAt:Date.now()}},[]),me=i.useCallback(pe=>{!pe||!Be.current.startedAt||(Be.current={...Be.current,sessionId:pe})},[]),xe=i.useCallback((pe=null)=>{const ze=Be.current;ze.startedAt&&(pe&&ze.sessionId&&ze.sessionId!==pe||(Be.current={sessionId:null,startedAt:0}))},[]),y=i.useCallback(()=>{_e.current&&(clearTimeout(_e.current),_e.current=null),et.current=""},[]),D=i.useCallback((pe,ze=null)=>{if(ze&&ze!=="session-status")return!1;const Je=Be.current;return!!(Je.startedAt&&pe&&Je.sessionId===pe&&Date.now()-Je.startedAt<15e3&&(Fe===se.CONNECTING||Fe===se.QUEUED||Fe===se.STREAMING||Fe===se.AWAITING_APPROVAL||Fe===se.COMPLETED||Fe===se.ABORTED||Fe===se.ERRORED))},[Fe]),H=i.useCallback((pe=null)=>{const ze=Ie.current?.name||e?.name||"";ze&&zl(ze,pe,ye.current)},[e?.name]),L=kx({selectedProject:e,selectedProjectRef:Ie,selectedSession:t,currentSessionId:de,setCurrentSessionId:ve,provider:t?.__provider||null,runtimePhase:Fe,isLoading:Re,isLoadingRef:Oe,processingSessions:m,autoScrollToBottom:$,externalMessageUpdate:Z,ws:r,sendMessage:o,chatMessages:Xe,setChatMessages:Ue,setIsLoading:ot,setCanAbortSession:Me,setRuntimePhase:st,setClaudeStatus:oe,setPendingPermissionRequests:We,resetStreamingState:y,clearLocalRunGuard:xe,localRunGuardRef:Be,pendingViewSessionRef:$e,isSystemSessionChange:fe,setIsSystemSessionChange:U,onSessionInactive:d,onSessionNotProcessing:p,onSessionProcessing:u}),O=i.useMemo(()=>th(L.sessionMessages),[L.sessionMessages]);i.useEffect(()=>{te(O.modeState||null),we(Array.isArray(O.availableCommands)?O.availableCommands:[]),L.setTokenBudget(O.tokenUsage||null)},[L.setTokenBudget,O.availableCommands,O.modeState,O.tokenUsage]);const ne=i.useMemo(()=>{if(!t&&!de)return t;const pe=t?{...t}:{};return!pe.id&&de&&(pe.id=de),pe.acpModes=Te,pe.acpAvailableCommands=Q,pe},[Q,Te,de,t]),ke=C0({selectedProject:e,selectedSession:ne,selectedProjectRef:Ie,currentSessionId:de,canAbortSession:ut,isLoading:Re,setChatMessages:Ue,setCanAbortSession:Me,setRuntimePhase:st,setClaudeStatus:oe,pendingPermissionRequests:tt,setPendingPermissionRequests:We,sendMessage:o,onSessionActive:c,onInputFocusChange:l,onShowSettings:h,onFileOpen:a,appendSessionConversationEvent:L.appendSessionConversationEvent,startLocalRunGuard:T,pendingViewSessionRef:$e,scrollToBottom:L.scrollToBottom,setIsUserScrolledUp:L.setIsUserScrolledUp,tokenBudget:L.tokenBudget,chatMessages:Xe,setSessionMessages:L.setSessionMessages,resetRuntimeForNewChat:L.resetSessionHistoryForNewChat,urlContext:z,urlPrompt:R,urlSlashCommands:E,integrationClientId:B,latestIntegrationMessage:I,sendIntegrationMessage:Y,sendByCtrlEnter:F});Cx({latestMessage:s,provider:ke.provider,claudeStatus:le,selectedProject:e,selectedSession:t,currentSessionId:de,setCurrentSessionId:ve,isLoading:Re,runtimePhase:Fe,sendMessage:o,persistCurrentChatCache:H,setIsSystemSessionChange:U,setPendingPermissionRequests:We,setIsLoading:ot,setCanAbortSession:Me,setClaudeStatus:oe,setChatMessages:Ue,setTokenBudget:L.setTokenBudget,setAcpSessionModeState:te,setAcpAvailableCommands:we,applyRealtimeConversationEvent:C,streamBufferRef:et,streamTimerRef:_e,clearLocalRunGuard:xe,syncLocalRunGuardSession:me,shouldIgnoreStaleIdleSignal:D,pendingViewSessionRef:$e,appendSessionConversationEvent:L.appendSessionConversationEvent,recoverAndSettleSessionRuntime:L.recoverAndSettleSessionRuntime,recoverTerminalSessionPhase:L.recoverTerminalSessionPhase,inferRuntimePhaseFromSessionEvents:L.inferRuntimePhaseFromSessionEvents,inferTerminalPhaseFromSessionEvents:L.inferTerminalPhaseFromSessionEvents,scheduleSessionStatusRecovery:L.scheduleSessionStatusRecovery,sessionMessages:L.sessionMessages,setSessionMessages:L.setSessionMessages,loadSessionMessages:L.loadSessionMessages,onSessionInactive:d,onSessionNotProcessing:p,onSessionProcessing:u,onReplaceTemporarySession:f,onNavigateToSession:x,t:re,setRuntimePhase:st}),i.useEffect(()=>{he.current!==_&&(he.current=_,!t&&(y(),xe(),ke.resetComposerForNewChat()))},[xe,ke.resetComposerForNewChat,_,y,t]);const Ge=Uf({status:le,messages:Xe,pendingPermissionRequests:tt,t:re}),at=Re&&!!Ge;return n.jsxs(n.Fragment,{children:[n.jsx("style",{children:`
235
+ details[open] .details-chevron {
236
+ transform: rotate(180deg);
237
+ }
238
+ `}),n.jsxs("div",{className:"h-full flex flex-col",children:[n.jsx(Ah,{selectedProject:e,selectedSession:t,currentSessionId:de,provider:ke.provider,chatMessages:Xe,threadMessages:L.threadMessages,isLoading:Re,isLoadingSessionMessages:L.isLoadingSessionMessages,isLoadingMoreMessages:L.isLoadingMoreMessages,hasMoreMessages:L.hasMoreMessages,totalMessages:L.totalMessages,sessionMessages:L.sessionMessages,visibleMessageCount:L.visibleMessageCount,pendingPermissionRequests:tt,scrollContainerRef:L.scrollContainerRef,messagesEndRef:L.messagesEndRef,onScroll:L.handleScroll,onLoadEarlierSessionMessages:()=>L.loadOlderMessages(),onLoadEarlierMessages:L.loadEarlierMessages,onProviderSelection:ke.handleProviderSelection,onFileOpen:a,onShowSettings:h,onGrantToolPermission:ke.handleGrantToolPermission,onPermissionDecision:ke.handlePermissionDecision,autoExpandTools:N,showRawParameters:w}),n.jsx(Vh,{composer:ke,statusPresentation:Ge,shouldShowClaudeStatus:at,isLoading:Re,chatMessages:Xe,sendByCtrlEnter:F})]})]})}const _0=wt.memo(E0);function A0({file:e,onClose:t}){const r=`/api/projects/${e.projectName}/files/content?path=${encodeURIComponent(e.path)}`,[o,s]=i.useState(null),[a,l]=i.useState(null),[c,d]=i.useState(!0);return i.useEffect(()=>{let u;const p=new AbortController;return(async()=>{try{d(!0),l(null),s(null);const f=await Kt(r,{signal:p.signal});if(!f.ok)throw new Error(`Request failed with status ${f.status}`);const x=await f.blob();u=URL.createObjectURL(x),s(u)}catch(f){if(f.name==="AbortError")return;console.error("Error loading image:",f),l("Unable to load image")}finally{d(!1)}})(),()=>{p.abort(),u&&URL.revokeObjectURL(u)}},[r]),n.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl max-h-[90vh] w-full mx-4 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[n.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:e.name}),n.jsx(Le,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:n.jsx(Wt,{className:"h-4 w-4"})})]}),n.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[c&&n.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:n.jsx("p",{children:"Loading image…"})}),!c&&o&&n.jsx("img",{src:o,alt:e.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!c&&!o&&n.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[n.jsx("p",{children:a||"Unable to load image"}),n.jsx("p",{className:"text-sm mt-2 break-all",children:e.path})]})]}),n.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:n.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:e.path})})]})})}const I0=new Set(["png","jpg","jpeg","gif","webp","bmp","svg","ico","avif"]);function T0(e){const t=String(e||""),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1).toLowerCase()}function $o(e){return typeof e!="string"?"":e}function P0({file:e,onClose:t}){const[r,o]=i.useState(()=>$o(e?.diffInfo?.new_string)),[s,a]=i.useState(()=>!e?.diffInfo),[l,c]=i.useState(null),d=i.useMemo(()=>I0.has(T0(e?.name)),[e?.name]),u=!!(e?.diffInfo&&typeof e.diffInfo.new_string=="string");return i.useEffect(()=>{if(!e||u||d){a(!1),c(null),o($o(e?.diffInfo?.new_string));return}let p=!1;return(async()=>{try{a(!0),c(null);const f=await mt.readFile(e.projectName,e.path);if(!f.ok)throw new Error(`Request failed with status ${f.status}`);const x=await f.json();p||o($o(x.content))}catch(f){p||(console.error("Error loading file preview:",f),c("Unable to load file preview"),o(""))}finally{p||a(!1)}})(),()=>{p=!0}},[e,u,d]),i.useEffect(()=>{const p=m=>{m.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),e?d?n.jsx(A0,{file:e,onClose:t}):n.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",onClick:t,children:n.jsxs("div",{className:"mx-auto mt-8 flex max-h-[calc(100vh-4rem)] w-[min(1100px,calc(100vw-2rem))] flex-col overflow-hidden rounded-3xl border border-border/60 bg-background shadow-2xl",onClick:p=>p.stopPropagation(),children:[n.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-border/60 px-5 py-4",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[n.jsx(gi,{className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"truncate",children:e.name})]}),n.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:e.path}),u?n.jsx("div",{className:"mt-2 text-xs text-amber-600 dark:text-amber-300",children:"Showing the updated content from the chat action."}):null]}),n.jsx(Le,{variant:"ghost",size:"icon",onClick:t,"aria-label":"Close file preview",children:n.jsx(Wt,{className:"h-5 w-5"})})]}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/20",children:s?n.jsx("div",{className:"flex h-full min-h-[320px] items-center justify-center text-sm text-muted-foreground",children:"Loading file preview..."}):l?n.jsxs("div",{className:"flex h-full min-h-[320px] flex-col items-center justify-center gap-2 px-6 text-center",children:[n.jsx("div",{className:"text-sm font-medium text-foreground",children:l}),n.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:e.path})]}):n.jsx("pre",{className:"min-h-full overflow-auto p-5 font-mono text-xs leading-6 text-foreground whitespace-pre-wrap break-words",children:r})})]})}):null}var R0=eu(),M0=tu(),D0=nu(),zo={exports:{}},Va;function L0(){return Va||(Va=1,function(e,t){(function(r,o){e.exports=o()})(self,()=>(()=>{var r={6:(l,c)=>{function d(p){try{const m=new URL(p),f=m.password&&m.username?`${m.protocol}//${m.username}:${m.password}@${m.host}`:m.username?`${m.protocol}//${m.username}@${m.host}`:`${m.protocol}//${m.host}`;return p.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(p,m,f,x={}){this._terminal=p,this._regex=m,this._handler=f,this._options=x}provideLinks(p,m){const f=u.computeLink(p,this._regex,this._terminal,this._handler);m(this._addCallbacks(f))}_addCallbacks(p){return p.map(m=>(m.leave=this._options.leave,m.hover=(f,x)=>{if(this._options.hover){const{range:h}=m;this._options.hover(f,x,h)}},m))}};class u{static computeLink(m,f,x,h){const N=new RegExp(f.source,(f.flags||"")+"g"),[w,S]=u._getWindowedLineStrings(m-1,x),$=w.join("");let F;const Z=[];for(;F=N.exec($);){const z=F[0];if(!d(z))continue;const[R,E]=u._mapStrIdx(x,S,0,F.index),[B,I]=u._mapStrIdx(x,R,E,z.length);if(R===-1||E===-1||B===-1||I===-1)continue;const Y={start:{x:E+1,y:R+1},end:{x:I,y:B+1}};Z.push({range:Y,text:z,activate:h})}return Z}static _getWindowedLineStrings(m,f){let x,h=m,N=m,w=0,S="";const $=[];if(x=f.buffer.active.getLine(m)){const F=x.translateToString(!0);if(x.isWrapped&&F[0]!==" "){for(w=0;(x=f.buffer.active.getLine(--h))&&w<2048&&(S=x.translateToString(!0),w+=S.length,$.push(S),x.isWrapped&&S.indexOf(" ")===-1););$.reverse()}for($.push(F),w=0;(x=f.buffer.active.getLine(++N))&&x.isWrapped&&w<2048&&(S=x.translateToString(!0),w+=S.length,$.push(S),S.indexOf(" ")===-1););}return[$,h]}static _mapStrIdx(m,f,x,h){const N=m.buffer.active,w=N.getNullCell();let S=x;for(;h;){const $=N.getLine(f);if(!$)return[-1,-1];for(let F=S;F<$.length;++F){$.getCell(F,w);const Z=w.getChars();if(w.getWidth()&&(h-=Z.length||1,F===$.length-1&&Z==="")){const z=N.getLine(f+1);z&&z.isWrapped&&(z.getCell(0,w),w.getWidth()===2&&(h+=1))}if(h<0)return[f,F]}f++,S=0}return[f,S]}}c.LinkComputer=u}},o={};function s(l){var c=o[l];if(c!==void 0)return c.exports;var d=o[l]={exports:{}};return r[l](d,d.exports,s),d.exports}var a={};return(()=>{var l=a;Object.defineProperty(l,"__esModule",{value:!0}),l.WebLinksAddon=void 0;const c=s(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(p,m){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=m}else console.warn("Opening link blocked as opener could not be cleared")}l.WebLinksAddon=class{constructor(p=u,m={}){this._handler=p,this._options=m}activate(p){this._terminal=p;const m=this._options,f=m.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,f,this._handler,m))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(zo)),zo.exports}var O0=L0();const F0=`
239
+ .xterm .xterm-screen {
240
+ outline: none !important;
241
+ }
242
+ .xterm:focus .xterm-screen {
243
+ outline: none !important;
244
+ }
245
+ .xterm-screen:focus {
246
+ outline: none !important;
247
+ }
248
+ `;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=F0,document.head.appendChild(e)}function $0({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:o=!1,onProcessComplete:s,minimal:a=!1,autoConnect:l=!1}){const{t:c}=Et("chat"),d=i.useRef(null),u=i.useRef(null),p=i.useRef(null),m=i.useRef(null),[f,x]=i.useState(!1),[h,N]=i.useState(!1),[w,S]=i.useState(!1),[$,F]=i.useState(null),[Z,z]=i.useState(!1),R=i.useRef(e),E=i.useRef(t),B=i.useRef(r),I=i.useRef(o),Y=i.useRef(s);i.useEffect(()=>{R.current=e,E.current=t,B.current=r,I.current=o,Y.current=s});const _=i.useCallback(async()=>{if(!(Z||f))try{let fe;if(!Nf){const U=localStorage.getItem("auth-token");if(!U){console.error("No authentication token found for Shell WebSocket connection");return}fe=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(U)}`}m.current=new WebSocket(fe),m.current.onopen=()=>{x(!0),z(!1),setTimeout(()=>{p.current&&u.current&&(p.current.fit(),m.current.send(JSON.stringify({type:"init",projectPath:R.current.fullPath||R.current.path,sessionId:I.current?null:E.current?.id,hasSession:I.current?!1:!!E.current,provider:I.current?"plain-shell":E.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:B.current,isPlainShell:I.current})))},100)},m.current.onmessage=U=>{try{const le=JSON.parse(U.data);if(le.type==="output"){let oe=le.data;if(I.current&&Y.current){const Te=oe.replace(/\x1b\[[0-9;]*m/g,"");if(Te.includes("Process exited with code 0"))Y.current(0);else if(Te.match(/Process exited with code (\d+)/)){const te=parseInt(Te.match(/Process exited with code (\d+)/)[1]);te!==0&&Y.current(te)}}u.current&&u.current.write(oe)}else le.type==="url_open"&&window.open(le.url,"_blank")}catch(le){console.error("[Shell] Error handling WebSocket message:",le,U.data)}},m.current.onclose=U=>{x(!1),z(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},m.current.onerror=U=>{x(!1),z(!1)}}catch{x(!1),z(!1)}},[Z,f]),re=i.useCallback(()=>{!h||f||Z||(z(!0),_())},[h,f,Z,_]),ie=i.useCallback(()=>{m.current&&(m.current.close(),m.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),x(!1),z(!1)},[]),V=i.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),ae=i.useMemo(()=>V?V.slice(0,30):null,[V]),de=i.useMemo(()=>V?V.slice(0,50):null,[V]),ve=()=>{S(!0),m.current&&(m.current.close(),m.current=null),u.current&&(u.current.dispose(),u.current=null,p.current=null),x(!1),N(!1),setTimeout(()=>{S(!1)},200)};return i.useEffect(()=>{const fe=t?.id||null;$!==null&&$!==fe&&h&&ie(),F(fe)},[t?.id,h,ie]),i.useEffect(()=>{if(!d.current||!e||w||u.current)return;u.current=new R0.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),p.current=new M0.FitAddon;const fe=new D0.WebglAddon,U=new O0.WebLinksAddon;u.current.loadAddon(p.current),u.current.loadAddon(U);try{u.current.loadAddon(fe)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler(oe=>(oe.ctrlKey||oe.metaKey)&&oe.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):(oe.ctrlKey||oe.metaKey)&&oe.key==="v"?(navigator.clipboard.readText().then(Te=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:Te}))}).catch(()=>{}),!1):!0),setTimeout(()=>{p.current&&(p.current.fit(),u.current&&m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),N(!0),u.current.onData(oe=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:oe}))});const le=new ResizeObserver(()=>{p.current&&u.current&&setTimeout(()=>{p.current.fit(),m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&le.observe(d.current),()=>{le.disconnect(),m.current&&(m.current.readyState===WebSocket.OPEN||m.current.readyState===WebSocket.CONNECTING)&&m.current.close(),m.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,w]),i.useEffect(()=>{!l||!h||Z||f||re()},[l,h,Z,f,re]),e?a?n.jsx("div",{className:"h-full w-full bg-gray-900",children:n.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):n.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[n.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${f?"bg-green-500":"bg-red-500"}`}),t&&n.jsxs("span",{className:"text-xs text-primary/80",children:["(",ae,"...)"]}),!t&&n.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!h&&n.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),w&&n.jsx("span",{className:"text-xs text-primary",children:c("shell.status.restarting")})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[f&&n.jsxs("button",{onClick:ie,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:[n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),n.jsx("span",{children:c("shell.actions.disconnect")})]}),n.jsxs("button",{onClick:ve,disabled:w||f,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:[n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})}),n.jsx("span",{children:c("shell.actions.restart")})]})]})]})}),n.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[n.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!h&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:n.jsx("div",{className:"text-white",children:c("shell.loading")})}),h&&!f&&!Z&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:n.jsxs("div",{className:"text-center max-w-sm w-full",children:[n.jsxs("button",{onClick:re,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:[n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),n.jsx("span",{children:c("shell.actions.connect")})]}),n.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:de}):c("shell.startSession")})]})}),Z&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:n.jsxs("div",{className:"text-center max-w-sm w-full",children:[n.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[n.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),n.jsx("span",{className:"text-base font-medium",children:c("shell.connecting")})]}),n.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?c("shell.runCommand",{command:r||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName})})]})})]})]}):n.jsx("div",{className:"h-full flex items-center justify-center",children:n.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[n.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:n.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.jsx("h3",{className:"text-lg font-semibold mb-2",children:c("shell.selectProject.title")}),n.jsx("p",{children:c("shell.selectProject.description")})]})})}function lc({project:e,session:t=null,command:r=null,isPlainShell:o=null,autoConnect:s=!0,onComplete:a=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:m=!1}){const[f,x]=i.useState(!1),h=o!==null?o:r!==null,N=i.useCallback(w=>{x(!0),a&&a(w)},[a]);return e?n.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!m&&u&&c&&n.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-200",children:c}),f&&n.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),l&&n.jsx("button",{onClick:l,className:"text-gray-400 hover:text-white",title:"Close",children:n.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),n.jsx("div",{className:"flex-1 w-full min-h-0",children:n.jsx($0,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:h,onProcessComplete:N,minimal:m,autoConnect:m?!0:s})})]}):n.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:n.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[n.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:n.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),n.jsx("p",{children:"A project is required to open a shell"})]})})}class z0 extends wt.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,r){console.error("ErrorBoundary caught an error:",t,r),this.setState({error:t,errorInfo:r})}render(){return this.state.hasError?n.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:n.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[n.jsxs("div",{className:"flex items-center mb-4",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:n.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"})})}),n.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),n.jsxs("div",{className:"text-sm text-red-700",children:[n.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&n.jsxs("details",{className:"mt-4",children:[n.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),n.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]})]})]}),n.jsx("div",{className:"mt-4",children:n.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}}function cc(e){return e==="files"?"chat":e}function B0({selectedProject:e,selectedSession:t,activeTab:r,setActiveTab:o,ws:s,sendMessage:a,latestMessage:l,isMobile:c,isPWA:d,onMenuClick:u,isLoading:p,onInputFocusChange:m,onSessionActive:f,onSessionInactive:x,onSessionProcessing:h,onSessionNotProcessing:N,processingSessions:w,onReplaceTemporarySession:S,onNavigateToSession:$,onShowSettings:F,autoExpandTools:Z,showRawParameters:z,showThinking:R,autoScrollToBottom:E,sendByCtrlEnter:B,externalMessageUpdate:I,urlContext:Y,urlPrompt:_,urlSlashCommands:re,integrationClientId:ie,latestIntegrationMessage:V,sendIntegrationMessage:ae,onShowNewProject:de,onNewSession:ve,newSessionResetNonce:fe}){const{t:U}=Et(),[le,oe]=i.useState(null),Te=(he,et=null)=>{const _e={name:he.split("/").pop(),path:he,projectName:e?.name,diffInfo:et};oe(_e)},te=()=>{oe(null)};i.useEffect(()=>{const he=cc(r);he!==r&&o(he)},[r,o]);const Q="flex flex-shrink-0 items-center justify-center p-1.5 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none touch-manipulation active:scale-95",we="flex flex-shrink-0 items-center justify-center text-muted-foreground";if(p)return n.jsxs("div",{className:"h-full flex flex-col",children:[c&&n.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:n.jsx("button",{onClick:u,className:`pwa-menu-button ${Q}`,children:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[n.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:n.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"}})}),n.jsx("h2",{className:"text-xl font-semibold",children:U("mainContent.loading")})]})})]});if(!e)return n.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[c&&n.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:n.jsx("button",{onClick:u,className:`pwa-menu-button ${Q}`,children:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),n.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:n.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[n.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:n.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:U("mainContent.chooseProject")}),n.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:U("mainContent.selectProjectDescription")}),n.jsx("div",{className:"mx-auto flex w-fit items-center",children:n.jsxs("button",{onClick:de,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:U("sidebar:projects.newProject"),children:[n.jsx(Gn,{className:"w-5 h-5"}),n.jsx("span",{children:U("sidebar:projects.newProject")})]})})]})})]});const Ie=t?.__provider||t?.provider||"claude",ye=Ie==="openai"?"codex":Ie,Oe=ye==="codex"&&typeof t?.id=="string"?t.id.trim():"",Be=Oe?`codex://threads/${encodeURIComponent(Oe)}`:"",$e=()=>{Be&&(window.location.href=Be)};return n.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[n.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:n.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[c&&n.jsx("button",{onClick:u,onTouchStart:he=>{he.preventDefault(),u()},className:`pwa-menu-button ${Q}`,children:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),n.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[r==="chat"&&t&&n.jsx("div",{className:we,children:ye==="codex"?n.jsx(kr,{className:"w-4 h-4"}):ye==="gemini"?n.jsx(jr,{className:"w-4 h-4"}):ye==="opencode"?n.jsx(Sr,{className:"h-4 w-auto max-w-full"}):n.jsx(wr,{className:"w-4 h-4"})}),n.jsx("div",{className:"min-w-0 flex-1",children:r==="chat"&&t?n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:ye==="codex"?t.summary||t.name||"Codex Session":ye==="gemini"?t.summary||t.name||"Gemini Session":ye==="opencode"?t.summary||t.name||"OpenCode Session":t.summary||"New Session"}),n.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:e.displayName})]}):r==="chat"&&!t?n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:U("mainContent.newSession")}),n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):n.jsxs("div",{className:"min-w-0",children:[n.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"Project"}),n.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[r==="chat"&&ye==="codex"&&Be&&!c&&n.jsx("button",{onClick:$e,className:Q,title:U("mainContent.openInCodexClient"),"aria-label":U("mainContent.openInCodexClient"),children:n.jsx(Xr,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>ve&&ve(e),className:Q,title:U("tooltips.newChat","New Chat"),children:n.jsx(Du,{className:"w-5 h-5"})})]})]})}),n.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:n.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[n.jsx("div",{className:`h-full ${r==="chat"?"block":"hidden"}`,children:n.jsx(z0,{showDetails:!0,children:n.jsx(_0,{selectedProject:e,selectedSession:t,ws:s,sendMessage:a,latestMessage:l,onFileOpen:Te,onInputFocusChange:m,onSessionActive:f,onSessionInactive:x,onSessionProcessing:h,onSessionNotProcessing:N,processingSessions:w,onReplaceTemporarySession:S,onNavigateToSession:$,onShowSettings:F,autoExpandTools:Z,showRawParameters:z,showThinking:R,autoScrollToBottom:E,sendByCtrlEnter:B,externalMessageUpdate:I,urlContext:Y,urlPrompt:_,urlSlashCommands:re,integrationClientId:ie,latestIntegrationMessage:V,sendIntegrationMessage:ae,newSessionResetNonce:fe},`${e?.name||"no-project"}:${t?.id||`new-${fe}`}`)})}),r==="shell"&&n.jsx("div",{className:"h-full w-full overflow-hidden",children:n.jsx(lc,{project:e,session:t,showHeader:!1})}),n.jsx("div",{className:`h-full overflow-hidden ${r==="preview"?"block":"hidden"}`})]})}),le&&n.jsx(P0,{file:le,onClose:te})]})}const U0=wt.memo(B0),dc="0.2.11",uc=()=>{const[e,t]=i.useState(!1),[r,o]=i.useState(null),[s,a]=i.useState(null);return i.useEffect(()=>{(async()=>{try{const c=await Kt("/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/,"");o(u),t(!!d.updateAvailable),a({title:d.releaseInfo?.title||`v${u}`,body:d.releaseInfo?.body||"",htmlUrl:d.releaseInfo?.htmlUrl||`https://www.npmjs.com/package/${d.packageName||"@axhub/genie"}`,publishedAt:d.releaseInfo?.publishedAt||null})}else t(!1),o(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),t(!1),o(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:r,currentVersion:dc,releaseInfo:s}};function W0(){const{t:e}=Et("settings"),[t,r]=i.useState([]),[o,s]=i.useState(!0),[a,l]=i.useState(!1),[c,d]=i.useState(""),[u,p]=i.useState(null),[m,f]=i.useState(null),{updateAvailable:x,latestVersion:h,releaseInfo:N}=uc();i.useEffect(()=>{w()},[]);const w=async()=>{try{s(!0);const R=await(await Kt("/api/settings/api-keys")).json();r(R.apiKeys||[])}catch(z){console.error("Error fetching settings:",z)}finally{s(!1)}},S=async()=>{if(c.trim())try{const R=await(await Kt("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:c})})).json();R.success&&(f(R.apiKey),d(""),l(!1),w())}catch(z){console.error("Error creating API key:",z)}},$=async z=>{if(confirm(e("apiKeys.confirmDelete")))try{await Kt(`/api/settings/api-keys/${z}`,{method:"DELETE"}),w()}catch(R){console.error("Error deleting API key:",R)}},F=async(z,R)=>{try{await Kt(`/api/settings/api-keys/${z}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!R})}),w()}catch(E){console.error("Error toggling API key:",E)}},Z=(z,R)=>{navigator.clipboard.writeText(z),p(R),setTimeout(()=>p(null),2e3)};return o?n.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):n.jsxs("div",{className:"space-y-8",children:[m&&n.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[n.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),n.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:m.apiKey}),n.jsx(Le,{size:"sm",variant:"outline",onClick:()=>Z(m.apiKey,"new"),children:u==="new"?n.jsx(jn,{className:"h-4 w-4"}):n.jsx(vi,{className:"h-4 w-4"})})]}),n.jsx(Le,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>f(null),children:e("apiKeys.newKey.iveSavedIt")})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(bi,{className:"h-5 w-5"}),n.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),n.jsxs(Le,{size:"sm",onClick:()=>l(!a),children:[n.jsx(hr,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),n.jsxs("div",{className:"mb-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),n.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"),n.jsx(Xr,{className:"h-3 w-3"})]})]}),a&&n.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[n.jsx(Ln,{placeholder:e("apiKeys.form.placeholder"),value:c,onChange:z=>d(z.target.value),className:"mb-2"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Le,{onClick:S,children:e("apiKeys.form.createButton")}),n.jsx(Le,{variant:"outline",onClick:()=>l(!1),children:e("apiKeys.form.cancelButton")})]})]}),n.jsx("div",{className:"space-y-2",children:t.length===0?n.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(z=>n.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-medium",children:z.key_name}),n.jsx("code",{className:"text-xs text-muted-foreground",children:z.api_key}),n.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()}`]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Le,{size:"sm",variant:z.is_active?"outline":"secondary",onClick:()=>F(z.id,z.is_active),children:z.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),n.jsx(Le,{size:"sm",variant:"ghost",onClick:()=>$(z.id),children:n.jsx(In,{className:"h-4 w-4"})})]})]},z.id))})]}),n.jsx("div",{className:"pt-6 border-t border-border/50",children:n.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[n.jsxs("a",{href:N?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",dc]}),x&&h&&n.jsxs("a",{href:N?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/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:[n.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:h})}),n.jsx(Xr,{className:"h-2.5 w-2.5"})]})]})})]})}function K0({compact:e=!1}){const{i18n:t,t:r}=Et("settings"),o=s=>{const a=s.target.value;t.changeLanguage(a)};return e?n.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:[n.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[n.jsx(Iu,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),r("account.language")]}),n.jsx("select",{value:t.language,onChange:o,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:Js.map(s=>n.jsx("option",{value:s.value,children:s.nativeName},s.value))})]}):n.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:r("account.languageLabel")}),n.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("account.languageDescription")})]}),n.jsx("select",{value:t.language,onChange:o,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:Js.map(s=>n.jsx("option",{value:s.value,children:s.nativeName},s.value))})]})})}function H0({isOpen:e,onClose:t,provider:r="claude",project:o,onComplete:s,customCommand:a,isAuthenticated:l=!1}){if(!e)return null;const c=()=>{if(a)return a;switch(r){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(r){case"claude":return"Claude CLI Login";case"codex":return"Codex CLI Login";case"gemini":return"Gemini CLI Login";case"opencode":return"OpenCode CLI Login";default:return"CLI Login"}},u=p=>{s?.(p),p===0&&t()};return n.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:n.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:[n.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[n.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),n.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:n.jsx(Wt,{className:"w-6 h-6"})})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(lc,{project:o,command:c(),onComplete:u,minimal:!0})})]})})}const Bo=["appearance","api"],q0={allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"},G0={permissionMode:"default"},V0=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],fs=[{key:"claude",label:"Claude CLI",endpoint:"/api/cli/claude/status"},{key:"codex",label:"Codex CLI",endpoint:"/api/cli/codex/status"},{key:"gemini",label:"Gemini CLI",endpoint:"/api/cli/gemini/status"},{key:"opencode",label:"OpenCode CLI",endpoint:"/api/cli/opencode/status"}];function Ja(e,t){try{const r=localStorage.getItem(e);if(!r)return t;const o=JSON.parse(r);return o&&typeof o=="object"?{...t,...o}:t}catch{return t}}function J0(){return fs.reduce((e,t)=>(e[t.key]={authenticated:!1,email:null,loading:!0,error:null},e),{})}function Ya(){if(typeof window>"u")return{name:"default",fullPath:"/"};const e=new URLSearchParams(window.location.search);return{name:"default",fullPath:e.get("cwd")||e.get("workdir")||"/"}}function Xa({title:e,description:t,checked:r,onToggle:o}){return n.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"text-sm font-medium text-foreground",children:e}),t?n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:t}):null]}),n.jsx("button",{type:"button",onClick:o,className:`relative h-7 w-12 rounded-full transition ${r?"bg-primary":"bg-muted"}`,"aria-checked":r,role:"switch",children:n.jsx("span",{className:`absolute top-1 h-5 w-5 rounded-full bg-background shadow transition ${r?"left-6":"left-1"}`})})]})}function Qa({items:e,onRemove:t,emptyLabel:r}){return e.length?n.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(o=>n.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-border/60 bg-muted/40 px-3 py-1 text-xs",children:[n.jsx("span",{className:"font-mono",children:o}),n.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:n.jsx(Wt,{className:"h-3.5 w-3.5"})})]},o))}):n.jsx("div",{className:"text-xs text-muted-foreground",children:r})}function Y0({provider:e,status:t,onLogin:r}){const o=t?.authenticated,s=t?.loading,a=o?"border-emerald-500/25 bg-emerald-500/5":t?.error?"border-amber-500/25 bg-amber-500/5":"border-border/60 bg-card/70";return n.jsxs("div",{className:`rounded-2xl border px-4 py-4 ${a}`,children:[n.jsxs("div",{className:"flex items-start justify-between gap-3",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm font-semibold text-foreground",children:e.label}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s?"Checking local authentication...":o?t.email||"Authenticated locally":t?.error||"Not authenticated"})]}),n.jsx(Vd,{variant:o?"default":"secondary",children:s?"Checking":o?"Ready":"Needs login"})]}),n.jsx("div",{className:"mt-4 flex items-center gap-2",children:n.jsxs(Le,{size:"sm",variant:o?"outline":"default",onClick:()=>r(e.key),children:[n.jsx(Jd,{className:"mr-2 h-4 w-4"}),o?"Re-authenticate":"Open login"]})})]})}function X0({isOpen:e,onClose:t,projects:r=[],initialTab:o="appearance"}){const{isDarkMode:s,toggleDarkMode:a}=vs(),[l,c]=i.useState(Bo.includes(o)?o:"appearance"),[d,u]=i.useState([]),[p,m]=i.useState([]),[f,x]=i.useState(""),[h,N]=i.useState(""),[w,S]=i.useState(!1),[$,F]=i.useState("name"),[Z,z]=i.useState("default"),[R,E]=i.useState(!1),[B,I]=i.useState(null),[Y,_]=i.useState(J0),[re,ie]=i.useState(!1),[V,ae]=i.useState("claude"),[de,ve]=i.useState(null);i.useEffect(()=>{c(Bo.includes(o)?o:"appearance")},[o]),i.useEffect(()=>{if(!e)return;const Q=Ja("claude-settings",q0),we=Ja("codex-settings",G0);u(Array.isArray(Q.allowedTools)?Q.allowedTools:[]),m(Array.isArray(Q.disallowedTools)?Q.disallowedTools:[]),S(!!Q.skipPermissions),F(Q.projectSortOrder==="date"?"date":"name"),z(we.permissionMode||"default"),I(null),U()},[e]);const fe=i.useMemo(()=>de||r?.[0]||Ya(),[r,de]);async function U(){const Q=await Promise.all(fs.map(async we=>{try{const Ie=await Kt(we.endpoint),ye=Ie.ok?await Ie.json():null;return[we.key,{authenticated:!!ye?.authenticated,email:ye?.email||null,loading:!1,error:ye?.error||(Ie.ok?null:"Failed to check authentication status")}]}catch(Ie){return[we.key,{authenticated:!1,email:null,loading:!1,error:Ie.message}]}}));_(Object.fromEntries(Q))}function le(){E(!0),I(null);try{localStorage.setItem("claude-settings",JSON.stringify({allowedTools:d,disallowedTools:p,skipPermissions:w,projectSortOrder:$,lastUpdated:new Date().toISOString()})),localStorage.setItem("codex-settings",JSON.stringify({permissionMode:Z,lastUpdated:new Date().toISOString()})),I("success"),window.dispatchEvent(new StorageEvent("storage",{key:"claude-settings"})),window.dispatchEvent(new StorageEvent("storage",{key:"codex-settings"}))}catch(Q){console.error("Error saving local settings:",Q),I("error")}finally{E(!1)}}function oe(Q){ae(Q),ve(r?.[0]||Ya()),ie(!0)}function Te(Q){Q===0&&(I("success"),U())}function te(Q,we,Ie,ye){const Oe=Q.trim();!Oe||Ie.includes(Oe)||(ye([...Ie,Oe]),we(""))}return e?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",onClick:t}),n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:n.jsxs("div",{className:"flex h-[85vh] w-full max-w-5xl flex-col overflow-hidden rounded-3xl border border-border/60 bg-background shadow-2xl",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 px-6 py-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:n.jsx(Wu,{className:"h-5 w-5"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-lg font-semibold text-foreground",children:"Settings"}),n.jsx("div",{className:"text-sm text-muted-foreground",children:"Local preferences, provider auth, and API access."})]})]}),n.jsx(Le,{variant:"ghost",size:"icon",onClick:t,"aria-label":"Close settings",children:n.jsx(Wt,{className:"h-5 w-5"})})]}),n.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[n.jsx("div",{className:"w-52 border-r border-border/60 bg-muted/20 p-4",children:n.jsx("div",{className:"space-y-2",children:Bo.map(Q=>n.jsxs("button",{type:"button",onClick:()=>c(Q),className:`flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition ${l===Q?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"}`,children:[Q==="appearance"?n.jsx(qd,{className:"h-4 w-4"}):n.jsx(bi,{className:"h-4 w-4"}),n.jsx("span",{children:Q==="appearance"?"Appearance":"API & Auth"})]},Q))})}),n.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:l==="appearance"?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Application"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Adjust the shell around the editor and sidebar."})]}),n.jsx(Xa,{title:"Dark mode",description:"Switch the overall application theme.",checked:s,onToggle:a}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[n.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[n.jsx(Gd,{className:"h-4 w-4"}),"Interface language"]}),n.jsx(K0,{})]}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[n.jsx("div",{className:"mb-2 text-sm font-medium text-foreground",children:"Project list sorting"}),n.jsxs("select",{value:$,onChange:Q=>F(Q.target.value==="date"?"date":"name"),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm",children:[n.jsx("option",{value:"name",children:"Name"}),n.jsx("option",{value:"date",children:"Last activity"})]})]})]}),n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Claude / Codex local behavior"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"These options stay in local storage and are used by the chat runtime."})]}),n.jsx(Xa,{title:"Skip Claude permission prompts",description:"Bypass interactive approvals when the runtime supports it.",checked:w,onToggle:()=>S(Q=>!Q)}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[n.jsx("div",{className:"mb-2 text-sm font-medium text-foreground",children:"Codex permission mode"}),n.jsxs("select",{value:Z,onChange:Q=>z(Q.target.value||"default"),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm",children:[n.jsx("option",{value:"default",children:"Default"}),n.jsx("option",{value:"acceptEdits",children:"Accept edits"}),n.jsx("option",{value:"bypassPermissions",children:"Bypass permissions"}),n.jsx("option",{value:"plan",children:"Plan"})]})]}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-4",children:[n.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[n.jsx(qu,{className:"h-4 w-4"}),"Allowed tool patterns"]}),n.jsx("div",{className:"flex flex-wrap gap-2 pb-3",children:V0.map(Q=>n.jsx("button",{type:"button",onClick:()=>te(Q,x,d,u),className:"rounded-full border border-border/60 px-3 py-1 text-xs text-muted-foreground transition hover:border-primary hover:text-foreground",children:Q},Q))}),n.jsxs("div",{className:"flex gap-2 pb-3",children:[n.jsx(Ln,{value:f,onChange:Q=>x(Q.target.value),placeholder:"Add custom allow rule"}),n.jsx(Le,{onClick:()=>te(f,x,d,u),children:"Add"})]}),n.jsx(Qa,{items:d,onRemove:Q=>u(d.filter(we=>we!==Q)),emptyLabel:"No allow-list entries."})]}),n.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-4",children:[n.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[n.jsx(Qr,{className:"h-4 w-4"}),"Disallowed tool patterns"]}),n.jsxs("div",{className:"flex gap-2 pb-3",children:[n.jsx(Ln,{value:h,onChange:Q=>N(Q.target.value),placeholder:"Add custom deny rule"}),n.jsx(Le,{variant:"outline",onClick:()=>te(h,N,p,m),children:"Add"})]}),n.jsx(Qa,{items:p,onRemove:Q=>m(p.filter(we=>we!==Q)),emptyLabel:"No deny-list entries."})]})]})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Provider authentication"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a local terminal flow to sign the CLI back in when needed."})]}),n.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:fs.map(Q=>n.jsx(Y0,{provider:Q,status:Y[Q.key],onLogin:oe},Q.key))})]}),n.jsxs("section",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-base font-semibold text-foreground",children:"API keys"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the local keys used to call protected Genie endpoints."})]}),n.jsx(W0,{})]})]})})]}),n.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-6 py-4",children:[n.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:B==="success"?n.jsxs(n.Fragment,{children:[n.jsx(jn,{className:"h-4 w-4 text-emerald-500"}),n.jsx("span",{children:"Saved locally."})]}):B==="error"?n.jsxs(n.Fragment,{children:[n.jsx(Qr,{className:"h-4 w-4 text-amber-500"}),n.jsx("span",{children:"Could not save local settings."})]}):n.jsx("span",{children:"Changes only affect this local workspace profile."})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Le,{variant:"outline",onClick:t,children:"Close"}),n.jsx(Le,{onClick:le,disabled:R,children:R?"Saving...":"Save settings"})]})]})]})}),n.jsx(H0,{isOpen:re,onClose:()=>ie(!1),provider:V,project:fe,onComplete:Te,isAuthenticated:!!Y[V]?.authenticated})]}):null}var Q0=["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","className","spin"];function Za(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,o)}return r}function ei(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Za(Object(r),!0).forEach(function(o){Z0(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Za(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Z0(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ev(e,t){if(e==null)return{};var r=tv(e,t),o,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)o=a[s],!(t.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(r[o]=e[o])}return r}function tv(e,t){if(e==null)return{};var r={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(r[s]=e[s]);return r}var nv={size:"1em",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round",rtl:!1,theme:"outline",colors:{outline:{fill:"#333",background:"transparent"},filled:{fill:"#333",background:"#FFF"},twoTone:{fill:"#333",twoTone:"#2F88FF"},multiColor:{outStrokeColor:"#333",outFillColor:"#2F88FF",innerStrokeColor:"#FFF",innerFillColor:"#43CCF8"}},prefix:"i"};function rv(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function ov(e,t,r){var o=typeof t.fill=="string"?[t.fill]:t.fill||[],s=[],a=t.theme||r.theme;switch(a){case"outline":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push("none"),s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push("none");break;case"filled":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push("#FFF"),s.push("#FFF");break;case"two-tone":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:r.colors.twoTone.twoTone),s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:r.colors.twoTone.twoTone);break;case"multi-color":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:r.colors.multiColor.outFillColor),s.push(typeof o[2]=="string"?o[2]:r.colors.multiColor.innerStrokeColor),s.push(typeof o[3]=="string"?o[3]:r.colors.multiColor.innerFillColor);break}return{size:t.size||r.size,strokeWidth:t.strokeWidth||r.strokeWidth,strokeLinecap:t.strokeLinecap||r.strokeLinecap,strokeLinejoin:t.strokeLinejoin||r.strokeLinejoin,colors:s,id:e}}var pc=i.createContext(nv);pc.Provider;function mc(e,t,r){return function(o){var s=o.size,a=o.strokeWidth,l=o.strokeLinecap,c=o.strokeLinejoin,d=o.theme,u=o.fill,p=o.className,m=o.spin,f=ev(o,Q0),x=i.useContext(pc),h=i.useMemo(rv,[]),N=ov(h,{size:s,strokeWidth:a,strokeLinecap:l,strokeLinejoin:c,theme:d,fill:u},x),w=[x.prefix+"-icon"];return w.push(x.prefix+"-icon-"+e),x.rtl&&w.push(x.prefix+"-icon-rtl"),m&&w.push(x.prefix+"-icon-spin"),p&&w.push(p),wt.createElement("span",ei(ei({},f),{},{className:w.join(" ")}),r(N))}}const sv=mc("new-lark",!0,function(e){return wt.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},wt.createElement("path",{d:"M17 29C21 29 25 26.9339 28 23.4065C36 14 41.4242 16.8166 44 17.9998C38.5 20.9998 40.5 29.6233 33 35.9998C28.382 39.9259 23.4945 41.014 19 41C12.5231 40.9799 6.86226 37.7637 4 35.4063V16.9998",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),wt.createElement("path",{d:"M5.64808 15.8669C5.02231 14.9567 3.77715 14.7261 2.86694 15.3519C1.95673 15.9777 1.72615 17.2228 2.35192 18.1331L5.64808 15.8669ZM36.0021 35.7309C36.958 35.1774 37.2843 33.9539 36.7309 32.9979C36.1774 32.042 34.9539 31.7157 33.9979 32.2691L36.0021 35.7309ZM2.35192 18.1331C5.2435 22.339 10.7992 28.144 16.8865 32.2239C19.9345 34.2667 23.217 35.946 26.449 36.7324C29.6946 37.522 33.0451 37.4428 36.0021 35.7309L33.9979 32.2691C32.2049 33.3072 29.9929 33.478 27.3947 32.8458C24.783 32.2103 21.9405 30.7958 19.1135 28.9011C13.4508 25.106 8.2565 19.661 5.64808 15.8669L2.35192 18.1331Z",fill:e.colors[0]}),wt.createElement("path",{d:"M33.5947 17C32.84 14.7027 30.8551 9.94054 27.5947 7H11.5947C15.2174 10.6757 23.0002 16 27.0002 24",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}))}),av=mc("wechat",!0,function(e){return wt.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},wt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M36.9974 21.7112C36.8434 13.0079 29.7401 6 21 6C12.1634 6 5 13.1634 5 22C5 26.1701 6.59531 29.9676 9.20892 32.8154L8.01043 40.0257L15.125 36.9699C18.2597 38.0122 21.218 38.2728 24 37.7516",fill:e.colors[1]}),wt.createElement("path",{d:"M36.9974 21.7112C36.8434 13.0079 29.7401 6 21 6C12.1634 6 5 13.1634 5 22C5 26.1701 6.59531 29.9676 9.20892 32.8154L8.01043 40.0257L15.125 36.9699C18.2597 38.0122 21.218 38.2728 24 37.7516",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),wt.createElement("path",{d:"M15.125 20.4667C16.3676 20.4667 17.375 19.4519 17.375 18.2C17.375 16.9482 16.3676 15.9333 15.125 15.9333C13.8824 15.9333 12.875 16.9482 12.875 18.2C12.875 19.4519 13.8824 20.4667 15.125 20.4667Z",fill:e.colors[2]}),wt.createElement("path",{d:"M24.125 20.4667C25.3676 20.4667 26.375 19.4519 26.375 18.2C26.375 16.9482 25.3676 15.9333 24.125 15.9333C22.8824 15.9333 21.875 16.9482 21.875 18.2C21.875 19.4519 22.8824 20.4667 24.125 20.4667Z",fill:e.colors[2]}),wt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M38.7618 39.9293C37.0135 41.2302 34.8467 42 32.5 42C26.701 42 22 37.299 22 31.5C22 25.701 26.701 21 32.5 21C38.299 21 43 25.701 43 31.5C43 33.0997 42.6423 34.6159 42.0024 35.9728",fill:e.colors[1]}),wt.createElement("path",{d:"M38.7618 39.9293C37.0135 41.2302 34.8467 42 32.5 42C26.701 42 22 37.299 22 31.5C22 25.701 26.701 21 32.5 21C38.299 21 43 25.701 43 31.5C43 33.0997 42.6423 34.6159 42.0024 35.9728",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),wt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M42.0024 35.9728L43 42L38.7618 39.9293",fill:e.colors[1]}),wt.createElement("path",{d:"M42.0024 35.9728L43 42L38.7618 39.9293",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),wt.createElement("path",{d:"M35.6875 30.7999C34.7555 30.7999 34 30.0388 34 29.0999C34 28.161 34.7555 27.3999 35.6875 27.3999C36.6195 27.3999 37.375 28.161 37.375 29.0999C37.375 30.0388 36.6195 30.7999 35.6875 30.7999Z",fill:e.colors[2]}),wt.createElement("path",{d:"M28.9375 30.7999C28.0055 30.7999 27.25 30.0388 27.25 29.0999C27.25 28.161 28.0055 27.3999 28.9375 27.3999C29.8695 27.3999 30.625 28.161 30.625 29.0999C30.625 30.0388 29.8695 30.7999 28.9375 30.7999Z",fill:e.colors[2]}))}),iv=2e3,An="lan",ti="lan-access-password",lv={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode"};function cv({provider:e,className:t="h-4 w-4"}){return e==="codex"?n.jsx(kr,{className:t}):e==="gemini"?n.jsx(jr,{className:t}):e==="opencode"?n.jsx(Sr,{className:"h-4 w-auto"}):n.jsx(wr,{className:t})}function Vr({platform:e,size:t=20}){return e==="weixin"?n.jsx(av,{size:t,theme:"filled",fill:"#07C160"}):n.jsx(sv,{size:t,theme:"filled",fill:"#3370FF"})}function dv(e){return lv[e]||e}function uv(e){if(!e)return"0:00";const t=e-Date.now();if(t<=0)return"0:00";const r=Math.ceil(t/1e3),o=Math.floor(r/60),s=r%60;return`${o}:${String(s).padStart(2,"0")}`}function hs(e){return e?.fullPath||e?.path||""}function Uo(e){const t=hs(e),r=typeof e?.displayName=="string"?e.displayName.trim():"",o=typeof e?.name=="string"?e.name.trim():"";if(r)return r;if(o)return o;if(!t)return"";const a=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return a[a.length-1]||t}function ni(e){return e&&(e.title||e.label||e.value)||""}function pv({open:e,onOpenChange:t,selectedProject:r,projects:o=[],onConnectionChange:s}){const{t:a}=Et("sidebar"),[l,c]=i.useState(null),[d,u]=i.useState(!1),[p,m]=i.useState(null),[f,x]=i.useState(null),[h,N]=i.useState(null),[w,S]=i.useState(""),[$,F]=i.useState({}),[Z,z]=i.useState(null),[R,E]=i.useState(""),[B,I]=i.useState(""),[Y,_]=i.useState(!1),[re,ie]=i.useState(""),[V,ae]=i.useState({}),[de,ve]=i.useState({}),fe=i.useRef(null),U=i.useRef(null),le=hs(r),oe=l?.ccConnect?.installed===!0,Te=i.useMemo(()=>p===An?h?{id:An,connected:!!h.hasPassword,addresses:h.addresses||[]}:null:l?.platforms?.find(v=>v.id===p)||null,[p,h,l]),te=f&&f.platform===p?f:null,Q=i.useMemo(()=>(l?.providers||[]).filter(v=>v.installed).map(v=>v.id),[l]),we=i.useMemo(()=>{const v=new Map,M=(G,be)=>{const b=String(G||"").trim();!b||v.has(b)||v.set(b,{value:b,title:String(be||b).trim()||b,subtitle:b})};for(const G of o){const be=hs(G);M(be,Uo(G))}le&&M(le,Uo(r));for(const G of l?.platforms||[])G?.projectPath&&M(G.projectPath,Uo({path:G.projectPath}));return Array.from(v.values())},[o,r,le,l]),Ie=i.useMemo(()=>new Map(we.map(v=>[v.value,v])),[we]),ye=i.useMemo(()=>{const v=l?.platforms||[],M=h?[{id:An,connected:!!h.hasPassword,projectPath:h.addresses?.length?h.addresses.join(" / "):null,configuredProviders:[],activeProvider:null,addresses:h.addresses||[]}]:[];return[...v,...M]},[h,l]),Oe=()=>{fe.current&&(clearInterval(fe.current),fe.current=null)},Be=async({silent:v=!1}={})=>{v||u(!0);try{const M=await mt.ccConnect.platforms(),G=await M.json();if(!M.ok)throw new Error(G?.error||"Failed to load connection summary.");return c(G),s?.(G),G}catch(M){return E(M.message),null}finally{v||u(!1)}},$e=async()=>{try{const v=await mt.lanAccess.summary(),M=await v.json();if(!v.ok)throw new Error(M?.error||"Failed to load LAN access summary.");if(N(M),M?.hasPassword){const G=localStorage.getItem(ti);G&&S(G)}return M}catch(v){return E(v.message),null}},he=async(v,{focusQr:M=!1}={})=>{const G=await mt.lanAccess.createToken(v),be=await G.json();if(!G.ok)throw new Error(be?.error||"Failed to generate LAN access link.");return F(b=>({...b,[v]:be})),M&&z(v),be},et=async(v=[])=>{const M={};for(const G of v)try{const be=await he(G);M[G]=be}catch(be){E(be.message)}return M},_e=async()=>{const v=U.current;if(Oe(),!(!v?.sessionId||!v?.platform||new Set(["confirmed","error","expired"]).has(v.status)))try{await mt.ccConnect.cleanupSession(v.platform,v.sessionId)}catch{}};i.useEffect(()=>{U.current=f},[f]),i.useEffect(()=>{if(!e){_e(),c(null),m(null),x(null),N(null),S(""),F({}),z(null),E(""),I(""),ie(""),ae({}),ve({});return}return Promise.all([Be(),$e()]).then(([,v])=>{v?.hasPassword&&v.addresses?.length&&et(v.addresses)}),()=>{Oe()}},[e]),i.useEffect(()=>{if(!te?.sessionId){Oe();return}const v=async()=>{try{const M=await mt.ccConnect.sessionStatus(te.platform,te.sessionId),G=await M.json();if(!M.ok)throw new Error(G?.error||"Failed to read setup status.");x(G),G.status==="confirmed"?(Oe(),I(G.message||a("ccConnect.messages.connected")),ie(""),x(null),await Be({silent:!0})):(G.status==="error"||G.status==="expired")&&(Oe(),ie(""))}catch(M){Oe(),ie(""),E(M.message)}};return v(),fe.current=setInterval(()=>{v()},iv),()=>Oe()},[te?.platform,te?.sessionId,a]),i.useEffect(()=>{e&&ae(v=>{const M={...v};let G=!1;const be=l?.platforms||[];for(const b of be){if(typeof v[b.id]=="string"?v[b.id].trim():"")continue;const ee=b.projectPath||le||we[0]?.value||"";ee&&(M[b.id]=ee,G=!0)}return G?M:v})},[e,we,le,l]),i.useEffect(()=>{e&&ve(v=>{const M={...v};let G=!1;for(const be of l?.platforms||[]){const b=Array.isArray(be.configuredProviders)&&be.configuredProviders.length>0?be.configuredProviders:Q,J=typeof v[be.id]=="string"?v[be.id].trim():"";if(J&&b.includes(J))continue;const ee=b.includes(be.activeProvider)?be.activeProvider:b[0]||"";ee&&(M[be.id]=ee,G=!0)}return G?M:v})},[Q,e,l]);const Xe=v=>{const M=typeof V[v]=="string"?V[v].trim():"";return M||l?.platforms?.find(be=>be.id===v)?.projectPath||le||we[0]?.value||""},Fe=v=>Array.isArray(v?.configuredProviders)&&v.configuredProviders.length>0?v.configuredProviders:Q,Re=v=>{const M=Fe(v),G=typeof de[v?.id]=="string"?de[v.id].trim():"";return G&&M.includes(G)?G:v?.activeProvider&&M.includes(v.activeProvider)?v.activeProvider:M[0]||null},ut=async(v,M)=>{if(ae(G=>({...G,[v.id]:M})),E(""),I(""),v.connected&&M&&M!==v.projectPath)try{await T(v.id,M)}catch{}},tt=async(v,M,{persist:G=!1}={})=>{ve(be=>({...be,[v.id]:M})),G&&(E(""),I(""),await y(v.id,M))},Ue=()=>{t(!1)},We=async()=>{ie("lan:password"),E(""),I("");try{const v=await mt.lanAccess.updatePassword(w),M=await v.json();if(!v.ok)throw new Error(M?.error||"Failed to update LAN access password.");I(M.message||a("ccConnect.messages.lanPasswordUpdated")),localStorage.setItem(ti,w);const G=await $e();G?.addresses?.length&&(F({}),await et(G.addresses))}catch(v){E(v.message)}finally{ie("")}},ot=async v=>{try{const M=$[v]||await he(v);await navigator.clipboard.writeText(M.accessUrl),I(a("ccConnect.messages.lanCopied"))}catch(M){E(M.message||a("ccConnect.messages.lanCopyFailed"))}},Me=async v=>{try{const M=$[v]||await he(v);window.open(M.accessUrl,"_blank","noopener,noreferrer")}catch(M){E(M.message)}},st=async v=>{try{if(!$[v]){await he(v,{focusQr:!0});return}z(v)}catch(M){E(M.message)}},C=async(v,M)=>{const G=Xe(v);if(!G){E(a("ccConnect.messages.selectProjectFirst"));return}E(""),I(""),ie(`setup:${v}:${M}`);const be={projectPath:G,mode:M},b=Re(l?.platforms?.find(J=>J.id===v));b&&(be.provider=b);try{const J=await mt.ccConnect.setup(v,be),ee=await J.json();if(!J.ok)throw new Error(ee?.error||a("ccConnect.messages.setupFailed"));x(ee),ie(""),m(v)}catch(J){ie(""),E(J.message)}},T=async(v,M=null)=>{const G=M||Xe(v);if(!G){E(a("ccConnect.messages.selectProjectFirst"));return}E(""),I(""),ie(`project:${v}`);try{const be=await mt.ccConnect.updateProject(v,{projectPath:G}),b=await be.json();if(!be.ok)throw new Error(b?.error||a("ccConnect.messages.projectUpdateFailed"));I(b.message||a("ccConnect.messages.projectUpdateSuccess")),await Be({silent:!0})}catch(be){throw E(be.message),be}finally{ie("")}},me=async()=>{if(!(!te?.platform||!te?.sessionId)){E(""),ie(`refresh:${te.platform}`);try{const v=await mt.ccConnect.refresh(te.platform,te.sessionId),M=await v.json();if(!v.ok)throw new Error(M?.error||a("ccConnect.messages.refreshFailed"));x(M),ie("")}catch(v){ie(""),E(v.message)}}},xe=async()=>{E(""),I(""),_(!0);try{const v=await mt.ccConnect.install(),M=await v.json();if(!v.ok)throw new Error(M?.error||a("ccConnect.messages.installFailed"));I(M.message||a("ccConnect.messages.installSuccess")),await Be({silent:!0})}catch(v){E(v.message)}finally{_(!1)}},y=async(v,M)=>{E(""),I(""),ie(`switch:${v}:${M}`);try{const G=await mt.ccConnect.switchProvider(v,M),be=await G.json();if(!G.ok)throw new Error(be?.error||a("ccConnect.messages.switchFailed"));I(be.message||a("ccConnect.messages.switchSuccess")),await Be({silent:!0})}catch(G){E(G.message)}finally{ie("")}},D=async v=>{E(""),I(""),ie(`unbind:${v}`);try{const M=await mt.ccConnect.unbind(v),G=await M.json();if(!M.ok)throw new Error(G?.error||a("ccConnect.messages.unbindFailed"));I(G.message||a("ccConnect.messages.unbindSuccess")),await Be({silent:!0}),x(null)}catch(M){E(M.message)}finally{ie("")}},H=async()=>{te?.sessionId&&(await _e(),x(null)),E(""),I(""),m(null),z(null)};if(!e)return null;const L=(v,M)=>{if(!M)return null;const G=v==="error"?"border-red-200 bg-red-50 text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300":"border-green-200 bg-green-50 text-green-700 dark:border-green-900/40 dark:bg-green-950/30 dark:text-green-300";return n.jsx("div",{className:`rounded-xl border px-3 py-2 text-sm ${G}`,children:M})},O=()=>n.jsxs("div",{className:"space-y-4 rounded-2xl border border-dashed border-border bg-muted/20 p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 text-amber-600 dark:bg-amber-900/30 dark:text-amber-300",children:n.jsx(No,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.install.title")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.install.description")})]})]}),n.jsx("div",{className:"rounded-lg bg-background px-3 py-2 font-mono text-xs text-foreground shadow-sm",children:"npm install -g cc-connect@beta"}),n.jsxs(Le,{onClick:xe,disabled:Y,children:[Y?n.jsx(Tt,{className:"h-4 w-4 animate-spin"}):n.jsx(No,{className:"h-4 w-4"}),a(Y?"ccConnect.install.installing":"ccConnect.install.action")]})]}),ne=v=>{const M=Xe(v.id),G=re===`project:${v.id}`,be=Ie.get(M)||null,b=we.length>0;return n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.project.label")}),G&&n.jsx(Tt,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),n.jsxs(Ho,{value:M||void 0,onValueChange:J=>{ut(v,J)},disabled:!b||!!re||!!te,children:[n.jsx(qo,{className:"h-auto min-h-12 w-full items-start py-3",children:be?n.jsxs("div",{className:"min-w-0 text-left",children:[n.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:ni(be)}),n.jsx("div",{className:"truncate text-xs text-muted-foreground",children:be.subtitle})]}):n.jsx("div",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.placeholder")})}),n.jsx(Go,{children:we.map(J=>n.jsx(Yr,{value:J.value,children:n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:"truncate font-medium text-foreground",children:ni(J)}),n.jsx("div",{className:"truncate text-xs text-muted-foreground",children:J.subtitle})]})},J.value))})]}),!M&&n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.empty")})]})},ke=({platform:v,providers:M,selectedProvider:G,onSelect:be,disabled:b=!1,disableSelected:J=!1,busyActionForProvider:ee=null})=>M?.length?n.jsxs("div",{className:"space-y-2",children:[n.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("ccConnect.labels.providerSwitcher")}),n.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(Ae=>{const Qe=Ae===G,j=typeof ee=="function"?ee(Ae):!1;return n.jsxs("button",{type:"button",className:`inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${Qe?"border-primary/30 bg-primary/5 text-primary":"border-border/70 bg-background text-foreground hover:bg-muted/40"} disabled:cursor-not-allowed disabled:opacity-70`,disabled:b||J&&Qe&&!j,onClick:()=>{be(Ae)},children:[n.jsx(cv,{provider:Ae,className:"h-3.5 w-3.5"}),n.jsx("span",{children:dv(Ae)}),j?n.jsx(Tt,{className:"h-3.5 w-3.5 animate-spin"}):Qe?n.jsx(Ys,{className:"h-3.5 w-3.5"}):null]},`${v.id}:${Ae}`)})})]}):null,Ge=()=>n.jsxs("div",{className:"space-y-4",children:[L("success",B),L("error",R),n.jsx("div",{className:"grid gap-3",children:ye.map(v=>n.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-card",children:[n.jsx("button",{className:"w-full px-4 py-4 text-left transition-colors hover:bg-muted/20",onClick:()=>{m(v.id),E(""),I("")},children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:v.id===An?n.jsx(Jo,{className:"h-5 w-5"}):n.jsx(Vr,{platform:v.id,size:20})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a(`ccConnect.platforms.${v.id}.title`)}),v.connected&&n.jsx("span",{className:"inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-[11px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-300",children:a("ccConnect.status.connected")})]}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a(`ccConnect.platforms.${v.id}.description`)}),v.projectPath?n.jsx("p",{className:"mt-3 break-all text-xs text-muted-foreground",children:v.projectPath}):n.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:a("ccConnect.status.notConnected")})]})]})}),v.connected&&v.configuredProviders?.length>0&&n.jsx("div",{className:"border-t border-border/60 bg-muted/10 px-4 py-3",children:ke({platform:v,providers:v.configuredProviders,selectedProvider:v.activeProvider,disabled:!!re,disableSelected:!0,busyActionForProvider:M=>re===`switch:${v.id}:${M}`,onSelect:async M=>{await tt(v,M,{persist:!0})}})})]},v.id))})]}),at=v=>ke({platform:v,providers:Fe(v),selectedProvider:v.activeProvider,disabled:!!re,disableSelected:!0,busyActionForProvider:M=>re===`switch:${v.id}:${M}`,onSelect:async M=>{await tt(v,M,{persist:!0})}}),pe=v=>n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"rounded-2xl border border-green-200 bg-green-50 px-4 py-4 dark:border-green-900/40 dark:bg-green-950/30",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300",children:n.jsx(tp,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-green-700 dark:text-green-300",children:a("ccConnect.labels.connectedTitle",{platform:a(`ccConnect.platforms.${v.id}.title`)})}),n.jsx("p",{className:"mt-1 text-sm text-green-700/80 dark:text-green-300/80",children:a("ccConnect.labels.connectedHint")})]})]})}),ne(v),at(v),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsxs(Le,{variant:"outline",onClick:()=>{D(v.id)},disabled:!!re,className:"text-red-600 hover:text-red-600",children:[re===`unbind:${v.id}`?n.jsx(Tt,{className:"h-4 w-4 animate-spin"}):n.jsx(Zu,{className:"h-4 w-4"}),a("ccConnect.actions.unbind")]}),n.jsx(Le,{variant:"ghost",onClick:H,children:a("ccConnect.actions.back")})]})]}),ze=()=>{if(!te)return null;const v=te.mode==="qr",M=te.status==="pending"&&(te.qrImageBase64||te.qrUrl);return n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/20 p-4",children:n.jsxs("div",{className:"flex min-h-[220px] flex-col items-center justify-center gap-3",children:[(te.status==="starting"||re.startsWith("setup:"))&&n.jsxs(n.Fragment,{children:[n.jsx(Tt,{className:"h-8 w-8 animate-spin text-primary"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.starting")})]}),M&&n.jsxs(n.Fragment,{children:[te.qrImageBase64?n.jsx("img",{src:`data:image/png;base64,${te.qrImageBase64}`,alt:a("ccConnect.labels.qrAlt"),className:"h-48 w-48 rounded-xl border border-border bg-white object-contain p-2"}):n.jsx("img",{src:te.qrUrl,alt:a("ccConnect.labels.qrAlt"),className:"h-48 w-48 rounded-xl border border-border bg-white object-contain p-2"}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.status.awaitingScan")}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.labels.countdown",{time:uv(te.expiresAt)})})]}),te.status==="scanned"&&n.jsxs(n.Fragment,{children:[n.jsx(Ys,{className:"h-10 w-10 text-primary"}),n.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.status.scanned")}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.status.confirmOnDevice")})]}),te.status==="error"&&n.jsxs(n.Fragment,{children:[n.jsx(No,{className:"h-8 w-8 text-red-500"}),n.jsx("p",{className:"text-sm font-medium text-red-600 dark:text-red-300",children:te.message})]}),te.status==="expired"&&n.jsxs(n.Fragment,{children:[n.jsx(Vo,{className:"h-8 w-8 text-muted-foreground"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.expired")})]})]})}),v&&(te.status==="pending"||te.status==="error"||te.status==="expired")&&n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(Le,{variant:"outline",onClick:()=>{me()},disabled:!!re,children:[re.startsWith("refresh:")?n.jsx(Tt,{className:"h-4 w-4 animate-spin"}):n.jsx(Vo,{className:"h-4 w-4"}),a("ccConnect.actions.refreshQr")]}),n.jsx(Le,{variant:"ghost",onClick:H,children:a("ccConnect.actions.cancel")})]})]})},Je=v=>n.jsxs("div",{className:"space-y-4",children:[ne(v),ke({platform:v,providers:Fe(v),selectedProvider:Re(v),disabled:!!te||!!re,onSelect:async M=>{await tt(v,M)}}),n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:n.jsx(Pr,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.weixin.qrTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.weixin.qrDescription")})]})]}),!te&&n.jsxs(Le,{className:"mt-4",onClick:()=>{C(v.id,"qr")},disabled:!Xe(v.id)||!Re(v)||!!re,children:[re==="setup:weixin:qr"?n.jsx(Tt,{className:"h-4 w-4 animate-spin"}):n.jsx(Vr,{platform:v.id,size:16}),a("ccConnect.actions.connectWeixin")]})]}),ze(),!te&&n.jsx(Le,{variant:"ghost",onClick:H,children:a("ccConnect.actions.back")})]}),it=v=>n.jsxs("div",{className:"space-y-4",children:[ne(v),ke({platform:v,providers:Fe(v),selectedProvider:Re(v),disabled:!!te||!!re,onSelect:async M=>{await tt(v,M)}}),!te&&n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:n.jsx(Pr,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.feishu.qrTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.feishu.qrDescription")})]})]}),n.jsxs(Le,{className:"mt-4",onClick:()=>{C(v.id,"qr")},disabled:!Xe(v.id)||!Re(v)||!!re,children:[re==="setup:feishu:qr"?n.jsx(Tt,{className:"h-4 w-4 animate-spin"}):n.jsx(Vr,{platform:v.id,size:16}),a("ccConnect.actions.startQrSetup")]})]}),ze(),!te&&n.jsx(Le,{variant:"ghost",onClick:H,children:a("ccConnect.actions.back")})]}),Ct=()=>{const v=h?.addresses||[],M=Z?$[Z]:null;return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:n.jsx(Xs,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.passwordTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.lan.passwordDescription")})]})]}),n.jsxs("div",{className:"mt-4 flex flex-col gap-3 sm:flex-row",children:[n.jsx("input",{type:"password",value:w,onChange:G=>S(G.target.value),placeholder:a("ccConnect.platforms.lan.passwordPlaceholder"),className:"h-11 flex-1 rounded-2xl border border-border bg-background px-4 text-sm outline-none transition focus:border-primary"}),n.jsxs(Le,{className:"h-11 rounded-2xl px-4",onClick:()=>{We()},disabled:!w.trim()||re==="lan:password",children:[re==="lan:password"?n.jsx(Tt,{className:"h-4 w-4 animate-spin"}):n.jsx(Xs,{className:"h-4 w-4"}),a("ccConnect.actions.saveLanPassword")]})]})]}),n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"mb-3",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.linksTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.lan.linksDescription")})]}),n.jsx("div",{className:"space-y-3",children:v.length?v.map(G=>($[G],n.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/10 px-3 py-2.5",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:G})}),n.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[n.jsx(ln,{content:a("ccConnect.actions.copyLink"),delay:150,children:n.jsx("span",{children:n.jsx(Le,{variant:"outline",size:"icon",className:"h-9 w-9 rounded-xl",disabled:!h?.hasPassword,onClick:()=>{ot(G)},"aria-label":a("ccConnect.actions.copyLink"),title:a("ccConnect.actions.copyLink"),children:n.jsx(vi,{className:"h-4 w-4"})})})}),n.jsx(ln,{content:a("ccConnect.actions.openLink"),delay:150,children:n.jsx("span",{children:n.jsx(Le,{variant:"outline",size:"icon",className:"h-9 w-9 rounded-xl",disabled:!h?.hasPassword,onClick:()=>{Me(G)},"aria-label":a("ccConnect.actions.openLink"),title:a("ccConnect.actions.openLink"),children:n.jsx(Xr,{className:"h-4 w-4"})})})}),n.jsx(ln,{content:a("ccConnect.actions.showLanQr"),delay:150,children:n.jsx("span",{children:n.jsx(Le,{size:"icon",className:"h-9 w-9 rounded-xl",disabled:!h?.hasPassword,onClick:()=>{st(G)},"aria-label":a("ccConnect.actions.showLanQr"),title:a("ccConnect.actions.showLanQr"),children:n.jsx(Pr,{className:"h-4 w-4"})})})})]})]})},G))):n.jsx("div",{className:"rounded-2xl border border-dashed border-border/70 px-4 py-6 text-sm text-muted-foreground",children:a("ccConnect.platforms.lan.noAddresses")})})]}),M?.qrCodeDataUrl&&n.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:n.jsx(Pr,{className:"h-5 w-5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.qrTitle")}),n.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:Z})]})]}),n.jsxs("div",{className:"mt-4 flex flex-col items-center gap-3",children:[n.jsx("img",{src:M.qrCodeDataUrl,alt:a("ccConnect.labels.qrAlt"),className:"h-52 w-52 rounded-2xl border border-border bg-white object-contain p-2"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.platforms.lan.qrHint")})]})]})]})},Mt=v=>v?n.jsxs("div",{className:"space-y-4",children:[L("success",B),L("error",R),v.id!==An&&!oe&&!v.connected?n.jsxs("div",{className:"space-y-4",children:[O(),n.jsx(Le,{variant:"ghost",onClick:H,children:a("ccConnect.actions.back")})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("button",{className:"inline-flex items-center gap-2 rounded-lg px-2 py-1 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:()=>{H()},children:[n.jsx(su,{className:"h-4 w-4"}),a("ccConnect.actions.back")]}),n.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-3 py-1 text-xs font-medium text-primary",children:[v.id===An?n.jsx(Jo,{className:"h-4 w-4"}):n.jsx(Vr,{platform:v.id,size:16}),a(`ccConnect.platforms.${v.id}.title`)]})]}),v.id===An?Ct():v.connected&&!te?pe(v):v.id==="weixin"?Je(v):it(v)]})]}):null;return Jr.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:n.jsxs("div",{className:"w-full max-w-2xl overflow-hidden rounded-[28px] border border-border/70 bg-background shadow-2xl",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 px-6 py-4",children:[n.jsx("div",{className:"min-w-0",children:n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-foreground",children:a("ccConnect.title")}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.subtitle")})]})}),n.jsxs("div",{className:"flex items-center gap-3",children:[d&&n.jsx(Tt,{className:"h-4 w-4 animate-spin text-muted-foreground"}),n.jsx(Le,{variant:"ghost",size:"icon",onClick:Ue,"aria-label":a("actions.cancel"),children:n.jsx(Wt,{className:"h-4 w-4"})})]})]}),n.jsx("div",{className:"max-h-[80vh] overflow-y-auto px-6 py-5",children:l||h?Te?Mt(Te):Ge():n.jsxs("div",{className:"flex min-h-[240px] flex-col items-center justify-center gap-3",children:[n.jsx(Tt,{className:"h-8 w-8 animate-spin text-primary"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.loading")})]})})]})}),document.body)}function mv(e=window.location.hostname){return e==="localhost"||e==="127.0.0.1"||e==="::1"}const fc=i.createContext({user:null,token:null,authenticateLanAccess:()=>{},logout:()=>{},isLoading:!0,error:null}),Os=()=>{const e=i.useContext(fc);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},fv=({children:e})=>{const[t,r]=i.useState(null),[o,s]=i.useState(localStorage.getItem("auth-token")),[a,l]=i.useState(!0),[c,d]=i.useState(null),u=()=>{localStorage.removeItem("auth-token"),s(null),r(null)},p=(N,w)=>{N&&(localStorage.setItem("auth-token",N),s(N)),r(w||null)},m=async()=>{const N=await mt.auth.bootstrap(),w=await N.json();if(!N.ok){if(N.status===403)return!1;throw new Error(w?.error||"Failed to initialize local access")}return p(w.token,w.user),!0},f=async()=>{try{l(!0),d(null);const N=localStorage.getItem("auth-token");if(N)try{const w=await mt.auth.user();if(w.ok){const S=await w.json();s(N),r(S.user);return}u()}catch(w){console.error("Token verification failed:",w),u()}mv()&&await m()}catch(N){console.error("[AuthContext] Authentication bootstrap failed:",N),d(N.message||"Failed to initialize access")}finally{l(!1)}};i.useEffect(()=>{f()},[]);const x=async N=>{try{d(null);const w=await mt.lanAccess.login(N),S=await w.json();if(w.ok)return p(S.token,S.user),{success:!0};const $=S?.error||"Access denied";return d($),{success:!1,error:$}}catch(w){console.error("LAN access login error:",w);const S="Network error. Please try again.";return d(S),{success:!1,error:S}}},h=()=>{u(),o&&mt.auth.logout().catch(N=>{console.error("Logout endpoint error:",N)})};return n.jsx(fc.Provider,{value:{user:t,token:o,authenticateLanAccess:x,logout:h,isLoading:a,error:c},children:e})},hc=i.createContext(null),hv=()=>{const e=i.useContext(hc);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},xv=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},gv=()=>{const e=i.useRef(null),t=i.useRef(!1),[r,o]=i.useState(null),[s,a]=i.useState(!1),l=i.useRef(null),c=i.useRef(!1),d=i.useRef([]),u=i.useRef([]),p=i.useRef(null),m=i.useRef(0),{token:f}=Os(),x=i.useCallback(()=>{if(p.current||t.current)return;const R=()=>{if(p.current=null,t.current){u.current=[];return}const E=u.current.shift();E&&(m.current+=1,o({...E,__messageSeq:m.current}),u.current.length>0&&(p.current=setTimeout(R,0)))};p.current=setTimeout(R,0)},[]),h=i.useCallback(R=>{u.current.push(R),x()},[x]),N=i.useCallback((R,E)=>{h({type:"connection-error",error:E,provider:R?.provider||(typeof R?.type=="string"?R.type.replace(/-command$/,""):"claude"),sessionId:R?.sessionId||R?.options?.sessionId||null,clientRequestId:R?.clientRequestId||null})},[h]),w=i.useCallback(R=>{R.timeoutId&&(clearTimeout(R.timeoutId),R.timeoutId=null)},[]),S=i.useCallback(R=>{if(R.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach(B=>{w(B),R.send(JSON.stringify(B.payload))})},[w]),$=i.useCallback(R=>{if(!R||typeof R!="object"||R.clientRequestId)return R;const E=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...R,clientRequestId:E}},[]),F=i.useCallback(()=>{if(t.current||c.current)return;const R=e.current;if(!(R&&(R.readyState===WebSocket.OPEN||R.readyState===WebSocket.CONNECTING)))try{const E=xv(f);if(!E){d.current.splice(0,d.current.length).forEach(Y=>{w(Y),N(Y.payload,"No authentication token found for WebSocket connection")});return}c.current=!0;const B=new WebSocket(E);e.current=B,B.onopen=()=>{c.current=!1,a(!0),e.current=B,h({type:"ws-connection-state",state:"connected"}),S(B)},B.onmessage=I=>{try{const Y=JSON.parse(I.data);h(Y)}catch(Y){console.error("Error parsing WebSocket message:",Y)}},B.onclose=()=>{c.current=!1,a(!1),e.current===B&&(e.current=null),h({type:"ws-connection-state",state:"disconnected"}),l.current=setTimeout(()=>{t.current||F()},3e3)},B.onerror=I=>{console.error("WebSocket error:",I)}}catch(E){c.current=!1,console.error("Error creating WebSocket connection:",E)}},[w,N,S,f]);i.useEffect(()=>(t.current=!1,F(),()=>{c.current=!1,l.current&&clearTimeout(l.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[F,f]),i.useEffect(()=>()=>{t.current=!0,c.current=!1,l.current&&clearTimeout(l.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(E=>w(E)),e.current&&(e.current.close(),e.current=null)},[w]);const Z=i.useCallback(R=>{const E=$(R),B=e.current;if(B&&B.readyState===WebSocket.OPEN){try{B.send(JSON.stringify(E))}catch(Y){throw Y}return}h({type:"ws-connection-state",state:"connecting",sessionId:E?.sessionId||E?.options?.sessionId||null,clientRequestId:E?.clientRequestId||null});const I={payload:E,timeoutId:setTimeout(()=>{d.current=d.current.filter(Y=>Y!==I),N(E,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(I),F()},[F,N,h,$]);return i.useMemo(()=>({ws:e.current,sendMessage:Z,latestMessage:r,isConnected:s}),[Z,r,s])},vv=({children:e})=>{const t=gv();return n.jsx(hc.Provider,{value:t,children:e})};function yv(){const{t:e}=Et("common"),{authenticateLanAccess:t,error:r}=Os(),[o,s]=i.useState(""),[a,l]=i.useState(!1),c=async d=>{if(d.preventDefault(),!(!o.trim()||a)){l(!0);try{await t(o)}finally{l(!1)}}};return n.jsxs("div",{className:"relative h-dvh overflow-hidden bg-background text-foreground",children:[n.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_top,_hsl(var(--primary)/0.10),_transparent_38%),radial-gradient(circle_at_bottom_right,_hsl(var(--muted-foreground)/0.08),_transparent_30%)]"}),n.jsx("div",{className:"relative flex h-full items-center justify-center overflow-hidden p-4 sm:p-5",children:n.jsxs("div",{className:"w-full max-w-md rounded-[28px] border border-border/70 bg-card/95 p-6 shadow-[0_24px_80px_rgba(15,23,42,0.10)] backdrop-blur-sm",children:[n.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[n.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:n.jsx(Jo,{className:"h-6 w-6"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-xl font-semibold",children:e("lanAccess.title")}),n.jsx("p",{className:"text-sm text-muted-foreground",children:e("lanAccess.subtitle")})]})]}),n.jsxs("form",{className:"space-y-4",onSubmit:c,children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-sm font-medium text-foreground",htmlFor:"lan-access-password",children:e("lanAccess.placeholder")}),n.jsxs("div",{className:"relative",children:[n.jsx(Ru,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(Ln,{id:"lan-access-password",type:"password",value:o,onChange:d=>s(d.target.value),placeholder:e("lanAccess.placeholder"),className:"h-12 rounded-2xl border-border bg-background pl-10 text-foreground placeholder:text-muted-foreground"})]})]}),r?n.jsx("div",{className:"rounded-2xl border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:r}):n.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/40 px-3 py-2 text-sm text-muted-foreground",children:e("lanAccess.hint")}),n.jsx(Le,{className:"h-12 w-full rounded-2xl text-base font-medium",disabled:a,children:e(a?"lanAccess.submitting":"lanAccess.submit")})]})]})})]})}const bv=()=>n.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"flex justify-center mb-4",children:n.jsx("img",{src:"/logo-128.png",alt:"Logo",className:"w-16 h-16 rounded-lg shadow-sm"})}),n.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Axhub Genie"}),n.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[n.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),n.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),n.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),n.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),wv=({children:e})=>{const{user:t,isLoading:r}=Os();return r?n.jsx(bv,{}):t?e:n.jsx(yv,{})};function sr(e,t){const[r,o]=i.useState(()=>{if(typeof window>"u")return t;try{const a=window.localStorage.getItem(e);return a?JSON.parse(a):t}catch(a){return console.log(a),t}});return[r,a=>{if(!(typeof window>"u"))try{const l=a instanceof Function?a(r):a;window.localStorage.setItem(e,JSON.stringify(l)),o(l)}catch(l){console.log(l)}}]}const kv=3e3;function ar(e){return typeof e=="string"&&e.trim().length>0}function jv(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function Sv(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function Nv({enabled:e,channel:t,clientId:r,sessionId:o}){const s=i.useRef(null),a=i.useRef(null),l=i.useRef(!1),c=i.useRef(!1),d=i.useRef(0),u=i.useRef(ar(o)?o.trim():null),[p,m]=i.useState(null),[f,x]=i.useState(!1),h=i.useMemo(()=>e===!0&&ar(t)&&ar(r),[e,t,r]);i.useEffect(()=>{u.current=ar(o)?o.trim():null},[o]);const N=i.useCallback(z=>{d.current+=1,m({...z,__messageSeq:d.current})},[]),w=i.useCallback(()=>{const z=s.current;z&&(z.close(),s.current=null),x(!1),l.current=!1},[]),S=i.useCallback((z,R=s.current)=>!z||!R||R.readyState!==WebSocket.OPEN?!1:(R.send(JSON.stringify({type:"integration.ack",requestId:z,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),$=i.useCallback((z=s.current)=>{!h||!z||z.readyState!==WebSocket.OPEN||z.send(JSON.stringify({type:"integration.connect",requestId:jv("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:r.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:ar(o)?o.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[t,r,h,o]),F=i.useCallback(()=>{if(!h||c.current||l.current)return;const z=s.current;if(z&&(z.readyState===WebSocket.OPEN||z.readyState===WebSocket.CONNECTING))return;const R=Sv();if(!R)return;l.current=!0;const E=new WebSocket(R);s.current=E,E.onopen=()=>{l.current=!1,s.current=E,x(!0),$(E)},E.onmessage=B=>{try{const I=JSON.parse(B.data);I&&typeof I.type=="string"&&I.type.startsWith("integration.")&&(I.type==="integration.ping"&&S(I.requestId||null,E),N(I))}catch(I){console.error("Error parsing integration WebSocket message:",I)}},E.onclose=()=>{s.current===E&&(s.current=null),l.current=!1,x(!1),!c.current&&h&&(a.current=setTimeout(()=>{a.current=null,F()},kv))},E.onerror=B=>{console.error("Integration WebSocket error:",B)}},[$,N,h,S]);i.useEffect(()=>{if(c.current=!1,!h){a.current&&(clearTimeout(a.current),a.current=null),w();return}return F(),()=>{a.current&&(clearTimeout(a.current),a.current=null),w()}},[w,F,h]),i.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),w()},[w]),i.useEffect(()=>{h&&$()},[$,h,o]);const Z=i.useCallback(z=>{const R=s.current;return!R||R.readyState!==WebSocket.OPEN?!1:(R.send(JSON.stringify(z)),!0)},[]);return{integrationWs:s.current,latestIntegrationMessage:p,sendIntegrationMessage:Z,isIntegrationConnected:f,isIntegrationEnabled:h}}const Cv=["cwd","workdir","project","context","prompt","model","integrationWs"];function Ev(e){return e instanceof URLSearchParams?e:typeof e=="string"?new URLSearchParams(e):new URLSearchParams}function xs(e,t,r={},o={}){const s=typeof e=="string"&&e?e:"/",a=Ev(t),l=new URLSearchParams,c=Array.isArray(o?.persistedKeys)&&o.persistedKeys.length>0?o.persistedKeys:Cv;for(const u of c){const p=a.get(u);p&&l.set(u,p)}for(const[u,p]of Object.entries(r||{})){if(p==null||p===""){l.delete(u);continue}l.set(u,String(p))}const d=l.toString();return d?`${s}?${d}`:s}const _v="axhub",ri="axhub-genie.integrationClientId";function xc(e){return typeof e=="string"&&e.trim().length>0}function oi(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`frontend-${crypto.randomUUID()}`:`frontend-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Av(e,t){return e!=="1"?null:xc(t)?t.trim():_v}function Iv(e,t=null){if(e!=="1")return null;const r=t&&typeof t.getItem=="function"&&typeof t.setItem=="function"?t:null;if(!r)return oi();const o=r.getItem(ri);if(xc(o))return o.trim();const s=oi();return r.setItem(ri,s),s}function Tv(){if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}}const Pv=new Set(["claude","codex","gemini","opencode"]);function Fs(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();if(!t)return null;const r=t==="openai"?"codex":t;return Pv.has(r)?r:null}function gc({provider:e,sessionId:t}){const r=Fs(e),o=typeof t=="string"&&t.trim()?t.trim():"";return!r||!o?null:`/session/${r}/${encodeURIComponent(o)}`}function si(e,t){const r=gc(e);if(!r)return null;const o=e?.projectPath||e?.cwd||e?.project||null;return xs(r,t,o?{cwd:o,project:o}:{})}function Rv({isMobile:e,currentProjectName:t,sessionProjectName:r}){return e?r!==t:!1}function Mv({sidebarVisible:e=!0}={}){return["chat-sidebar",e?null:"relative z-20","h-full","flex-shrink-0",e?"overflow-hidden":"overflow-visible","transition-all","duration-300",e?"w-[22rem]":"w-[4.25rem]"].filter(Boolean).join(" ")}function Dv({sidebarVisible:e=!0}={}){return["h-full",e?"overflow-hidden":"overflow-visible"].join(" ")}function Lv({isLoadingProjects:e,hasSelectedProject:t,hasSessionRoute:r,sessionRouteStatus:o}){return t?!1:e?!0:!!(r&&o!=="missing"&&o!=="error")}function Ov({requestToken:e,activeRequestToken:t,pathname:r,provider:o,sessionId:s}){if(!e||!t||e!==t||typeof r!="string"||typeof s!="string"||!s)return!1;const a=gc({provider:Fs(o),sessionId:s});return!!(a&&r===a)}function Fv({activeResolution:e,sessionId:t,resolutionKey:r}){return!e||typeof e!="object"?!0:!(e.sessionId===t&&e.status==="resolving"&&e.resolutionKey===r)}const ai="lastSelectedProject",ii="lastSelectedSession";function $v(e){return!e||typeof e!="object"?[]:[...e.sessions||[],...e.codexSessions||[],...e.geminiSessions||[],...e.opencodeSessions||[]]}function vc(e,t){return e?.name!==t?.name||e?.displayName!==t?.displayName||e?.fullPath!==t?.fullPath||e?.path!==t?.path||e?.isCustomName!==t?.isCustomName||e?.isManuallyAdded!==t?.isManuallyAdded}function li(e,t=null){const r=!!t?.detailsLoaded;return{...e,detailsLoaded:r,sessions:r?t?.sessions||[]:[],codexSessions:r?t?.codexSessions||[]:[],geminiSessions:r?t?.geminiSessions||[]:[],opencodeSessions:r?t?.opencodeSessions||[]:[],sessionMeta:r?t?.sessionMeta||{hasMore:!1,total:0}:null}}function ci(e,t){const r=new Map(e.map(a=>[a.name,a])),o=t.map(a=>{const l=r.get(a.name);return l?vc(l,a)?li(a,l):l:li(a)});return o.length!==e.length||o.some((a,l)=>a!==e[l])?o:e}function zv(e,t){let r=!1;const o=e.map(s=>s.name!==t.name?s:(r=!0,{...s,...t,sessions:t.sessions||[],codexSessions:t.codexSessions||[],geminiSessions:t.geminiSessions||[],opencodeSessions:t.opencodeSessions||[],sessionMeta:t.sessionMeta||{hasMore:!1,total:0},detailsLoaded:!0}));return r?o:e}function Bv(e){return e?.name?{name:e.name,displayName:e.displayName||e.name,fullPath:e.fullPath||e.path||null,path:e.path||e.fullPath||null}:null}function Uv(e){return e?.id?{id:e.id,title:e.title||e.summary||e.name||"New Session",provider:e.__provider||"claude",projectName:e.__projectName||null}:null}function di(){const e=ld(),t=cd(),{provider:r,sessionId:o}=dd(),[s]=ud(),{t:a}=Et("common"),{isDarkMode:l}=vs();i.useRef(0);const{updateAvailable:c,latestVersion:d,currentVersion:u,releaseInfo:p}=uc(),[m,f]=i.useState(!1),[x,h]=i.useState([]),[N,w]=i.useState(null),[S,$]=i.useState(null),[F,Z]=i.useState({}),[z,R]=i.useState(0),[E,B]=i.useState("chat"),[I,Y]=i.useState(!1),_=I&&!1,[re,ie]=i.useState(!1),[V,ae]=i.useState(!0),[de,ve]=i.useState(null),[fe,U]=i.useState(!1),[le,oe]=i.useState(!1),[Te,te]=i.useState("appearance"),[Q,we]=i.useState(!1),[Ie]=sr("autoExpandTools",!1),[ye]=sr("showRawParameters",!1),[Oe]=sr("showThinking",!0),Be=!1,[$e]=sr("sendByCtrlEnter",!1),[he,et]=sr("sidebarVisible",!0),[_e,Xe]=i.useState(!1),[Fe,Re]=i.useState(new Set),[ut,tt]=i.useState(new Set),Ue=i.useRef({sessionId:null,status:"idle"}),We=i.useRef(0),[ot,Me]=i.useState("idle"),st=i.useCallback((k,W="claude")=>{if(!k)return W;try{const X=localStorage.getItem("session-provider-map");if(!X)return W;const je=JSON.parse(X)?.[k];return typeof je=="string"&&je?je:W}catch{return W}},[]),[C,T]=i.useState(0),me=i.useRef({selectionKey:null}),xe=i.useRef({attemptedKeys:new Set}),y=i.useRef(x),D=i.useRef(N),H=i.useRef(S),L=s.get("cwd")||s.get("workdir"),O=i.useMemo(()=>Dn(L),[L]),ne=s.get("project")||s.get("projectName"),ke=i.useMemo(()=>Fs(r),[r]);s.get("model");const Ge=s.get("context"),at=s.get("prompt"),pe=s.get("integrationWs"),ze=s.get("slashCommands"),Je=i.useMemo(()=>Tv(),[]),it=i.useMemo(()=>Iv(pe,Je),[Je,pe]),Ct=i.useMemo(()=>Av(pe,L),[L,pe]),Mt=s.toString(),M=x.find(k=>!!(dr(k,O)||ne&&(k.fullPath===ne||k.path===ne)))?.name||null,G=i.useMemo(()=>Mf({updateAvailable:c}),[c]),be=(k,W)=>!k||!W?k!==W:vc(k,W)||!!k.detailsLoaded!=!!W.detailsLoaded,b=k=>{if(!k)return!1;if(o===k)return!0;const W=Ue.current;return W?.sessionId===k&&W?.status!=="missing"&&W?.status!=="error"?!0:Fe.has(k)||ut.has(k)},J=i.useCallback(k=>{if(!k?.name)return;const W=D.current,X=H.current;if(W?.name===k.name&&W!==k&&(be(W,k)||!W.detailsLoaded&&k.detailsLoaded)&&w(k),!X||X.__projectName!==k.name||!k.detailsLoaded)return;const Ce=$v(k).find(Ye=>Ye.id===X.id);if(!Ce){b(X.id)||$(null);return}const je={...Ce,__provider:X.__provider||st(Ce.id,"claude"),__projectName:k.name};(je.title!==X.title||je.summary!==X.summary||je.updated_at!==X.updated_at||je.lastActivity!==X.lastActivity||je.__provider!==X.__provider||je.__projectName!==X.__projectName)&&$(je)},[st,b]),ee=i.useCallback(async(k,W={})=>{const{background:X=!1,force:Ce=!1}=W;if(!k)return null;const je=y.current.find(Ye=>Ye.name===k);if(!Ce&&je?.detailsLoaded)return je;if(F[k])return null;Z(Ye=>({...Ye,[k]:!0}));try{const Ye=await mt.projectDetails(k);if(!Ye.ok){if(Ye.status===404)return h($t=>$t.filter(nt=>nt.name!==k)),null;throw new Error(`Failed to load project details: ${Ye.status}`)}const rt=await Ye.json();h($t=>zv($t,rt));const kt={...je,...rt,detailsLoaded:!0};return J(kt),kt}catch(Ye){return console.error(`Error loading details for project ${k}:`,Ye),null}finally{Z(Ye=>{const rt={...Ye};return delete rt[k],rt})}},[F,J]),Ae=i.useCallback(async(k={})=>{const{background:W=!1}=k;try{W||ae(!0);const Ce=await(await mt.projectsList()).json();h(je=>ci(je,Ce))}catch(X){console.error("Error fetching projects:",X)}finally{W||ae(!1)}},[]),Qe=i.useCallback((k,W)=>{const X=xs(k,s);t(X,W)},[t,s]),j=i.useCallback(k=>{const W=xs("/",s,{},{persistedKeys:["integrationWs"]});t(W,k)},[t,s]),ue=i.useCallback((k,W)=>{const X=si(k,s);return X?(t(X,W),!0):(console.warn("Skipping session navigation because provider or session id is missing.",k),!1)},[t,s]),ge=i.useCallback(()=>{We.current+=1,Ue.current={sessionId:null,status:"idle"},Me("idle")},[]),{ws:Ne,sendMessage:He,latestMessage:Ze}=hv(),{latestIntegrationMessage:Dt,sendIntegrationMessage:De}=Nv({enabled:pe==="1",clientId:it,channel:Ct,sessionId:S?.id||o||null}),Lt=i.useCallback(k=>lr(k),[]),jt=i.useRef(null),[K,Ot]=i.useState(!1);i.useEffect(()=>{const k=cc(E);k!==E&&B(k)},[E]),i.useEffect(()=>{const k=()=>{const W=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");Ot(W),document.addEventListener("touchstart",{}),W?(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 k(),window.matchMedia("(display-mode: standalone)").addEventListener("change",k),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",k)}},[]),i.useEffect(()=>{const k=()=>{Y(window.innerWidth<768)};return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[]),i.useEffect(()=>{Ae()},[Ae]),i.useEffect(()=>{o||ge()},[ge,o]),i.useEffect(()=>{y.current=x},[x]),i.useEffect(()=>{D.current=N},[N]),i.useEffect(()=>{H.current=S},[S]),i.useEffect(()=>{try{const k=Bv(N);k?localStorage.setItem(ai,JSON.stringify(k)):localStorage.removeItem(ai);const W=Uv(S);W?localStorage.setItem(ii,JSON.stringify(W)):localStorage.removeItem(ii)}catch(k){console.warn("Failed to persist last selected project/session:",k)}},[N,S]),i.useEffect(()=>{if(!O&&!ne||x.length===0)return;const k=`${O||""}::${ne||""}`;if(me.current.selectionKey===k)return;if(S){me.current.selectionKey=k;return}let W=null;if(O&&(W=x.find(X=>dr(X,O))),!W&&ne){const X=ne.trim().toLowerCase();W=x.find(Ce=>[Ce.name,Ce.displayName,Ce.path,Ce.fullPath].some(Ye=>typeof Ye=="string"&&Ye.toLowerCase()===X))}W&&w(W),me.current.selectionKey=k},[O,ne,x,S]),i.useEffect(()=>{if(!N?.name||x.length===0)return;const k=x.find(W=>W.name===N.name);if(!k){!o&&!O&&!ne&&(w(null),S?.__projectName===N.name&&$(null));return}k!==N&&be(N,k)&&w(k),!k.detailsLoaded&&!F[k.name]&&ee(k.name,{background:!0})},[ee,O,F,x,ne,N,S?.__projectName,o]),i.useEffect(()=>{if(!O||V||S||y.current.some(je=>dr(je,O)))return;const W=`cwd:${O}`;if(xe.current.attemptedKeys.has(W))return;xe.current.attemptedKeys.add(W);let X=!1;return(async()=>{try{const je=await mt.createProject(O),Ye=await je.json().catch(()=>({}));if(!je.ok){const rt=Ye?.error||"Unknown error";if(rt.includes("Project already configured")){await Ae();return}console.warn(`[URL] Failed to auto-create project for cwd "${O}": ${rt}`);return}if(X)return;Ye?.project&&w(Ye.project),await Ae()}catch(je){console.error(`[URL] Error auto-creating project for cwd "${O}":`,je)}})(),()=>{X=!0}},[O,V,S]),i.useEffect(()=>{if(Ze){if(Ze.type==="loading_progress"){jt.current&&(clearTimeout(jt.current),jt.current=null),ve(Ze),Ze.phase==="complete"&&(jt.current=setTimeout(()=>{ve(null),jt.current=null},500));return}if(Ze.type==="projects_updated"){if(Ze.changedFile&&S&&N){const St=Ze.changedFile.replace(/\\/g,"/").split("/"),ht=St[St.length-1]||"",yt=ht.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]||ht.replace(".jsonl","");(Ze.changedSessionId||yt)===S.id&&(Fe.has(S.id)||T(wn=>wn+1))}const k=Array.isArray(Ze.projects)?Ze.projects:[];h(nt=>ci(nt,k));const W=D.current,X=H.current,Ce=W?k.find(nt=>nt.name===W.name):null;if(W&&!Ce&&!b(X?.id)){w(null),$(null);return}const je=X&&Fe.has(X.id)||Fe.size>0&&Array.from(Fe).some(nt=>lr(nt)),Ye=Ze.affectedProjectName||null;if(!!!((Ye?y.current.find(nt=>nt.name===Ye&&nt.detailsLoaded):null)&&Ze.requiresDetailsRefresh))return;const $t=W?.name===Ye;if(je&&$t)return;ee(Ye,{background:!0,force:!0})}}return()=>{jt.current&&(clearTimeout(jt.current),jt.current=null)}},[Fe,Ze,ee,ut,N,S,o,b]),window.refreshProjects=(k={})=>Ae({background:!0,...k}),window.openSettings=i.useCallback((k="appearance")=>{te(k),oe(!0)},[]),i.useEffect(()=>{if(!o)return;const k=S?.id||null,W=k!==o;if(!ke){Ue.current={sessionId:o,status:"error"},Me("error");return}const X=`${o}::${Mt}`,Ce=Lt(o),je=Dl({projects:x,queryProject:ne,queryCwd:O}),Ye=(ht,yt,bn)=>{if(!ht||!yt)return!1;const Ht=x.find(lt=>lt.name===ht.name)||ht,It={...yt,__provider:bn||ke,__projectName:Ht.name};return w(lt=>lt?.name===Ht.name?lt:Ht),$(lt=>lt?.id===It.id&&lt?.__provider===It.__provider&&lt?.__projectName===It.__projectName?lt:It),ee(Ht.name,{background:!0}),W&&B("chat"),Ue.current={sessionId:o,status:"resolved",resolutionKey:X},Me("resolved"),!0};if(k===o&&N?.name&&(!S?.__provider||S.__provider===ke)){Ue.current={sessionId:o,status:"resolved",resolutionKey:X},Me("resolved"),W&&B("chat");return}const rt=Jh(x,o,{provider:ke,projectPath:ne||O||null});if(rt){Ye(rt.project,rt.session,rt.provider);return}if(Yh({projects:x,queryProject:ne,queryCwd:O})){je?.name&&!F[je.name]&&ee(je.name,{background:!0}),Ue.current={sessionId:o,status:"awaiting-project-details",resolutionKey:X},Me("awaiting-project-details");return}const kt=je;if(kt?(w(ht=>ht?.name===kt.name?ht:kt),$({id:o,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:ke,__projectName:kt.name}),W&&B("chat"),Ue.current={sessionId:o,status:"placeholder",resolutionKey:X},Me("placeholder")):(w(null),$(null)),Ce||Ue.current.sessionId===o&&Ue.current.status==="resolving"&&Ue.current.resolutionKey===X)return;const $t=We.current+1;We.current=$t,Ue.current={sessionId:o,status:"resolving",resolutionKey:X},Me("resolving");let nt=!1;return(async()=>{try{const ht=await mt.resolveSession(ke,o),yt=await ht.json().catch(()=>({}));if(nt||!Ov({requestToken:$t,activeRequestToken:We.current,pathname:e.pathname,provider:ke,sessionId:o}))return;if(!ht.ok||!yt?.found||!yt?.project||!yt?.session){Ue.current={sessionId:o,status:"missing",resolutionKey:X},Me("missing");return}if(yt?.provider)try{const It=localStorage.getItem("session-provider-map"),lt=It?JSON.parse(It):{};lt[o]=yt.provider,localStorage.setItem("session-provider-map",JSON.stringify(lt))}catch{}if(!Ye(yt.project,yt.session,yt.provider||ke))return;const Ht=si({provider:yt.provider||ke,sessionId:o},s),wn=`${window.location.pathname}${window.location.search}`;Ht&&Ht!==wn&&t(Ht,{replace:!0})}catch(ht){nt||(console.error("Error resolving session route:",ht),Ue.current={sessionId:o,status:"error",resolutionKey:X},Me("error"))}})(),()=>{Fv({activeResolution:Ue.current,sessionId:o,resolutionKey:X})&&(nt=!0)}},[Lt,ee,e.pathname,t,O,F,x,ne,ke,s,Mt,S?.id,o]);const un=k=>{ge(),w(k),$(null),ee(k.name,{background:!0}),j()},vn=k=>{ge();let W=null;k.__projectName&&(W=y.current.find(X=>X.name===k.__projectName)||null,W&&w(W)),$(k),E!=="preview"&&B("chat"),Rv({isMobile:I,sessionProjectName:k.__projectName,currentProjectName:N?.name})&&ie(!1),ue({provider:k.__provider||k.provider||null,sessionId:k.id})},en=k=>{if(ge(),k?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${k.name}`),localStorage.removeItem(`draft_input_${k.name}`)}catch(W){console.warn("Failed to clear local chat cache for new session:",W)}w(k),$(null),R(W=>W+1),B("chat"),j(),I&&ie(!1)},tn=k=>{S?.id===k&&(ge(),$(null),Qe("/")),h(W=>W.map(X=>({...X,sessions:X.sessions?.filter(Ce=>Ce.id!==k)||[],codexSessions:X.codexSessions?.filter(Ce=>Ce.id!==k)||[],geminiSessions:X.geminiSessions?.filter(Ce=>Ce.id!==k)||[],opencodeSessions:X.opencodeSessions?.filter(Ce=>Ce.id!==k)||[],sessionMeta:X.sessionMeta?{...X.sessionMeta,total:Math.max(0,(X.sessionMeta?.total||0)-1)}:X.sessionMeta})))},nn=async()=>{try{await Ae({background:!0});const k=Array.from(new Set([...y.current.filter(W=>W.detailsLoaded).map(W=>W.name),D.current?.name||null].filter(Boolean)));await Promise.all(k.map(W=>ee(W,{background:!0,force:!0})))}catch(k){console.error("Error refreshing sidebar:",k)}},_t=k=>{N?.name===k&&(ge(),w(null),$(null),Qe("/")),h(W=>W.filter(X=>X.name!==k))},Bn=i.useCallback((k,W)=>{h(X=>X.map(Ce=>Ce.name===k?{...Ce,displayName:W,isCustomName:!0}:Ce)),w(X=>!X||X.name!==k?X:{...X,displayName:W,isCustomName:!0})},[]),yn=i.useCallback(k=>{k&&Re(W=>new Set([...W,k]))},[]),Se=i.useCallback(k=>{k&&Re(W=>{const X=new Set(W);return X.delete(k),X})},[]),pn=i.useCallback(k=>{k&&tt(W=>new Set([...W,k]))},[]),Cn=i.useCallback(k=>{k&&tt(W=>{const X=new Set(W);return X.delete(k),X})},[]),En=i.useCallback((k,W=null)=>{k&&(Re(X=>{const Ce=new Set;for(const je of X)W&&je===W||lr(je)||Ce.add(je);return Ce.add(k),Ce}),tt(X=>{const Ce=new Set;for(const je of X)W&&je===W||lr(je)||Ce.add(je);return Ce.add(k),Ce}))},[]),Ft=()=>{const{t:k}=Et("common"),[W,X]=i.useState(!1),[Ce,je]=i.useState(""),[Ye,rt]=i.useState("");if(!m)return null;const kt=nt=>nt?nt.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,`
249
+
250
+ `).trim():"",$t=async()=>{X(!0),je(`Starting update...
251
+ `),rt("");try{const nt=await Kt("/api/system/update",{method:"POST"}),St=await nt.json();nt.ok?(je(ht=>ht+St.output+`
252
+ `),je(ht=>ht+`
253
+ ✅ Update completed successfully!
254
+ `),je(ht=>ht+`Please restart the server to apply changes.
255
+ `)):(rt(St.error||"Update failed"),je(ht=>ht+`
256
+ ❌ Update failed: `+(St.error||"Unknown error")+`
257
+ `))}catch(nt){rt(nt.message),je(St=>St+`
258
+ ❌ Update failed: `+nt.message+`
259
+ `)}finally{X(!1)}};return n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[n.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>f(!1),"aria-label":k("versionUpdate.ariaLabels.closeModal")}),n.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:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 bg-primary/15 dark:bg-primary/25 rounded-lg flex items-center justify-center",children:n.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:k("versionUpdate.title")}),n.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:p?.title||k("versionUpdate.newVersionReady")})]})]}),n.jsx("button",{onClick:()=>f(!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:n.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[n.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:k("versionUpdate.currentVersion")}),n.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:u})]}),n.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:[n.jsx("span",{className:"text-sm font-medium text-primary",children:k("versionUpdate.latestVersion")}),n.jsx("span",{className:"text-sm text-primary font-mono",children:d})]})]}),p?.body&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:k("versionUpdate.whatsNew")}),p?.htmlUrl&&n.jsxs("a",{href:p.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:text-primary hover:underline flex items-center gap-1",children:[k("versionUpdate.viewFullRelease"),n.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.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"})})]})]}),n.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:n.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:kt(p.body)})})]}),Ce&&n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:k("versionUpdate.updateProgress")}),n.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:n.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap",children:Ce})})]}),!W&&!Ce&&n.jsxs("div",{className:"space-y-3",children:[n.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:k("versionUpdate.manualUpgrade")}),n.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:n.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"npm install -g @axhub/genie@latest"})}),n.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:k("versionUpdate.manualUpgradeHint")})]}),n.jsxs("div",{className:"flex gap-2 pt-2",children:[n.jsx("button",{onClick:()=>f(!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:k(Ce?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!Ce&&n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>{navigator.clipboard.writeText("npm install -g @axhub/genie@latest")},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:k("versionUpdate.buttons.copyCommand")}),n.jsx("button",{onClick:$t,disabled:W,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:W?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),k("versionUpdate.buttons.updating")]}):k("versionUpdate.buttons.updateNow")})]})]})]})]})};return n.jsxs("div",{className:"chat-app-shell fixed inset-0 flex overflow-hidden bg-background",style:{"--mobile-nav-total":"0px"},children:[!I&&n.jsx("div",{className:Mv({sidebarVisible:he}),children:n.jsx("div",{className:Dv({sidebarVisible:he}),children:he?n.jsx(la,{projects:x,selectedProject:N,selectedSession:S,onProjectSelect:un,onProjectRename:Bn,onSessionSelect:vn,onNewSession:en,onSessionDelete:tn,onProjectDelete:_t,isLoading:V,projectDetailsLoading:F,loadingProgress:de,onProjectExpand:ee,onRefresh:nn,onShowSettings:()=>oe(!0),updateAvailable:c,latestVersion:d,currentVersion:u,releaseInfo:p,onShowVersionModal:()=>f(!0),isPWA:K,isMobile:I,onToggleSidebar:()=>et(!1),lockedProjectName:M,showNewProject:_e,setShowNewProject:Xe,onOpenCcConnectDialog:()=>we(!0)}):n.jsx("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:G.map(k=>{const W=N||x[0]||null,X="relative flex items-center justify-center p-1.5 text-muted-foreground transition-colors duration-200 hover:text-foreground disabled:pointer-events-none disabled:opacity-50";if(k===bt.SHOW_SIDEBAR)return n.jsx("button",{onClick:()=>et(!0),className:X,"aria-label":a("versionUpdate.ariaLabels.showSidebar"),title:a("versionUpdate.ariaLabels.showSidebar"),children:n.jsx(yi,{className:"w-4 h-4"})},k);if(k===bt.NEW_SESSION)return n.jsx(ln,{content:a("sidebar:sessions.newSession"),position:"right",delay:150,children:n.jsx("button",{onClick:()=>W&&en(W),className:X,"aria-label":a("sidebar:sessions.newSession"),title:a("sidebar:sessions.newSession"),disabled:!W||V,children:n.jsx(hr,{className:"w-4 h-4"})})},k);if(k===bt.REMOTE_ACCESS)return n.jsx(ln,{content:a("sidebar:ccConnect.actions.open"),position:"right",delay:150,children:n.jsx("button",{onClick:()=>we(!0),className:X,"aria-label":a("sidebar:ccConnect.actions.open"),title:a("sidebar:ccConnect.actions.open"),children:n.jsx(ys,{className:"w-4 h-4"})})},k);if(k===bt.THEME_TOGGLE){const Ce=a(l?"common.lightMode":"common.darkMode");return n.jsx(ln,{content:Ce,position:"right",delay:150,children:n.jsx(hi,{variant:"icon",className:X,title:Ce})},k)}return k===bt.UPDATE_AVAILABLE?n.jsxs("button",{onClick:()=>f(!0),className:X,"aria-label":a("versionUpdate.ariaLabels.updateAvailable"),title:a("versionUpdate.ariaLabels.updateAvailable"),children:[n.jsx(Zd,{className:"w-5 h-5 text-primary"}),n.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-primary animate-pulse"})]},k):null})})})}),I&&n.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${re?"opacity-100 visible":"opacity-0 invisible"}`,children:[n.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:k=>{k.stopPropagation(),ie(!1)},onTouchStart:k=>{k.preventDefault(),k.stopPropagation(),ie(!1)},"aria-label":a("versionUpdate.ariaLabels.closeSidebar")}),n.jsx("div",{className:`chat-sidebar relative h-full w-[85vw] max-w-sm bg-white shadow-xl transform dark:bg-background sm:w-80 ${re?"translate-x-0":"-translate-x-full"}`,onClick:k=>k.stopPropagation(),onTouchStart:k=>k.stopPropagation(),children:n.jsx(la,{projects:x,selectedProject:N,selectedSession:S,onProjectSelect:un,onProjectRename:Bn,onSessionSelect:vn,onNewSession:en,onSessionDelete:tn,onProjectDelete:_t,isLoading:V,projectDetailsLoading:F,loadingProgress:de,onProjectExpand:ee,onRefresh:nn,onShowSettings:()=>oe(!0),updateAvailable:c,latestVersion:d,currentVersion:u,releaseInfo:p,onShowVersionModal:()=>f(!0),isPWA:K,isMobile:I,onToggleSidebar:()=>et(!1),lockedProjectName:M,showNewProject:_e,setShowNewProject:Xe,onOpenCcConnectDialog:()=>we(!0)})})]}),n.jsx(pv,{open:Q,onOpenChange:we,selectedProject:N,projects:x}),n.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:n.jsx(U0,{selectedProject:N,selectedSession:S,activeTab:E,setActiveTab:B,ws:Ne,sendMessage:He,latestMessage:Ze,isMobile:I,isPWA:K,onMenuClick:()=>ie(!0),isLoading:Lv({isLoadingProjects:V,hasSelectedProject:!!N,hasSessionRoute:!!o,sessionRouteStatus:ot}),onInputFocusChange:U,onSessionActive:yn,onSessionInactive:Se,onSessionProcessing:pn,onSessionNotProcessing:Cn,processingSessions:ut,onReplaceTemporarySession:En,onNavigateToSession:(k,W=null,X=null)=>{const Ce=W||H.current?.__provider||localStorage.getItem("selected-provider")||"claude",je=X||N?.fullPath||N?.path||null,Ye=N?.name||null;$(rt=>rt?.id===k&&rt?.__provider===Ce&&rt?.__projectName===Ye?rt:{id:k,title:rt?.title||"New Session",created_at:rt?.created_at||new Date().toISOString(),updated_at:new Date().toISOString(),__provider:Ce,__projectName:Ye,projectPath:je}),ue({provider:Ce,sessionId:k,projectPath:je})},onShowSettings:()=>oe(!0),autoExpandTools:Ie,showRawParameters:ye,showThinking:Oe,autoScrollToBottom:Be,sendByCtrlEnter:$e,externalMessageUpdate:C,urlContext:Ge,urlPrompt:at,urlSlashCommands:ze,integrationClientId:it,latestIntegrationMessage:Dt,sendIntegrationMessage:De,onShowNewProject:()=>Xe(!0),onNewSession:en,newSessionResetNonce:z})}),_,n.jsx(X0,{isOpen:le,onClose:()=>oe(!1),projects:x,initialTab:Te}),n.jsx(Ft,{})]})}function Qv(){return n.jsx(Yd,{i18n:ru,children:n.jsx(Xd,{children:n.jsx(fv,{children:n.jsx(vv,{children:n.jsx(wv,{children:n.jsx(ad,{basename:window.__ROUTER_BASENAME__||"",children:n.jsxs(id,{children:[n.jsx(So,{path:"/",element:n.jsx(di,{})}),n.jsx(So,{path:"/session/:provider/:sessionId",element:n.jsx(di,{})}),n.jsx(So,{path:"/review",element:n.jsx(Qd,{})})]})})})})})})})}export{Qv as default};