@axhub/genie 0.2.10 → 0.2.12
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.
- package/dist/api-docs.html +2 -2
- package/dist/assets/App-Clb2COtW.js +274 -0
- package/dist/assets/ImagePlaygroundPage-DqhMSbM8.js +106 -0
- package/dist/assets/ImagePlaygroundPage-MEn3NN80.css +1 -0
- package/dist/assets/ReviewApp-CDcLYe-u.js +1 -0
- package/dist/assets/{_basePickBy-DVVb07UV.js → _basePickBy-jUZsM51q.js} +1 -1
- package/dist/assets/{_baseUniq-BtbziL5G.js → _baseUniq-BXglE6_v.js} +1 -1
- package/dist/assets/{arc-BsCC8yBD.js → arc-D-oFCFBv.js} +1 -1
- package/dist/assets/{architectureDiagram-2XIMDMQ5-woFp6eNI.js → architectureDiagram-2XIMDMQ5-DC8bAnQt.js} +1 -1
- package/dist/assets/{blockDiagram-WCTKOSBZ-ya8VAc2k.js → blockDiagram-WCTKOSBZ-C4semIRc.js} +1 -1
- package/dist/assets/{c4Diagram-IC4MRINW-CY1dZmIZ.js → c4Diagram-IC4MRINW-FHj1QO3y.js} +1 -1
- package/dist/assets/channel-BF4woPXX.js +1 -0
- package/dist/assets/{chunk-4BX2VUAB-CR1lAd74.js → chunk-4BX2VUAB-D-LjsQ_s.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-CP98WcFC.js → chunk-55IACEB6-DI3j_d7A.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-D9c7ijAB.js → chunk-FMBD7UC4-BEVnaLFN.js} +1 -1
- package/dist/assets/{chunk-JSJVCQXG-DQAGYOn-.js → chunk-JSJVCQXG-CSxpcErk.js} +1 -1
- package/dist/assets/{chunk-KX2RTZJC-BbTXiDq7.js → chunk-KX2RTZJC-BbuhDN4h.js} +1 -1
- package/dist/assets/{chunk-NQ4KR5QH-BI6AX0dr.js → chunk-NQ4KR5QH-C3x61XQa.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-DB3V2Ifo.js → chunk-QZHKN3VN-DxWOFtPh.js} +1 -1
- package/dist/assets/{chunk-WL4C6EOR-DhzTthv6.js → chunk-WL4C6EOR-Bt2OauD2.js} +1 -1
- package/dist/assets/classDiagram-VBA2DB6C-D2kHlnQ7.js +1 -0
- package/dist/assets/classDiagram-v2-RAHNMMFH-D2kHlnQ7.js +1 -0
- package/dist/assets/clone-CqBvwCJW.js +1 -0
- package/dist/assets/{cose-bilkent-S5V4N54A-BQ09ZE2j.js → cose-bilkent-S5V4N54A-Dexadrue.js} +1 -1
- package/dist/assets/{dagre-KLK3FWXG-Dc2ueD_R.js → dagre-KLK3FWXG-F9U4X2xC.js} +1 -1
- package/dist/assets/{diagram-E7M64L7V-DP-LsQoL.js → diagram-E7M64L7V-B3V17aH3.js} +1 -1
- package/dist/assets/{diagram-IFDJBPK2-Cg6r42cB.js → diagram-IFDJBPK2-CdHAmLL1.js} +1 -1
- package/dist/assets/{diagram-P4PSJMXO-aHsfoUZE.js → diagram-P4PSJMXO-CrTNfk8K.js} +1 -1
- package/dist/assets/{erDiagram-INFDFZHY-qBXJ4aAz.js → erDiagram-INFDFZHY-vDh9SWK9.js} +1 -1
- package/dist/assets/{flowDiagram-PKNHOUZH-D_13emJM.js → flowDiagram-PKNHOUZH-DpltMg7L.js} +1 -1
- package/dist/assets/{ganttDiagram-A5KZAMGK-BvIcOLwz.js → ganttDiagram-A5KZAMGK-COTk2xur.js} +1 -1
- package/dist/assets/{gitGraphDiagram-K3NZZRJ6-ad0vvNcU.js → gitGraphDiagram-K3NZZRJ6-BNV7bvvj.js} +1 -1
- package/dist/assets/{graph-CeJCMjan.js → graph-Dkeg9oys.js} +1 -1
- package/dist/assets/{highlighted-body-TPN3WLV5-B_novwSz.js → highlighted-body-TPN3WLV5-DaiQEBwR.js} +1 -1
- package/dist/assets/index-DgGmiqsP.css +1 -0
- package/dist/assets/index-DvA901Vs.js +2 -0
- package/dist/assets/{infoDiagram-LFFYTUFH-lOxAqb3m.js → infoDiagram-LFFYTUFH-CZioW3Gt.js} +1 -1
- package/dist/assets/{ishikawaDiagram-PHBUUO56-DIr-51gj.js → ishikawaDiagram-PHBUUO56-BbqR3i1B.js} +1 -1
- package/dist/assets/{journeyDiagram-4ABVD52K-CYcIW0ZU.js → journeyDiagram-4ABVD52K-wfb-WHzl.js} +1 -1
- package/dist/assets/{kanban-definition-K7BYSVSG-C1ZK616a.js → kanban-definition-K7BYSVSG-B3c4y3VN.js} +1 -1
- package/dist/assets/{layout-CI2RM-v6.js → layout-Xr9Z2VGF.js} +1 -1
- package/dist/assets/{linear-DE7bISck.js → linear-JBmzAJtl.js} +1 -1
- package/dist/assets/{mermaid-O7DHMXV3-XxAJo8EK.js → mermaid-O7DHMXV3-fDuyNLKe.js} +238 -220
- package/dist/assets/{mindmap-definition-YRQLILUH-Dz6EFjmn.js → mindmap-definition-YRQLILUH-B5NTN_jD.js} +1 -1
- package/dist/assets/{pieDiagram-SKSYHLDU-DPpEzUed.js → pieDiagram-SKSYHLDU-CuO98GVu.js} +1 -1
- package/dist/assets/{quadrantDiagram-337W2JSQ-xdoXNet7.js → quadrantDiagram-337W2JSQ-LL3f4vLf.js} +1 -1
- package/dist/assets/{requirementDiagram-Z7DCOOCP-DUq8H3CL.js → requirementDiagram-Z7DCOOCP-Di-2O6LH.js} +1 -1
- package/dist/assets/{sankeyDiagram-WA2Y5GQK-CmqEUxRu.js → sankeyDiagram-WA2Y5GQK-9lHqrXqR.js} +1 -1
- package/dist/assets/{sequenceDiagram-2WXFIKYE-DhtXRNiH.js → sequenceDiagram-2WXFIKYE-BQu-SoGr.js} +1 -1
- package/dist/assets/{stateDiagram-RAJIS63D-Dj0HOlbN.js → stateDiagram-RAJIS63D-BUxvd2BC.js} +1 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-CDVexTiR.js +1 -0
- package/dist/assets/{timeline-definition-YZTLITO2-DUuJzZB5.js → timeline-definition-YZTLITO2-oP47UEU6.js} +1 -1
- package/dist/assets/{treemap-KZPCXAKY-DpYBQ0qr.js → treemap-KZPCXAKY-BRjDo2aE.js} +1 -1
- package/dist/assets/{vendor-codemirror-CMHSJ_9p.js → vendor-codemirror-BiCeS-y4.js} +1 -1
- package/dist/assets/{vendor-react-xmA_f8ig.js → vendor-react-DVlYPmi3.js} +1 -1
- package/dist/assets/{vennDiagram-LZ73GAT5-DpePUyOd.js → vennDiagram-LZ73GAT5-DrRqcDqo.js} +1 -1
- package/dist/assets/{xychartDiagram-JWTSCODW-Cfp1I4_U.js → xychartDiagram-JWTSCODW-DUXrymAi.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +25 -6
- package/scripts/refresh-acp-default-capabilities.mjs +160 -0
- package/server/acp-runtime/client.js +1137 -181
- package/server/acp-runtime/command-overrides.js +48 -0
- package/server/acp-runtime/index.js +576 -16
- package/server/acp-runtime/registry.js +6 -4
- package/server/acp-runtime/session-store.js +235 -92
- package/server/database/db.js +12 -3
- package/server/external-agent/ws.js +212 -11
- package/server/index.js +156 -53
- package/server/projects-watcher-config.js +4 -0
- package/server/projects.js +485 -125
- package/server/routes/cc-connect.js +5 -4
- package/server/routes/codex.js +24 -0
- package/server/routes/commands.js +166 -10
- package/server/routes/runs.js +641 -0
- package/server/routes/session-core.js +357 -109
- package/server/session-core/eventStore.js +0 -121
- package/server/session-core/providerAdapters.js +644 -163
- package/server/session-core/providerDiscovery.js +66 -38
- package/server/session-core/runRegistry.js +244 -0
- package/server/session-core/runtimeState.js +75 -3
- package/server/session-core/runtimeWriter.js +132 -10
- package/server/utils/codexImagePlayground.js +479 -0
- package/server/utils/localTerminal.js +56 -0
- package/server/utils/shellCommand.js +70 -0
- package/shared/acpCapabilities.js +393 -0
- package/shared/acpDefaultCapabilities.generated.json +141 -0
- package/shared/conversationEvents.js +425 -121
- package/dist/assets/App-CYCCsgwf.js +0 -264
- package/dist/assets/ReviewApp-0srHIXwb.js +0 -1
- package/dist/assets/channel-BMhScXFe.js +0 -1
- package/dist/assets/classDiagram-VBA2DB6C-CMIxlWcT.js +0 -1
- package/dist/assets/classDiagram-v2-RAHNMMFH-CMIxlWcT.js +0 -1
- package/dist/assets/clone-BPqOt4r3.js +0 -1
- package/dist/assets/index-C514cLyb.js +0 -2
- package/dist/assets/index-h1DBl_g3.css +0 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-C9utf5gv.js +0 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ImagePlaygroundPage-DqhMSbM8.js","assets/vendor-codemirror-BiCeS-y4.js","assets/vendor-react-DVlYPmi3.js","assets/index-DvA901Vs.js","assets/index-DgGmiqsP.css","assets/mermaid-O7DHMXV3-fDuyNLKe.js","assets/vendor-xterm-DfaPXD3y.js","assets/ImagePlaygroundPage-MEn3NN80.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{l as fl,i as Dm,_ as Lm}from"./index-DvA901Vs.js";import{j as r}from"./vendor-codemirror-BiCeS-y4.js";import{a as i,d as Om,R as Rt,e as us,g as Vc,B as Fm,f as $m,h as Qo,u as zm,i as Bm,j as Um,k as qm}from"./vendor-react-DVlYPmi3.js";import{bJ as at,bK as ir,bL as Nr,bM as Qc,bN as tt,bO as hn,bP as Rs,bQ as Ps,bR as kn,bS as Jc,bT as Yc,bU as Wm,bV as On,bW as Km,bX as Hm,bY as Gm,bZ as Vm,b_ as Qm,b$ as Jm,c0 as Ym,c1 as Xm,c2 as Zm,c3 as ef,c4 as yt,c5 as ui,c6 as Ot,c7 as on,c8 as In,c9 as tf,ca as Ge,cb as Bt,cc as _a,cd as pi,ce as mi,cf as nf,cg as Xc,ch as rf,ci as of,cj as qe,ck as sf,cl as af,cm as lf,cn as cf,co as df,cp as uf,cq as pf,cr as mf,cs as ff,ct as hf,cu as Ra,cv as xf,cw as gf,cx as vf,cy as yf,cz as bf,cA as wf,cB as kf,cC as Sf,cD as jf,cE as Zc,cF as ed,cG as td,cH as Cf,cI as Nf,cJ as nd,cK as Ef,cL as fi,cM as If,cN as Af,cO as to,cP as rd,cQ as _f,cR as hl,cS as ps,cT as xl,cU as Rf,cV as Jn,cW as Pf,cX as od,cY as Tf,cZ as Pa,c_ as lr,c$ as Mf,d0 as Df,d1 as Lf,d2 as Of,d3 as sd,d4 as Ff,d5 as $f,d6 as zf,d7 as Bf,d8 as ua,I as Uf,T as qf,U as Wf,d9 as Kf}from"./mermaid-O7DHMXV3-fDuyNLKe.js";import{r as Hf,a as Gf,b as Vf}from"./vendor-xterm-DfaPXD3y.js";/**
|
|
3
|
+
* @license lucide-react v0.515.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const Qf=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Jf=at("arrow-left",Qf);/**
|
|
8
|
+
* @license lucide-react v0.515.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const Yf=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Xf=at("chevron-left",Yf);/**
|
|
13
|
+
* @license lucide-react v0.515.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const Zf=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],hi=at("chevron-right",Zf);/**
|
|
18
|
+
* @license lucide-react v0.515.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const eh=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],gl=at("circle-check-big",eh);/**
|
|
23
|
+
* @license lucide-react v0.515.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const th=[["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"}]],Jo=at("ellipsis",th);/**
|
|
28
|
+
* @license lucide-react v0.515.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const nh=[["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"}]],ms=at("external-link",nh);/**
|
|
33
|
+
* @license lucide-react v0.515.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const rh=[["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"}]],oh=at("eye",rh);/**
|
|
38
|
+
* @license lucide-react v0.515.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const sh=[["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"}]],ah=at("eye-off",sh);/**
|
|
43
|
+
* @license lucide-react v0.515.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const ih=[["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"}]],lh=at("file-pen-line",ih);/**
|
|
48
|
+
* @license lucide-react v0.515.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const ch=[["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"}]],dh=at("file-plus-2",ch);/**
|
|
53
|
+
* @license lucide-react v0.515.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const uh=[["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"}]],ph=at("file-search",uh);/**
|
|
58
|
+
* @license lucide-react v0.515.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const mh=[["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"}]],no=at("folder-open",mh);/**
|
|
63
|
+
* @license lucide-react v0.515.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const fh=[["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"}]],Sr=at("folder-plus",fh);/**
|
|
68
|
+
* @license lucide-react v0.515.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const hh=[["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"}]],pa=at("folder",hh);/**
|
|
73
|
+
* @license lucide-react v0.515.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const xh=[["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"}]],gh=at("hard-drive",xh);/**
|
|
78
|
+
* @license lucide-react v0.515.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const vh=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],xi=at("image-plus",vh);/**
|
|
83
|
+
* @license lucide-react v0.515.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const yh=[["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"}]],vl=at("key-round",yh);/**
|
|
88
|
+
* @license lucide-react v0.515.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const bh=[["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"}]],ad=at("key",bh);/**
|
|
93
|
+
* @license lucide-react v0.515.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const wh=[["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"}]],kh=at("languages",wh);/**
|
|
98
|
+
* @license lucide-react v0.515.0 - ISC
|
|
99
|
+
*
|
|
100
|
+
* This source code is licensed under the ISC license.
|
|
101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
+
*/const Sh=[["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"}]],yl=at("list-todo",Sh);/**
|
|
103
|
+
* @license lucide-react v0.515.0 - ISC
|
|
104
|
+
*
|
|
105
|
+
* This source code is licensed under the ISC license.
|
|
106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
+
*/const jh=[["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"}]],Ch=at("lock-keyhole",jh);/**
|
|
108
|
+
* @license lucide-react v0.515.0 - ISC
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the ISC license.
|
|
111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
+
*/const Nh=[["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"}]],gi=at("message-square",Nh);/**
|
|
113
|
+
* @license lucide-react v0.515.0 - ISC
|
|
114
|
+
*
|
|
115
|
+
* This source code is licensed under the ISC license.
|
|
116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
+
*/const Eh=[["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"}]],bl=at("pen-line",Eh);/**
|
|
118
|
+
* @license lucide-react v0.515.0 - ISC
|
|
119
|
+
*
|
|
120
|
+
* This source code is licensed under the ISC license.
|
|
121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
+
*/const Ih=[["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"}]],wl=at("pen",Ih);/**
|
|
123
|
+
* @license lucide-react v0.515.0 - ISC
|
|
124
|
+
*
|
|
125
|
+
* This source code is licensed under the ISC license.
|
|
126
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
+
*/const Ah=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fo=at("plus",Ah);/**
|
|
128
|
+
* @license lucide-react v0.515.0 - ISC
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the ISC license.
|
|
131
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
+
*/const _h=[["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"}]],Yo=at("qr-code",_h);/**
|
|
133
|
+
* @license lucide-react v0.515.0 - ISC
|
|
134
|
+
*
|
|
135
|
+
* This source code is licensed under the ISC license.
|
|
136
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
+
*/const Rh=[["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"}]],Ta=at("refresh-cw",Rh);/**
|
|
138
|
+
* @license lucide-react v0.515.0 - ISC
|
|
139
|
+
*
|
|
140
|
+
* This source code is licensed under the ISC license.
|
|
141
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
+
*/const Ph=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],Th=at("send-horizontal",Ph);/**
|
|
143
|
+
* @license lucide-react v0.515.0 - ISC
|
|
144
|
+
*
|
|
145
|
+
* This source code is licensed under the ISC license.
|
|
146
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
+
*/const Mh=[["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"}]],Dh=at("settings",Mh);/**
|
|
148
|
+
* @license lucide-react v0.515.0 - ISC
|
|
149
|
+
*
|
|
150
|
+
* This source code is licensed under the ISC license.
|
|
151
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
+
*/const Lh=[["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"}]],Ma=at("shield-check",Lh);/**
|
|
153
|
+
* @license lucide-react v0.515.0 - ISC
|
|
154
|
+
*
|
|
155
|
+
* This source code is licensed under the ISC license.
|
|
156
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
+
*/const Oh=[["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"}]],Fh=at("shield",Oh);/**
|
|
158
|
+
* @license lucide-react v0.515.0 - ISC
|
|
159
|
+
*
|
|
160
|
+
* This source code is licensed under the ISC license.
|
|
161
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
+
*/const $h=[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],zh=at("square-arrow-out-up-right",$h);/**
|
|
163
|
+
* @license lucide-react v0.515.0 - ISC
|
|
164
|
+
*
|
|
165
|
+
* This source code is licensed under the ISC license.
|
|
166
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
+
*/const Bh=[["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"}]],id=at("square-terminal",Bh);/**
|
|
168
|
+
* @license lucide-react v0.515.0 - ISC
|
|
169
|
+
*
|
|
170
|
+
* This source code is licensed under the ISC license.
|
|
171
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
+
*/const Uh=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],qh=at("square",Uh);/**
|
|
173
|
+
* @license lucide-react v0.515.0 - ISC
|
|
174
|
+
*
|
|
175
|
+
* This source code is licensed under the ISC license.
|
|
176
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
+
*/const Wh=[["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"}]],kl=at("star",Wh);/**
|
|
178
|
+
* @license lucide-react v0.515.0 - ISC
|
|
179
|
+
*
|
|
180
|
+
* This source code is licensed under the ISC license.
|
|
181
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
+
*/const Kh=[["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"}]],qn=at("trash-2",Kh);/**
|
|
183
|
+
* @license lucide-react v0.515.0 - ISC
|
|
184
|
+
*
|
|
185
|
+
* This source code is licensed under the ISC license.
|
|
186
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
187
|
+
*/const Hh=[["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"}]],ro=at("triangle-alert",Hh);/**
|
|
188
|
+
* @license lucide-react v0.515.0 - ISC
|
|
189
|
+
*
|
|
190
|
+
* This source code is licensed under the ISC license.
|
|
191
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
192
|
+
*/const Gh=[["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"}]],Vh=at("unlink",Gh);/**
|
|
193
|
+
* @license lucide-react v0.515.0 - ISC
|
|
194
|
+
*
|
|
195
|
+
* This source code is licensed under the ISC license.
|
|
196
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
+
*/const Qh=[["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"}]],Jh=at("wifi",Qh);function Yh(e,t=[]){let n=[];function o(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:f,children:y,...v}=p,_=f?.[e]?.[d]||c,N=i.useMemo(()=>v,Object.values(v));return r.jsx(_.Provider,{value:N,children:y})};u.displayName=a+"Provider";function m(p,f){const y=f?.[e]?.[d]||c,v=i.useContext(y);if(v)return v;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,Xh(s,...t)]}function Xh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function ld(e){const t=Zh(e),n=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(tx);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return r.jsx(t,{...l,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Zh(e){const t=i.forwardRef((n,o)=>{const{children:s,...a}=n;if(i.isValidElement(s)){const l=rx(s),c=nx(a,s.props);return s.type!==i.Fragment&&(c.ref=o?ir(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 ex=Symbol("radix.slottable");function tx(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ex}function nx(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function rx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ox=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ho=ox.reduce((e,t)=>{const n=ld(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function sx(e,t){e&&Om.flushSync(()=>e.dispatchEvent(t))}function ax(e,t=[]){let n=[];function o(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:f,children:y,...v}=p,_=f?.[e]?.[d]||c,N=i.useMemo(()=>v,Object.values(v));return r.jsx(_.Provider,{value:N,children:y})};u.displayName=a+"Provider";function m(p,f){const y=f?.[e]?.[d]||c,v=i.useContext(y);if(v)return v;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,ix(s,...t)]}function ix(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function lx(e){const t=cx(e),n=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(ux);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return r.jsx(t,{...l,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function cx(e){const t=i.forwardRef((n,o)=>{const{children:s,...a}=n;if(i.isValidElement(s)){const l=mx(s),c=px(a,s.props);return s.type!==i.Fragment&&(c.ref=o?ir(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 dx=Symbol("radix.slottable");function ux(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dx}function px(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function mx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fx=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],cd=fx.reduce((e,t)=>{const n=lx(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),ma="rovingFocusGroup.onEntryFocus",hx={bubbles:!1,cancelable:!0},xo="RovingFocusGroup",[Da,dd,xx]=Qc(xo),[gx,Ts]=ax(xo,[xx]),[vx,yx]=gx(xo),ud=i.forwardRef((e,t)=>r.jsx(Da.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Da.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(bx,{...e,ref:t})})}));ud.displayName=xo;var bx=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:s=!1,dir:a,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...p}=e,f=i.useRef(null),y=hn(t,f),v=Rs(a),[_,N]=Ps({prop:l,defaultProp:c??null,onChange:d,caller:xo}),[E,z]=i.useState(!1),q=kn(u),Z=dd(n),K=i.useRef(!1),[V,T]=i.useState(0);return i.useEffect(()=>{const Y=f.current;if(Y)return Y.addEventListener(ma,q),()=>Y.removeEventListener(ma,q)},[q]),r.jsx(vx,{scope:n,orientation:o,dir:v,loop:s,currentTabStopId:_,onItemFocus:i.useCallback(Y=>N(Y),[N]),onItemShiftTab:i.useCallback(()=>z(!0),[]),onFocusableItemAdd:i.useCallback(()=>T(Y=>Y+1),[]),onFocusableItemRemove:i.useCallback(()=>T(Y=>Y-1),[]),children:r.jsx(cd.div,{tabIndex:E||V===0?-1:0,"data-orientation":o,...p,ref:y,style:{outline:"none",...e.style},onMouseDown:tt(e.onMouseDown,()=>{K.current=!0}),onFocus:tt(e.onFocus,Y=>{const D=!K.current;if(Y.target===Y.currentTarget&&D&&!E){const oe=new CustomEvent(ma,hx);if(Y.currentTarget.dispatchEvent(oe),!oe.defaultPrevented){const Q=Z().filter(le=>le.focusable),b=Q.find(le=>le.active),$=Q.find(le=>le.id===_),ee=[b,$,...Q].filter(Boolean).map(le=>le.ref.current);fd(ee,m)}}K.current=!1}),onBlur:tt(e.onBlur,()=>z(!1))})})}),pd="RovingFocusGroupItem",md=i.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:s=!1,tabStopId:a,children:l,...c}=e,d=Nr(),u=a||d,m=yx(pd,n),p=m.currentTabStopId===u,f=dd(n),{onFocusableItemAdd:y,onFocusableItemRemove:v,currentTabStopId:_}=m;return i.useEffect(()=>{if(o)return y(),()=>v()},[o,y,v]),r.jsx(Da.ItemSlot,{scope:n,id:u,focusable:o,active:s,children:r.jsx(cd.span,{tabIndex:p?0:-1,"data-orientation":m.orientation,...c,ref:t,onMouseDown:tt(e.onMouseDown,N=>{o?m.onItemFocus(u):N.preventDefault()}),onFocus:tt(e.onFocus,()=>m.onItemFocus(u)),onKeyDown:tt(e.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){m.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const E=Sx(N,m.orientation,m.dir);if(E!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let q=f().filter(Z=>Z.focusable).map(Z=>Z.ref.current);if(E==="last")q.reverse();else if(E==="prev"||E==="next"){E==="prev"&&q.reverse();const Z=q.indexOf(N.currentTarget);q=m.loop?jx(q,Z+1):q.slice(Z+1)}setTimeout(()=>fd(q))}}),children:typeof l=="function"?l({isCurrentTabStop:p,hasTabStop:_!=null}):l})})});md.displayName=pd;var wx={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function kx(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sx(e,t,n){const o=kx(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return wx[o]}function fd(e,t=!1){const n=document.activeElement;for(const o of e)if(o===n||(o.focus({preventScroll:t}),document.activeElement!==n))return}function jx(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var hd=ud,xd=md,La=["Enter"," "],Cx=["ArrowDown","PageUp","Home"],gd=["ArrowUp","PageDown","End"],Nx=[...Cx,...gd],Ex={ltr:[...La,"ArrowRight"],rtl:[...La,"ArrowLeft"]},Ix={ltr:["ArrowLeft"],rtl:["ArrowRight"]},go="Menu",[ao,Ax,_x]=Qc(go),[cr,vd]=Yh(go,[_x,Jc,Ts]),vo=Jc(),yd=Ts(),[bd,Kn]=cr(go),[Rx,yo]=cr(go),wd=e=>{const{__scopeMenu:t,open:n=!1,children:o,dir:s,onOpenChange:a,modal:l=!0}=e,c=vo(t),[d,u]=i.useState(null),m=i.useRef(!1),p=kn(a),f=Rs(s);return i.useEffect(()=>{const y=()=>{m.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>m.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),r.jsx(Yc,{...c,children:r.jsx(bd,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:u,children:r.jsx(Rx,{scope:t,onClose:i.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:f,modal:l,children:o})})})};wd.displayName=go;var Px="MenuAnchor",vi=i.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e,s=vo(n);return r.jsx(Wm,{...s,...o,ref:t})});vi.displayName=Px;var yi="MenuPortal",[Tx,kd]=cr(yi,{forceMount:void 0}),Sd=e=>{const{__scopeMenu:t,forceMount:n,children:o,container:s}=e,a=Kn(yi,t);return r.jsx(Tx,{scope:t,forceMount:n,children:r.jsx(On,{present:n||a.open,children:r.jsx(Km,{asChild:!0,container:s,children:o})})})};Sd.displayName=yi;var mn="MenuContent",[Mx,bi]=cr(mn),jd=i.forwardRef((e,t)=>{const n=kd(mn,e.__scopeMenu),{forceMount:o=n.forceMount,...s}=e,a=Kn(mn,e.__scopeMenu),l=yo(mn,e.__scopeMenu);return r.jsx(ao.Provider,{scope:e.__scopeMenu,children:r.jsx(On,{present:o||a.open,children:r.jsx(ao.Slot,{scope:e.__scopeMenu,children:l.modal?r.jsx(Dx,{...s,ref:t}):r.jsx(Lx,{...s,ref:t})})})})}),Dx=i.forwardRef((e,t)=>{const n=Kn(mn,e.__scopeMenu),o=i.useRef(null),s=hn(t,o);return i.useEffect(()=>{const a=o.current;if(a)return Hm(a)},[]),r.jsx(wi,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:tt(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Lx=i.forwardRef((e,t)=>{const n=Kn(mn,e.__scopeMenu);return r.jsx(wi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ox=ld("MenuContent.ScrollLock"),wi=i.forwardRef((e,t)=>{const{__scopeMenu:n,loop:o=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:l,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:f,onDismiss:y,disableOutsideScroll:v,..._}=e,N=Kn(mn,n),E=yo(mn,n),z=vo(n),q=yd(n),Z=Ax(n),[K,V]=i.useState(null),T=i.useRef(null),Y=hn(t,T,N.onContentChange),D=i.useRef(0),oe=i.useRef(""),Q=i.useRef(0),b=i.useRef(null),$=i.useRef("right"),L=i.useRef(0),ee=v?Vm:i.Fragment,le=v?{as:Ox,allowPinchZoom:!0}:void 0,ve=W=>{const Se=oe.current+W,Ce=Z().filter(he=>!he.disabled),Ae=document.activeElement,se=Ce.find(he=>he.ref.current===Ae)?.textValue,J=Ce.map(he=>he.textValue),pe=Qx(J,Se,se),xe=Ce.find(he=>he.textValue===pe)?.ref.current;(function he(be){oe.current=be,window.clearTimeout(D.current),be!==""&&(D.current=window.setTimeout(()=>he(""),1e3))})(Se),xe&&setTimeout(()=>xe.focus())};i.useEffect(()=>()=>window.clearTimeout(D.current),[]),Gm();const ue=i.useCallback(W=>$.current===b.current?.side&&Yx(W,b.current?.area),[]);return r.jsx(Mx,{scope:n,searchRef:oe,onItemEnter:i.useCallback(W=>{ue(W)&&W.preventDefault()},[ue]),onItemLeave:i.useCallback(W=>{ue(W)||(T.current?.focus(),V(null))},[ue]),onTriggerLeave:i.useCallback(W=>{ue(W)&&W.preventDefault()},[ue]),pointerGraceTimerRef:Q,onPointerGraceIntentChange:i.useCallback(W=>{b.current=W},[]),children:r.jsx(ee,{...le,children:r.jsx(Qm,{asChild:!0,trapped:s,onMountAutoFocus:tt(a,W=>{W.preventDefault(),T.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:r.jsx(Jm,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:f,onDismiss:y,children:r.jsx(hd,{asChild:!0,...q,dir:E.dir,orientation:"vertical",loop:o,currentTabStopId:K,onCurrentTabStopIdChange:V,onEntryFocus:tt(d,W=>{E.isUsingKeyboardRef.current||W.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(Ym,{role:"menu","aria-orientation":"vertical","data-state":Bd(N.open),"data-radix-menu-content":"",dir:E.dir,...z,..._,ref:Y,style:{outline:"none",..._.style},onKeyDown:tt(_.onKeyDown,W=>{const Ce=W.target.closest("[data-radix-menu-content]")===W.currentTarget,Ae=W.ctrlKey||W.altKey||W.metaKey,se=W.key.length===1;Ce&&(W.key==="Tab"&&W.preventDefault(),!Ae&&se&&ve(W.key));const J=T.current;if(W.target!==J||!Nx.includes(W.key))return;W.preventDefault();const xe=Z().filter(he=>!he.disabled).map(he=>he.ref.current);gd.includes(W.key)&&xe.reverse(),Gx(xe)}),onBlur:tt(e.onBlur,W=>{W.currentTarget.contains(W.target)||(window.clearTimeout(D.current),oe.current="")}),onPointerMove:tt(e.onPointerMove,io(W=>{const Se=W.target,Ce=L.current!==W.clientX;if(W.currentTarget.contains(Se)&&Ce){const Ae=W.clientX>L.current?"right":"left";$.current=Ae,L.current=W.clientX}}))})})})})})})});jd.displayName=mn;var Fx="MenuGroup",ki=i.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(ho.div,{role:"group",...o,ref:t})});ki.displayName=Fx;var $x="MenuLabel",Cd=i.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(ho.div,{...o,ref:t})});Cd.displayName=$x;var fs="MenuItem",Sl="menu.itemSelect",Ms=i.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:o,...s}=e,a=i.useRef(null),l=yo(fs,e.__scopeMenu),c=bi(fs,e.__scopeMenu),d=hn(t,a),u=i.useRef(!1),m=()=>{const p=a.current;if(!n&&p){const f=new CustomEvent(Sl,{bubbles:!0,cancelable:!0});p.addEventListener(Sl,y=>o?.(y),{once:!0}),sx(p,f),f.defaultPrevented?u.current=!1:l.onClose()}};return r.jsx(Nd,{...s,ref:d,disabled:n,onClick:tt(e.onClick,m),onPointerDown:p=>{e.onPointerDown?.(p),u.current=!0},onPointerUp:tt(e.onPointerUp,p=>{u.current||p.currentTarget?.click()}),onKeyDown:tt(e.onKeyDown,p=>{const f=c.searchRef.current!=="";n||f&&p.key===" "||La.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Ms.displayName=fs;var Nd=i.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:o=!1,textValue:s,...a}=e,l=bi(fs,n),c=yd(n),d=i.useRef(null),u=hn(t,d),[m,p]=i.useState(!1),[f,y]=i.useState("");return i.useEffect(()=>{const v=d.current;v&&y((v.textContent??"").trim())},[a.children]),r.jsx(ao.ItemSlot,{scope:n,disabled:o,textValue:s??f,children:r.jsx(xd,{asChild:!0,...c,focusable:!o,children:r.jsx(ho.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...a,ref:u,onPointerMove:tt(e.onPointerMove,io(v=>{o?l.onItemLeave(v):(l.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:tt(e.onPointerLeave,io(v=>l.onItemLeave(v))),onFocus:tt(e.onFocus,()=>p(!0)),onBlur:tt(e.onBlur,()=>p(!1))})})})}),zx="MenuCheckboxItem",Ed=i.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:o,...s}=e;return r.jsx(Pd,{scope:e.__scopeMenu,checked:n,children:r.jsx(Ms,{role:"menuitemcheckbox","aria-checked":hs(n)?"mixed":n,...s,ref:t,"data-state":Ci(n),onSelect:tt(s.onSelect,()=>o?.(hs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Ed.displayName=zx;var Id="MenuRadioGroup",[Bx,Ux]=cr(Id,{value:void 0,onValueChange:()=>{}}),Ad=i.forwardRef((e,t)=>{const{value:n,onValueChange:o,...s}=e,a=kn(o);return r.jsx(Bx,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(ki,{...s,ref:t})})});Ad.displayName=Id;var _d="MenuRadioItem",Rd=i.forwardRef((e,t)=>{const{value:n,...o}=e,s=Ux(_d,e.__scopeMenu),a=n===s.value;return r.jsx(Pd,{scope:e.__scopeMenu,checked:a,children:r.jsx(Ms,{role:"menuitemradio","aria-checked":a,...o,ref:t,"data-state":Ci(a),onSelect:tt(o.onSelect,()=>s.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Rd.displayName=_d;var Si="MenuItemIndicator",[Pd,qx]=cr(Si,{checked:!1}),Td=i.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:o,...s}=e,a=qx(Si,n);return r.jsx(On,{present:o||hs(a.checked)||a.checked===!0,children:r.jsx(ho.span,{...s,ref:t,"data-state":Ci(a.checked)})})});Td.displayName=Si;var Wx="MenuSeparator",Md=i.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(ho.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})});Md.displayName=Wx;var Kx="MenuArrow",Dd=i.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e,s=vo(n);return r.jsx(Xm,{...s,...o,ref:t})});Dd.displayName=Kx;var ji="MenuSub",[Hx,Ld]=cr(ji),Od=e=>{const{__scopeMenu:t,children:n,open:o=!1,onOpenChange:s}=e,a=Kn(ji,t),l=vo(t),[c,d]=i.useState(null),[u,m]=i.useState(null),p=kn(s);return i.useEffect(()=>(a.open===!1&&p(!1),()=>p(!1)),[a.open,p]),r.jsx(Yc,{...l,children:r.jsx(bd,{scope:t,open:o,onOpenChange:p,content:u,onContentChange:m,children:r.jsx(Hx,{scope:t,contentId:Nr(),triggerId:Nr(),trigger:c,onTriggerChange:d,children:n})})})};Od.displayName=ji;var Jr="MenuSubTrigger",Fd=i.forwardRef((e,t)=>{const n=Kn(Jr,e.__scopeMenu),o=yo(Jr,e.__scopeMenu),s=Ld(Jr,e.__scopeMenu),a=bi(Jr,e.__scopeMenu),l=i.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},m=i.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return i.useEffect(()=>m,[m]),i.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),r.jsx(vi,{asChild:!0,...u,children:r.jsx(Nd,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":Bd(n.open),...e,ref:ir(t,s.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:tt(e.onPointerMove,io(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!l.current&&(a.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:tt(e.onPointerLeave,io(p=>{m();const f=n.content?.getBoundingClientRect();if(f){const y=n.content?.dataset.side,v=y==="right",_=v?-5:5,N=f[v?"left":"right"],E=f[v?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+_,y:p.clientY},{x:N,y:f.top},{x:E,y:f.top},{x:E,y:f.bottom},{x:N,y:f.bottom}],side:y}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:tt(e.onKeyDown,p=>{const f=a.searchRef.current!=="";e.disabled||f&&p.key===" "||Ex[o.dir].includes(p.key)&&(n.onOpenChange(!0),n.content?.focus(),p.preventDefault())})})})});Fd.displayName=Jr;var $d="MenuSubContent",zd=i.forwardRef((e,t)=>{const n=kd(mn,e.__scopeMenu),{forceMount:o=n.forceMount,...s}=e,a=Kn(mn,e.__scopeMenu),l=yo(mn,e.__scopeMenu),c=Ld($d,e.__scopeMenu),d=i.useRef(null),u=hn(t,d);return r.jsx(ao.Provider,{scope:e.__scopeMenu,children:r.jsx(On,{present:o||a.open,children:r.jsx(ao.Slot,{scope:e.__scopeMenu,children:r.jsx(wi,{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:m=>{l.isUsingKeyboardRef.current&&d.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:tt(e.onFocusOutside,m=>{m.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:tt(e.onEscapeKeyDown,m=>{l.onClose(),m.preventDefault()}),onKeyDown:tt(e.onKeyDown,m=>{const p=m.currentTarget.contains(m.target),f=Ix[l.dir].includes(m.key);p&&f&&(a.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});zd.displayName=$d;function Bd(e){return e?"open":"closed"}function hs(e){return e==="indeterminate"}function Ci(e){return hs(e)?"indeterminate":e?"checked":"unchecked"}function Gx(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Vx(e,t){return e.map((n,o)=>e[(t+o)%e.length])}function Qx(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let l=Vx(e,Math.max(a,0));s.length===1&&(l=l.filter(u=>u!==n));const d=l.find(u=>u.toLowerCase().startsWith(s.toLowerCase()));return d!==n?d:void 0}function Jx(e,t){const{x:n,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,m=c.y,p=d.x,f=d.y;m>o!=f>o&&n<(p-u)*(o-m)/(f-m)+u&&(s=!s)}return s}function Yx(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Jx(n,t)}function io(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Xx=wd,Zx=vi,eg=Sd,tg=jd,ng=ki,rg=Cd,og=Ms,sg=Ed,ag=Ad,ig=Rd,lg=Td,cg=Md,dg=Dd,ug=Od,pg=Fd,mg=zd;function fg(e,t=[]){let n=[];function o(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:f,children:y,...v}=p,_=f?.[e]?.[d]||c,N=i.useMemo(()=>v,Object.values(v));return r.jsx(_.Provider,{value:N,children:y})};u.displayName=a+"Provider";function m(p,f){const y=f?.[e]?.[d]||c,v=i.useContext(y);if(v)return v;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,hg(s,...t)]}function hg(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function xg(e){const t=gg(e),n=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(yg);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return r.jsx(t,{...l,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function gg(e){const t=i.forwardRef((n,o)=>{const{children:s,...a}=n;if(i.isValidElement(s)){const l=wg(s),c=bg(a,s.props);return s.type!==i.Fragment&&(c.ref=o?ir(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 vg=Symbol("radix.slottable");function yg(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vg}function bg(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function wg(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var kg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Sg=kg.reduce((e,t)=>{const n=xg(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),Ds="DropdownMenu",[jg,KS]=fg(Ds,[vd]),qt=vd(),[Cg,Ud]=jg(Ds),qd=e=>{const{__scopeDropdownMenu:t,children:n,dir:o,open:s,defaultOpen:a,onOpenChange:l,modal:c=!0}=e,d=qt(t),u=i.useRef(null),[m,p]=Ps({prop:s,defaultProp:a??!1,onChange:l,caller:Ds});return r.jsx(Cg,{scope:t,triggerId:Nr(),triggerRef:u,contentId:Nr(),open:m,onOpenChange:p,onOpenToggle:i.useCallback(()=>p(f=>!f),[p]),modal:c,children:r.jsx(Xx,{...d,open:m,onOpenChange:p,dir:o,modal:c,children:n})})};qd.displayName=Ds;var Wd="DropdownMenuTrigger",Kd=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:o=!1,...s}=e,a=Ud(Wd,n),l=qt(n);return r.jsx(Zx,{asChild:!0,...l,children:r.jsx(Sg.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:ir(t,a.triggerRef),onPointerDown:tt(e.onPointerDown,c=>{!o&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:tt(e.onKeyDown,c=>{o||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});Kd.displayName=Wd;var Ng="DropdownMenuPortal",Hd=e=>{const{__scopeDropdownMenu:t,...n}=e,o=qt(t);return r.jsx(eg,{...o,...n})};Hd.displayName=Ng;var Gd="DropdownMenuContent",Vd=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ud(Gd,n),a=qt(n),l=i.useRef(!1);return r.jsx(tg,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...o,ref:t,onCloseAutoFocus:tt(e.onCloseAutoFocus,c=>{l.current||s.triggerRef.current?.focus(),l.current=!1,c.preventDefault()}),onInteractOutside:tt(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,m=d.button===2||u;(!s.modal||m)&&(l.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Vd.displayName=Gd;var Eg="DropdownMenuGroup",Ig=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(ng,{...s,...o,ref:t})});Ig.displayName=Eg;var Ag="DropdownMenuLabel",_g=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(rg,{...s,...o,ref:t})});_g.displayName=Ag;var Rg="DropdownMenuItem",Qd=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(og,{...s,...o,ref:t})});Qd.displayName=Rg;var Pg="DropdownMenuCheckboxItem",Tg=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(sg,{...s,...o,ref:t})});Tg.displayName=Pg;var Mg="DropdownMenuRadioGroup",Jd=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(ag,{...s,...o,ref:t})});Jd.displayName=Mg;var Dg="DropdownMenuRadioItem",Yd=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(ig,{...s,...o,ref:t})});Yd.displayName=Dg;var Lg="DropdownMenuItemIndicator",Xd=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(lg,{...s,...o,ref:t})});Xd.displayName=Lg;var Og="DropdownMenuSeparator",Zd=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(cg,{...s,...o,ref:t})});Zd.displayName=Og;var Fg="DropdownMenuArrow",$g=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(dg,{...s,...o,ref:t})});$g.displayName=Fg;var zg=e=>{const{__scopeDropdownMenu:t,children:n,open:o,onOpenChange:s,defaultOpen:a}=e,l=qt(t),[c,d]=Ps({prop:o,defaultProp:a??!1,onChange:s,caller:"DropdownMenuSub"});return r.jsx(ug,{...l,open:c,onOpenChange:d,children:n})},Bg="DropdownMenuSubTrigger",eu=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(pg,{...s,...o,ref:t})});eu.displayName=Bg;var Ug="DropdownMenuSubContent",tu=i.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=qt(n);return r.jsx(mg,{...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)"}})});tu.displayName=Ug;var Yr=qd,Xr=Kd,jr=Hd,Zr=Vd,dn=Qd,qg=Jd,Wg=Yd,Kg=Xd,jl=Zd,Hg=zg,Gg=eu,Vg=tu;function Qg(e){const t=Jg(e),n=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(Xg);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return r.jsx(t,{...l,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Jg(e){const t=i.forwardRef((n,o)=>{const{children:s,...a}=n;if(i.isValidElement(s)){const l=ev(s),c=Zg(a,s.props);return s.type!==i.Fragment&&(c.ref=o?ir(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 Yg=Symbol("radix.slottable");function Xg(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Yg}function Zg(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function ev(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var tv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],bo=tv.reduce((e,t)=>{const n=Qg(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function nv(e,t=[]){let n=[];function o(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:f,children:y,...v}=p,_=f?.[e]?.[d]||c,N=i.useMemo(()=>v,Object.values(v));return r.jsx(_.Provider,{value:N,children:y})};u.displayName=a+"Provider";function m(p,f){const y=f?.[e]?.[d]||c,v=i.useContext(y);if(v)return v;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,rv(s,...t)]}function rv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function ov(e,t){return i.useReducer((n,o)=>t[n][o]??n,e)}var Ni="ScrollArea",[nu,HS]=nv(Ni),[sv,xn]=nu(Ni),ru=i.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:o="hover",dir:s,scrollHideDelay:a=600,...l}=e,[c,d]=i.useState(null),[u,m]=i.useState(null),[p,f]=i.useState(null),[y,v]=i.useState(null),[_,N]=i.useState(null),[E,z]=i.useState(0),[q,Z]=i.useState(0),[K,V]=i.useState(!1),[T,Y]=i.useState(!1),D=hn(t,Q=>d(Q)),oe=Rs(s);return r.jsx(sv,{scope:n,type:o,dir:oe,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:m,content:p,onContentChange:f,scrollbarX:y,onScrollbarXChange:v,scrollbarXEnabled:K,onScrollbarXEnabledChange:V,scrollbarY:_,onScrollbarYChange:N,scrollbarYEnabled:T,onScrollbarYEnabledChange:Y,onCornerWidthChange:z,onCornerHeightChange:Z,children:r.jsx(bo.div,{dir:oe,...l,ref:D,style:{position:"relative","--radix-scroll-area-corner-width":E+"px","--radix-scroll-area-corner-height":q+"px",...e.style}})})});ru.displayName=Ni;var ou="ScrollAreaViewport",su=i.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:o,nonce:s,...a}=e,l=xn(ou,n),c=i.useRef(null),d=hn(t,c,l.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx(bo.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});su.displayName=ou;var _n="ScrollAreaScrollbar",au=i.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=xn(_n,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"?r.jsx(av,{...o,ref:t,forceMount:n}):s.type==="scroll"?r.jsx(iv,{...o,ref:t,forceMount:n}):s.type==="auto"?r.jsx(iu,{...o,ref:t,forceMount:n}):s.type==="always"?r.jsx(Ei,{...o,ref:t}):null});au.displayName=_n;var av=i.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=xn(_n,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)},m=()=>{d=window.setTimeout(()=>l(!1),s.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",m),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",m)}}},[s.scrollArea,s.scrollHideDelay]),r.jsx(On,{present:n||a,children:r.jsx(iu,{"data-state":a?"visible":"hidden",...o,ref:t})})}),iv=i.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=xn(_n,e.__scopeScrollArea),a=e.orientation==="horizontal",l=Os(()=>d("SCROLL_END"),100),[c,d]=ov("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,m=a?"scrollLeft":"scrollTop";if(u){let p=u[m];const f=()=>{const y=u[m];p!==y&&(d("SCROLL"),l()),p=y};return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[s.viewport,a,d,l]),r.jsx(On,{present:n||c!=="hidden",children:r.jsx(Ei,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:t,onPointerEnter:tt(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:tt(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),iu=i.forwardRef((e,t)=>{const n=xn(_n,e.__scopeScrollArea),{forceMount:o,...s}=e,[a,l]=i.useState(!1),c=e.orientation==="horizontal",d=Os(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,m=n.viewport.offsetHeight<n.viewport.scrollHeight;l(c?u:m)}},10);return Er(n.viewport,d),Er(n.content,d),r.jsx(On,{present:o||a,children:r.jsx(Ei,{"data-state":a?"visible":"hidden",...s,ref:t})})}),Ei=i.forwardRef((e,t)=>{const{orientation:n="vertical",...o}=e,s=xn(_n,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=pu(c.viewport,c.content),m={...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 p(f,y){return mv(f,l.current,c,y)}return n==="horizontal"?r.jsx(lv,{...m,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollLeft,y=Cl(f,c,s.dir);a.current.style.transform=`translate3d(${y}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=p(f,s.dir))}}):n==="vertical"?r.jsx(cv,{...m,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollTop,y=Cl(f,c);a.current.style.transform=`translate3d(0, ${y}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=p(f))}}):null}),lv=i.forwardRef((e,t)=>{const{sizes:n,onSizesChange:o,...s}=e,a=xn(_n,e.__scopeScrollArea),[l,c]=i.useState(),d=i.useRef(null),u=hn(t,d,a.onScrollbarXChange);return i.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(cu,{"data-orientation":"horizontal",...s,ref:u,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Ls(n)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.x),onDragScroll:m=>e.onDragScroll(m.x),onWheelScroll:(m,p)=>{if(a.viewport){const f=a.viewport.scrollLeft+m.deltaX;e.onWheelScroll(f),fu(f,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&l&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:gs(l.paddingLeft),paddingEnd:gs(l.paddingRight)}})}})}),cv=i.forwardRef((e,t)=>{const{sizes:n,onSizesChange:o,...s}=e,a=xn(_n,e.__scopeScrollArea),[l,c]=i.useState(),d=i.useRef(null),u=hn(t,d,a.onScrollbarYChange);return i.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(cu,{"data-orientation":"vertical",...s,ref:u,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Ls(n)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.y),onDragScroll:m=>e.onDragScroll(m.y),onWheelScroll:(m,p)=>{if(a.viewport){const f=a.viewport.scrollTop+m.deltaY;e.onWheelScroll(f),fu(f,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&l&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:gs(l.paddingTop),paddingEnd:gs(l.paddingBottom)}})}})}),[dv,lu]=nu(_n),cu=i.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:o,hasThumb:s,onThumbChange:a,onThumbPointerUp:l,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:m,onResize:p,...f}=e,y=xn(_n,n),[v,_]=i.useState(null),N=hn(t,D=>_(D)),E=i.useRef(null),z=i.useRef(""),q=y.viewport,Z=o.content-o.viewport,K=kn(m),V=kn(d),T=Os(p,10);function Y(D){if(E.current){const oe=D.clientX-E.current.left,Q=D.clientY-E.current.top;u({x:oe,y:Q})}}return i.useEffect(()=>{const D=oe=>{const Q=oe.target;v?.contains(Q)&&K(oe,Z)};return document.addEventListener("wheel",D,{passive:!1}),()=>document.removeEventListener("wheel",D,{passive:!1})},[q,v,Z,K]),i.useEffect(V,[o,V]),Er(v,T),Er(y.content,T),r.jsx(dv,{scope:n,scrollbar:v,hasThumb:s,onThumbChange:kn(a),onThumbPointerUp:kn(l),onThumbPositionChange:V,onThumbPointerDown:kn(c),children:r.jsx(bo.div,{...f,ref:N,style:{position:"absolute",...f.style},onPointerDown:tt(e.onPointerDown,D=>{D.button===0&&(D.target.setPointerCapture(D.pointerId),E.current=v.getBoundingClientRect(),z.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",y.viewport&&(y.viewport.style.scrollBehavior="auto"),Y(D))}),onPointerMove:tt(e.onPointerMove,Y),onPointerUp:tt(e.onPointerUp,D=>{const oe=D.target;oe.hasPointerCapture(D.pointerId)&&oe.releasePointerCapture(D.pointerId),document.body.style.webkitUserSelect=z.current,y.viewport&&(y.viewport.style.scrollBehavior=""),E.current=null})})})}),xs="ScrollAreaThumb",du=i.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=lu(xs,e.__scopeScrollArea);return r.jsx(On,{present:n||s.hasThumb,children:r.jsx(uv,{ref:t,...o})})}),uv=i.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:o,...s}=e,a=xn(xs,n),l=lu(xs,n),{onThumbPositionChange:c}=l,d=hn(t,p=>l.onThumbChange(p)),u=i.useRef(void 0),m=Os(()=>{u.current&&(u.current(),u.current=void 0)},100);return i.useEffect(()=>{const p=a.viewport;if(p){const f=()=>{if(m(),!u.current){const y=fv(p,c);u.current=y,c()}};return c(),p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,m,c]),r.jsx(bo.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:tt(e.onPointerDownCapture,p=>{const y=p.target.getBoundingClientRect(),v=p.clientX-y.left,_=p.clientY-y.top;l.onThumbPointerDown({x:v,y:_})}),onPointerUp:tt(e.onPointerUp,l.onThumbPointerUp)})});du.displayName=xs;var Ii="ScrollAreaCorner",uu=i.forwardRef((e,t)=>{const n=xn(Ii,e.__scopeScrollArea),o=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&o?r.jsx(pv,{...e,ref:t}):null});uu.displayName=Ii;var pv=i.forwardRef((e,t)=>{const{__scopeScrollArea:n,...o}=e,s=xn(Ii,n),[a,l]=i.useState(0),[c,d]=i.useState(0),u=!!(a&&c);return Er(s.scrollbarX,()=>{const m=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(m),d(m)}),Er(s.scrollbarY,()=>{const m=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(m),l(m)}),u?r.jsx(bo.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 gs(e){return e?parseInt(e,10):0}function pu(e,t){const n=e/t;return isNaN(n)?0:n}function Ls(e){const t=pu(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-n)*t;return Math.max(o,18)}function mv(e,t,n,o="ltr"){const s=Ls(n),a=s/2,l=t||a,c=s-l,d=n.scrollbar.paddingStart+l,u=n.scrollbar.size-n.scrollbar.paddingEnd-c,m=n.content-n.viewport,p=o==="ltr"?[0,m]:[m*-1,0];return mu([d,u],p)(e)}function Cl(e,t,n="ltr"){const o=Ls(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-s,l=t.content-t.viewport,c=a-o,d=n==="ltr"?[0,l]:[l*-1,0],u=ef(e,d);return mu([0,l],[0,c])(u)}function mu(e,t){return n=>{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*(n-e[0])}}function fu(e,t){return e>0&&e<t}var fv=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},o=0;return function s(){const a={left:e.scrollLeft,top:e.scrollTop},l=n.left!==a.left,c=n.top!==a.top;(l||c)&&t(),n=a,o=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(o)};function Os(e,t){const n=kn(e),o=i.useRef(0);return i.useEffect(()=>()=>window.clearTimeout(o.current),[]),i.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(n,t)},[n,t])}function Er(e,t){const n=kn(t);Zm(()=>{let o=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(n)});return s.observe(e),()=>{window.cancelAnimationFrame(o),s.unobserve(e)}}},[e,n])}var hu=ru,hv=su,xu=au,xv=du,gv=uu;function vv(e,t=[]){let n=[];function o(a,l){const c=i.createContext(l),d=n.length;n=[...n,l];const u=p=>{const{scope:f,children:y,...v}=p,_=f?.[e]?.[d]||c,N=i.useMemo(()=>v,Object.values(v));return r.jsx(_.Provider,{value:N,children:y})};u.displayName=a+"Provider";function m(p,f){const y=f?.[e]?.[d]||c,v=i.useContext(y);if(v)return v;if(l!==void 0)return l;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{const a=n.map(l=>i.createContext(l));return function(c){const d=c?.[e]||a;return i.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[o,yv(s,...t)]}function yv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const l=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return n.scopeName=t.scopeName,n}function bv(e){const t=wv(e),n=i.forwardRef((o,s)=>{const{children:a,...l}=o,c=i.Children.toArray(a),d=c.find(Sv);if(d){const u=d.props.children,m=c.map(p=>p===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...l,ref:s,children:i.isValidElement(u)?i.cloneElement(u,void 0,m):null})}return r.jsx(t,{...l,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function wv(e){const t=i.forwardRef((n,o)=>{const{children:s,...a}=n;if(i.isValidElement(s)){const l=Cv(s),c=jv(a,s.props);return s.type!==i.Fragment&&(c.ref=o?ir(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 kv=Symbol("radix.slottable");function Sv(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kv}function jv(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Cv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Nv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Fs=Nv.reduce((e,t)=>{const n=bv(`Primitive.${t}`),o=i.forwardRef((s,a)=>{const{asChild:l,...c}=s,d=l?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),$s="Tabs",[Ev,GS]=vv($s,[Ts]),gu=Ts(),[Iv,Ai]=Ev($s),vu=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:s,defaultValue:a,orientation:l="horizontal",dir:c,activationMode:d="automatic",...u}=e,m=Rs(c),[p,f]=Ps({prop:o,onChange:s,defaultProp:a??"",caller:$s});return r.jsx(Iv,{scope:n,baseId:Nr(),value:p,onValueChange:f,orientation:l,dir:m,activationMode:d,children:r.jsx(Fs.div,{dir:m,"data-orientation":l,...u,ref:t})})});vu.displayName=$s;var yu="TabsList",bu=i.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...s}=e,a=Ai(yu,n),l=gu(n);return r.jsx(hd,{asChild:!0,...l,orientation:a.orientation,dir:a.dir,loop:o,children:r.jsx(Fs.div,{role:"tablist","aria-orientation":a.orientation,...s,ref:t})})});bu.displayName=yu;var wu="TabsTrigger",ku=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:s=!1,...a}=e,l=Ai(wu,n),c=gu(n),d=Cu(l.baseId,o),u=Nu(l.baseId,o),m=o===l.value;return r.jsx(xd,{asChild:!0,...c,focusable:!s,active:m,children:r.jsx(Fs.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":u,"data-state":m?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:d,...a,ref:t,onMouseDown:tt(e.onMouseDown,p=>{!s&&p.button===0&&p.ctrlKey===!1?l.onValueChange(o):p.preventDefault()}),onKeyDown:tt(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&l.onValueChange(o)}),onFocus:tt(e.onFocus,()=>{const p=l.activationMode!=="manual";!m&&!s&&p&&l.onValueChange(o)})})})});ku.displayName=wu;var Su="TabsContent",ju=i.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:s,children:a,...l}=e,c=Ai(Su,n),d=Cu(c.baseId,o),u=Nu(c.baseId,o),m=o===c.value,p=i.useRef(m);return i.useEffect(()=>{const f=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(f)},[]),r.jsx(On,{present:s||m,children:({present:f})=>r.jsx(Fs.div,{"data-state":m?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:u,tabIndex:0,...l,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:f&&a})})});ju.displayName=Su;function Cu(e,t){return`${e}-trigger-${t}`}function Nu(e,t){return`${e}-content-${t}`}var Av=vu,Eu=bu,Iu=ku,Au=ju;const _u=i.forwardRef(({className:e,orientation:t="vertical",...n},o)=>r.jsx(xu,{ref:o,orientation:t,className:yt("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:r.jsx(xv,{className:"relative flex-1 rounded-full bg-border/80"})}));_u.displayName=xu.displayName;const Ru=i.forwardRef(({className:e,children:t,...n},o)=>r.jsxs(hu,{ref:o,className:yt("relative overflow-hidden",e),...n,children:[r.jsx(hv,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsx(_u,{}),r.jsx(gv,{})]}));Ru.displayName=hu.displayName;const wo=({className:e="w-5 h-5"})=>r.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),ko=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=ui();return r.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},So=({className:e="w-5 h-5"})=>{const t=i.useId(),n=i.useId(),o=i.useId();return r.jsxs("svg",{"aria-label":"Gemini",className:e,role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("title",{children:"Gemini"}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${t})`}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${n})`}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${o})`}),r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:t,x1:"7",x2:"11",y1:"15.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#08B962"}),r.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:n,x1:"8",x2:"11.5",y1:"5.5",y2:"11",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#F94543"}),r.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:o,x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#FABC12"}),r.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]})},jo=({className:e="h-5 w-auto",style:t,...n})=>r.jsxs("svg",{"aria-label":"OpenCode",className:e,role:"img",style:{width:"auto",maxWidth:"100%",...t},viewBox:"0 0 32 24",preserveAspectRatio:"xMidYMid meet",xmlns:"http://www.w3.org/2000/svg",...n,children:[r.jsx("title",{children:"OpenCode"}),r.jsx("rect",{x:"6",y:"2",width:"20",height:"20",rx:"5",fill:"currentColor"}),r.jsx("path",{d:"M20 6h-8v12h8V6zm4 16H8V2h16v20z",fill:"white"})]}),or=i.forwardRef(({className:e,type:t,...n},o)=>r.jsx("input",{type:t,className:yt("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,...n}));or.displayName="Input";const _v=!1;function Wn(e,t=""){return`/api/projects/${encodeURIComponent(e)}${t}`}function Rv(e,t=""){return`/api/session-core/projects/${encodeURIComponent(e)}${t}`}function Pv(e,t,n={}){const{timeoutMs:o=null,signal:s,...a}=n,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 Pu({ttlMs:e=0}={}){const t=new Map,n=new Map,o=s=>typeof s?.clone=="function"?s.clone():s;return{fetch(s,a){if(!s)return a();const l=n.get(s);if(l&&l.expiresAt>Date.now())return Promise.resolve(o(l.response));if(l&&n.delete(s),!t.has(s)){const c=Promise.resolve().then(a).then(d=>(Number.isFinite(e)&&e>0&&n.set(s,{response:d,expiresAt:Date.now()+e}),d)).finally(()=>{t.delete(s)});t.set(s,c)}return t.get(s).then(o)}}}function Nl(e){return e==="resolve"?2e4:e==="events"?6e4:null}const Tv=Pu({ttlMs:1500}),Mv=Pu({ttlMs:1500});function Dv(){return localStorage.getItem("auth-token")}function Lv(){const e=localStorage.getItem("agent-command-overrides");return typeof e=="string"&&e.trim()?e.trim():""}function Wr(e={}){const t=Lv();return t?{...e,headers:{...e.headers||{},"X-Axhub-Acp-Command-Overrides":t}}:e}function Ov(e,t={}){const n={...t};!(e instanceof FormData)&&!n["Content-Type"]&&(n["Content-Type"]="application/json");{const o=Dv();o&&!n.Authorization&&(n.Authorization=`Bearer ${o}`)}return n}function Zt(e,t={}){const{timeoutMs:n=null,signal:o,headers:s,body:a,...l}=t;return Pv(fetch,e,{...l,body:a,headers:Ov(a,s),signal:o,timeoutMs:n})}function Nt(e,t={}){return Zt(e,t)}function Yn(e,t={}){return Mv.fetch(e,()=>Nt(e,t))}function Yt(e,t,n={}){return Nt(e,{...n,method:"POST",body:JSON.stringify(t)})}function Fv(e,t,n={}){return Nt(e,{...n,method:"PUT",body:JSON.stringify(t)})}function br(e,t={}){return Nt(e,{...t,method:"DELETE"})}function Xt(e,t){const n=new URLSearchParams;Object.entries(t||{}).forEach(([s,a])=>{a!=null&&a!==""&&n.set(s,String(a))});const o=n.toString();return o?`${e}?${o}`:e}const et={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:()=>Nt("/api/auth/user"),logout:()=>Nt("/api/auth/logout",{method:"POST"})},lanAccess:{summary:()=>Nt("/api/lan-access/summary"),updatePassword:e=>Yt("/api/lan-access/password",{password:e}),createToken:e=>Yt("/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:()=>Nt("/api/projects"),projectsList:(e={})=>Yn(Xt("/api/projects/list",{force:e.force?"true":null})),projectDetails:e=>Nt(Wn(e,"/details")),historyIndex:e=>Nt(Rv(e,"/history-index"),Wr()),providerDiscovery:(e,t=null,n={})=>Yn(Xt(`/api/session-core/providers/${e}`,{projectPath:t,force:n.force?"true":null})),providersDiscovery:(e=null)=>Yn(Xt("/api/session-core/providers",{projectPath:e})),providerAcpCapabilities:(e,t=null,n={})=>Yn(Xt(`/api/session-core/providers/${e}/acp-capabilities`,{projectPath:t,force:n.force?"true":null}),Wr()),sessionEvents:(e,t,n=null,o=null,s=null,a=0)=>{const l=Xt(`/api/session-core/sessions/${e}/${t}/events`,{projectName:n,projectPath:o,limit:s,offset:a});return Tv.fetch(l,()=>Nt(l,Wr({timeoutMs:Nl("events")})))},sessionMessages:(e,t,n=null,o=0,s="claude")=>Nt(Xt(`/api/session-core/sessions/${s}/${t}/events`,{projectName:e,limit:n,offset:o}),Wr()),run:e=>Yn(`/api/runs/${encodeURIComponent(e)}`),createRun:e=>Yt("/api/runs",e),runEvents:(e,t=0)=>Yn(Xt(`/api/runs/${encodeURIComponent(e)}/events`,{after:t})),cancelRun:(e,t={})=>Yt(`/api/runs/${encodeURIComponent(e)}/cancel`,t),resolveRunPermission:(e,t={})=>Yt(`/api/runs/${encodeURIComponent(e)}/permission`,t),resolveRunElicitation:(e,t={})=>Yt(`/api/runs/${encodeURIComponent(e)}/elicitation`,t),runStreamUrl:(e,t=0)=>Xt(`/api/runs/${encodeURIComponent(e)}/stream`,{after:t}),sessionRuns:(e,t,n="active")=>Yn(Xt(`/api/sessions/${encodeURIComponent(e)}/${encodeURIComponent(t)}/runs`,{status:n})),openSessionInCli:e=>Yt("/api/local-terminal/session",e),resolveSession:(e,t,n=null)=>Nt(Xt(`/api/session-core/sessions/${e}/${t}/resolve`,{projectPath:n}),Wr({timeoutMs:Nl("resolve")})),renameProject:(e,t)=>Fv(Wn(e,"/rename"),{displayName:t}),deleteSession:(e,t)=>br(`${Wn(e,"/sessions")}/${encodeURIComponent(t)}`),deleteCodexSession:e=>br(`/api/codex/sessions/${e}`),deleteGeminiSession:e=>br(`/api/gemini/sessions/${e}`),deleteOpencodeSession:e=>br(`/api/opencode/sessions/${e}`),deleteProject:(e,t=!1)=>br(Xt(Wn(e),{force:t?"true":null})),createProject:e=>Yt("/api/projects/create",{path:e}),createWorkspace:e=>Yt("/api/projects/create-workspace",e),readFile:(e,t)=>Nt(`${Wn(e,"/file")}?filePath=${encodeURIComponent(t)}`),getFiles:e=>Nt(Wn(e,"/files")),transcribe:e=>Nt("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>Nt(Xt("/api/browse-filesystem",{path:e})),createFolder:e=>Yt("/api/create-folder",{path:e}),ccConnect:{status:()=>Nt("/api/cc-connect/status"),providers:()=>Nt("/api/cc-connect/providers"),platforms:()=>Nt("/api/cc-connect/platforms"),install:()=>Nt("/api/cc-connect/install",{method:"POST"}),setup:(e,t)=>Yt(`/api/cc-connect/${e}/setup`,t),sessionStatus:(e,t)=>Nt(Xt(`/api/cc-connect/${e}/status`,{sessionId:t})),refresh:(e,t)=>Yt(`/api/cc-connect/${e}/refresh`,{sessionId:t}),cleanupSession:(e,t)=>br(Xt(`/api/cc-connect/${e}/session`,{sessionId:t})),activeProvider:e=>Nt(`/api/cc-connect/${e}/active-provider`),switchProvider:(e,t)=>Yt(`/api/cc-connect/${e}/switch-provider`,{provider:t}),updateProject:(e,t)=>Yt(`/api/cc-connect/${e}/project`,t),unbind:e=>Nt(`/api/cc-connect/${e}/unbind`,{method:"POST"})},get:e=>Nt(`/api${e}`)},El="__windows_drives__",$v="__workspace_roots__",zv=/^[A-Za-z]:\\?$/,Bv=({onClose:e,onProjectCreated:t})=>{const{t:n}=Ot(),[o,s]=i.useState(1),[a,l]=i.useState("existing"),[c,d]=i.useState(""),[u,m]=i.useState(!1),[p,f]=i.useState(null),[y,v]=i.useState([]),[_,N]=i.useState(!1),[E,z]=i.useState(!1),[q,Z]=i.useState("~"),[K,V]=i.useState("~"),[T,Y]=i.useState([]),[D,oe]=i.useState(!1),[Q,b]=i.useState(!1),[$,L]=i.useState(!1),[ee,le]=i.useState(""),[ve,ue]=i.useState(!1),[W,Se]=i.useState(null),[Ce,Ae]=i.useState(null),[se,J]=i.useState(!1),pe=P=>{const B=P.trim();if(!B)return"~";if(B.endsWith("/")||B.endsWith("\\"))return B;if(/^[A-Za-z]:$/.test(B))return`${B}\\`;const me=Math.max(B.lastIndexOf("/"),B.lastIndexOf("\\"));return me>0?me===2&&/^[A-Za-z]:/.test(B)?B.substring(0,3):B.substring(0,me):"~"},xe=Ce==="windows-drives",he=Ce==="workspace-roots",be=!!Ce,Be=W==="win32"&&!se,Ve=se,He=!be,nt=!be;i.useEffect(()=>{c.length>2?Pe(c):(v([]),N(!1))},[c]);const Pe=async P=>{try{const B=pe(P),Fe=await(await et.browseFilesystem(B)).json();if(Fe.suggestions){const rt=Fe.suggestions.filter(fe=>fe.path.toLowerCase().startsWith(P.toLowerCase())&&fe.path.toLowerCase()!==P.toLowerCase());v(rt.slice(0,5)),N(rt.length>0)}}catch(B){console.error("Error loading path suggestions:",B)}},lt=()=>{if(f(null),o===1){if(!a){f(n("projectWizard.errors.selectType"));return}s(2)}else if(o===2){if(!c.trim()){f(n("projectWizard.errors.providePath"));return}s(3)}},ct=()=>{f(null),s(o-1)},Te=async()=>{m(!0),f(null);try{const P={workspaceType:a,path:c.trim()},B=await et.createWorkspace(P),me=await B.json();if(!B.ok)throw new Error(me.details||me.error||n("projectWizard.errors.failedToCreate"));t&&t(me.project),e()}catch(P){console.error("Error creating workspace:",P),f(P.message||n("projectWizard.errors.failedToCreate"))}finally{m(!1)}},Je=P=>{d(P.path),N(!1)},_e=async()=>{z(!0),await Qe()},Qe=async P=>{try{oe(!0);const me=await(await et.browseFilesystem(P)).json();Z(me.path||P),V(me.displayPath||me.path||P),Y(me.suggestions||[]),Se(me.platform||null),Ae(me.virtualRoot||null),J(!!me.hasWorkspaceRootRestriction)}catch(B){console.error("Error loading folders:",B)}finally{oe(!1)}},Ke=(P,B=!1)=>{!P||P===El||(d(P),z(!1),B&&s(3))},mt=async P=>{await Qe(P)},Xe=async()=>{if(!(!ee.trim()||!nt)){ue(!0),f(null);try{const P=q.includes("\\")?"\\":"/",B=q.endsWith(P)?`${q}${ee.trim()}`:`${q}${P}${ee.trim()}`,me=await et.createFolder(B),Fe=await me.json();if(!me.ok)throw new Error(Fe.error||n("projectWizard.errors.failedToCreateFolder"));le(""),L(!1),await Qe(Fe.path||B)}catch(P){console.error("Error creating folder:",P),f(P.message||n("projectWizard.errors.failedToCreateFolder"))}finally{ue(!1)}}};return r.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:r.jsx(Sr,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("projectWizard.title")})]}),r.jsx("button",{onClick:e,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:u,children:r.jsx(on,{className:"w-5 h-5"})})]}),r.jsx("div",{className:"px-6 pt-4 pb-2",children:r.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(P=>r.jsxs(Rt.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${P<o?"bg-green-500 text-white":P===o?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:P<o?r.jsx(In,{className:"w-4 h-4"}):P}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:n(P===1?"projectWizard.steps.type":P===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),P<3&&r.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${P<o?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},P))})}),r.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[p&&r.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[r.jsx(tf,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),r.jsx("div",{className:"flex-1",children:r.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:p})})]}),o===1&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:n("projectWizard.step1.question")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsx("button",{onClick:()=>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:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:r.jsx(Sr,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.existing.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.existing.description")})]})]})}),r.jsx("button",{onClick:()=>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:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:r.jsx(Sr,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.new.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.new.description")})]})]})})]})]})}),o===2&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n(a==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),r.jsxs("div",{className:"relative flex gap-2",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(or,{type:"text",value:c,onChange:P=>d(P.target.value),placeholder:n(a==="existing"?"projectWizard.step2.existingPlaceholder":"projectWizard.step2.newPlaceholder"),className:"w-full"}),_&&y.length>0&&r.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:y.map((P,B)=>r.jsxs("button",{onClick:()=>Je(P),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:P.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:P.path})]},B))})]}),r.jsx(Ge,{type:"button",variant:"outline",onClick:_e,className:"px-3",title:n("projectWizard.folderBrowser.browseFolders"),children:r.jsx(no,{className:"w-4 h-4"})})]}),r.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n(a==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]})}),o===3&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[r.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:n("projectWizard.step3.reviewConfig")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.workspaceType")}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:n(a==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.path")}),r.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]})]})]}),r.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-4 border border-primary/30 dark:border-primary/60",children:r.jsx("p",{className:"text-sm text-primary",children:n(a==="existing"?"projectWizard.step3.existingInfo":"projectWizard.step3.newEmpty")})})]})]}),r.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[r.jsx(Ge,{variant:"outline",onClick:o===1?e:ct,disabled:u,children:o===1?n("projectWizard.buttons.cancel"):r.jsxs(r.Fragment,{children:[r.jsx(Xf,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.back")]})}),r.jsx(Ge,{onClick:o===3?Te:lt,disabled:u||o===1&&!a,children:u?r.jsxs(r.Fragment,{children:[r.jsx(Bt,{className:"w-4 h-4 mr-2 animate-spin"}),n("projectWizard.buttons.creating")]}):o===3?r.jsxs(r.Fragment,{children:[r.jsx(In,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.createProject")]}):r.jsxs(r.Fragment,{children:[n("projectWizard.buttons.next"),r.jsx(hi,{className:"w-4 h-4 ml-1"})]})})]})]}),E&&r.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 bg-primary/15 dark:bg-primary/30 rounded-lg flex items-center justify-center",children:r.jsx(no,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("projectWizard.folderBrowser.title")})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>mt(Be?El:$v),className:`p-2 rounded-md transition-colors ${be?"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"} ${Be||Ve?"":"hidden"}`,title:n(Be?"projectWizard.folderBrowser.browseDrives":"projectWizard.folderBrowser.browseRoots"),children:r.jsx(gh,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>b(!Q),className:`p-2 rounded-md transition-colors ${Q?"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:n(Q?"projectWizard.folderBrowser.hideHiddenFolders":"projectWizard.folderBrowser.showHiddenFolders"),children:Q?r.jsx(oh,{className:"w-5 h-5"}):r.jsx(ah,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>L(!$),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:n("projectWizard.folderBrowser.createFolder"),disabled:!nt,children:r.jsx(fo,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>z(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:r.jsx(on,{className:"w-5 h-5"})})]})]}),$&&nt&&r.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-primary/10 dark:bg-primary/20",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(or,{type:"text",value:ee,onChange:P=>le(P.target.value),placeholder:n("projectWizard.folderBrowser.newFolderPlaceholder"),className:"flex-1",onKeyDown:P=>{P.key==="Enter"&&Xe(),P.key==="Escape"&&(L(!1),le(""))},autoFocus:!0}),r.jsx(Ge,{size:"sm",onClick:Xe,disabled:!ee.trim()||ve,children:ve?r.jsx(Bt,{className:"w-4 h-4 animate-spin"}):n("buttons.create")}),r.jsx(Ge,{size:"sm",variant:"ghost",onClick:()=>{L(!1),le("")},children:n("buttons.cancel")})]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:D?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Bt,{className:"w-6 h-6 animate-spin text-gray-400"})}):r.jsxs("div",{className:"space-y-1",children:[q!=="~"&&q!=="/"&&!zv.test(q)&&!be&&r.jsxs("button",{onClick:()=>{const P=Math.max(q.lastIndexOf("/"),q.lastIndexOf("\\"));let B;P<=0?B="/":P===2&&/^[A-Za-z]:/.test(q)?B=q.substring(0,3):B=q.substring(0,P),mt(B)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[r.jsx(no,{className:"w-5 h-5 text-gray-400"}),r.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),T.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("projectWizard.folderBrowser.noSubfolders")}):T.filter(P=>Q||!P.name.startsWith(".")).sort((P,B)=>P.name.toLowerCase().localeCompare(B.name.toLowerCase())).map((P,B)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>mt(P.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[r.jsx(Sr,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:P.name})]}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>Ke(P.path,a==="existing"),className:"text-xs px-3",children:n("buttons.select")})]},B))]})}),r.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.folderBrowser.currentPath")}),r.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:xe?n("projectWizard.folderBrowser.drivesRoot"):he?n("projectWizard.folderBrowser.workspaceRoots"):K})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[r.jsx(Ge,{variant:"outline",onClick:()=>{z(!1),L(!1),le("")},children:n("buttons.cancel")}),r.jsx(Ge,{variant:"outline",onClick:()=>Ke(q,a==="existing"),disabled:!He,children:n("projectWizard.folderBrowser.useCurrentFolder")})]})]})]})})]})},xt=Object.freeze({HIDE_SIDEBAR:"hide-sidebar",NEW_SESSION:"new-session",NEW_PROJECT:"new-project",IMAGE_PLAYGROUND:"image-playground",REMOTE_ACCESS:"remote-access",REFRESH:"refresh",THEME_TOGGLE:"theme-toggle",SHOW_SIDEBAR:"show-sidebar",UPDATE_AVAILABLE:"update-available"});function Uv({isProjectLockedMode:e=!1}={}){return{showSearch:!1,titleKey:e?"sessions.title":"projects.title",topRowActionIds:e?[xt.THEME_TOGGLE]:[xt.THEME_TOGGLE,xt.HIDE_SIDEBAR],primaryActionIds:[xt.NEW_SESSION,xt.IMAGE_PLAYGROUND,xt.REMOTE_ACCESS],projectActionIds:e?[xt.REFRESH]:[xt.NEW_PROJECT,xt.REFRESH]}}function qv({updateAvailable:e=!1}={}){const t=[xt.SHOW_SIDEBAR,xt.NEW_SESSION,xt.IMAGE_PLAYGROUND,xt.REMOTE_ACCESS,xt.THEME_TOGGLE];return e&&t.push(xt.UPDATE_AVAILABLE),t}function Wv(e,{provider:t,projectName:n,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(n,o)}}const Tu="/image-playground",_i="returnTo",Oa="projectPath";function Kv(e=""){const t=typeof e=="string"?e.trim():"";return!t||t==="/"?"":t.endsWith("/")?t.slice(0,-1):t}function Mu(e=""){return`${Kv(e)}${Tu}`}function lo(e){return typeof e!="string"?null:e.trim()||null}function Hv(e){const t=lo(e);return!!(t&&(t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t)))}function Il(e){try{return decodeURIComponent(e)}catch{return e}}function Gv(e,t){if(typeof e!="string")return null;const n=e.startsWith("?")?e.slice(1):e;if(!n)return null;for(const o of n.split("&")){if(!o)continue;const s=o.indexOf("="),a=s>=0?o.slice(0,s):o;if(Il(a)!==t)continue;const l=s>=0?o.slice(s+1):"";return Il(l)}return null}function co(e,t){return typeof e=="string"?Gv(e,t):e.get(t)}function Du(e){for(const n of["cwd","workdir","project"]){const o=lo(co(e,n));if(o)return o}const t=co(e,"projectName");return Hv(t)?t.trim():null}function Lu(e,{basename:t=""}={}){if(!zs(e,{basename:t}))return null;const n=new URL(e,"http://localhost");return Du(n.search)}function zs(e,{basename:t=""}={}){if(typeof e!="string")return!1;const n=e.trim();if(!n||!n.startsWith("/")||n.startsWith("//"))return!1;const s=new URL(n,"http://localhost").pathname.replace(/\/+$/,"")||"/",a=Mu(t).replace(/\/+$/,"");return s!==Tu&&s!==a}function Ri(e){const t=e||(typeof window<"u"?window.location:null);if(!t)return"/";const n=typeof t.pathname=="string"&&t.pathname?t.pathname:"/",o=typeof t.search=="string"?t.search:"",s=typeof t.hash=="string"?t.hash:"",a=`${n}${o}${s}`;return zs(a)?a:"/"}function VS(e,{basename:t=""}={}){const n=e instanceof URLSearchParams||typeof e=="string"?e:new URLSearchParams(e||""),o=co(n,_i);if(!zs(o,{basename:t}))return null;const s=new URL(o,"http://localhost");return`${s.pathname}${s.search}${s.hash}`}function Vv(e,{basename:t=""}={}){const n=e instanceof URLSearchParams||typeof e=="string"?e:new URLSearchParams(e||""),o=lo(co(n,Oa));if(o)return o;const s=Du(n);return s||Lu(co(n,_i),{basename:t})}function Al(e){return e.map(([t,n])=>`${encodeURIComponent(t)}=${encodeURIComponent(n)}`).join("&")}function Pi({basename:e="",returnPath:t="",projectPath:n=""}={}){const o=Mu(e),s=[];if(!zs(t,{basename:e})){const l=lo(n);return l?(s.push([Oa,l]),`${o}?${Al(s)}`):o}s.push([_i,t]);const a=lo(n)||Lu(t,{basename:e});return a&&s.push([Oa,a]),`${o}?${Al(s)}`}const Qv=(e,t,n)=>{const o=new Date(e),s=t;if(isNaN(o.getTime()))return n?n("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?n?n("time.justNow"):"Just now":c===1?n?n("time.oneMinuteAgo"):"1 min ago":c<60?n?n("time.minutesAgo",{count:c}):`${c} mins ago`:d===1?n?n("time.oneHourAgo"):"1 hour ago":d<24?n?n("time.hoursAgo",{count:d}):`${d} hours ago`:u===1?n?n("time.oneDayAgo"):"1 day ago":u<7?n?n("time.daysAgo",{count:u}):`${u} days ago`:o.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},Jv=(e,t)=>{if(typeof e!="string")return"";const n=e.trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`},wr="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",Xo="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",fa="block min-w-0 w-full max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground";function Yv(e){if(typeof window<"u"){const t=Vv(window.location.search,{basename:window.__ROUTER_BASENAME__||""});if(t)return t}return e?.fullPath||e?.path||null}const _l=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?r.jsx(ko,{className:t}):e==="gemini"?r.jsx(So,{className:t}):e==="opencode"?r.jsx(jo,{className:"h-3.5 w-auto max-w-full"}):r.jsx(wo,{className:t});function Rl({projects:e,selectedProject:t,selectedSession:n,onProjectSelect:o,onProjectRename:s,onSessionSelect:a,onNewSession:l,onSessionDelete:c,onProjectDelete:d,isLoading:u,projectDetailsLoading:m,projectDetailsErrors:p,loadingProgress:f,onProjectExpand:y,onRefresh:v,updateAvailable:_,latestVersion:N,currentVersion:E,releaseInfo:z,onShowVersionModal:q,isPWA:Z,isMobile:K,onToggleSidebar:V,onShowSettings:T,lockedProjectName:Y,showNewProject:D,setShowNewProject:oe,onOpenCcConnectDialog:Q}){const{t:b}=Ot("sidebar"),[$,L]=i.useState(new Set),[ee,le]=i.useState(null),[ve,ue]=i.useState(""),[W,Se]=i.useState({}),[Ce,Ae]=i.useState({}),[se,J]=i.useState(new Date),[pe,xe]=i.useState("name"),[he,be]=i.useState(!1),[je,Be]=i.useState(null),[Ve,He]=i.useState(null),[nt,Pe]=i.useState(""),[lt,ct]=i.useState(null),[Te,Je]=i.useState(null),[_e,Qe]=i.useState({}),[Ke,mt]=i.useState(new Set),[Xe,P]=i.useState(null),[B,me]=i.useState(null),[Fe,rt]=i.useState(()=>{try{const x=localStorage.getItem("starredProjects");return x?new Set(JSON.parse(x)):new Set}catch(x){return console.error("Error loading starred projects:",x),new Set}}),fe=x=>I=>{I.target.closest(".overflow-y-auto")||I.target.closest("[data-scroll-container]")||(I.preventDefault(),I.stopPropagation(),x())};i.useEffect(()=>{const x=setInterval(()=>{J(new Date)},6e4);return()=>clearInterval(x)},[]),i.useEffect(()=>{Ae({})},[e]),i.useEffect(()=>{n&&t&&L(x=>new Set([...x,t.name]))},[n,t]),i.useEffect(()=>{Y&&L(new Set([Y]))},[Y,e.length]),i.useEffect(()=>{const x=()=>{try{const U=localStorage.getItem("claude-settings");if(U){const ce=JSON.parse(U);xe(ce.projectSortOrder||"name")}}catch(U){console.error("Error loading sort order:",U)}};x();const I=U=>{U.key==="claude-settings"&&x()};window.addEventListener("storage",I);const S=setInterval(()=>{document.hasFocus()&&x()},1e3);return()=>{window.removeEventListener("storage",I),clearInterval(S)}},[]);const g=async x=>{const I=new Set,S=!$.has(x.name);S&&I.add(x.name),L(I),S&&typeof y=="function"&&await y(x.name,{background:!0})},ie=(x,I)=>{a({...x,__projectName:I})},Ne=x=>{const I=new Set(Fe);I.has(x)?I.delete(x):I.add(x),rt(I);try{localStorage.setItem("starredProjects",JSON.stringify([...I]))}catch(S){console.error("Error saving starred projects:",S)}},de=x=>Fe.has(x),Oe=x=>{let I={};try{I=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const S=[...x.sessions||[],...Ce[x.name]||[]].map(Ue=>({...Ue,__provider:I[Ue.id]||"claude"})),U=(x.codexSessions||[]).map(Ue=>({...Ue,__provider:"codex"})),ce=(x.geminiSessions||[]).map(Ue=>({...Ue,__provider:"gemini"})),ze=(x.opencodeSessions||[]).map(Ue=>({...Ue,__provider:"opencode"})),ft=Ue=>Ue.__provider==="codex"?new Date(Ue.createdAt||Ue.lastActivity):Ue.__provider==="gemini"?new Date(Ue.createdAt||Ue.lastActivity):Ue.__provider==="opencode"?new Date(Ue.createdAt||Ue.lastActivity):new Date(Ue.lastActivity);return[...S,...U,...ce,...ze].sort((Ue,St)=>ft(St)-ft(Ue))},Me=x=>{const I=Oe(x);return I.length===0?new Date(0):I.reduce((U,ce)=>{const ze=new Date(ce.lastActivity);return ze>U?ze:U},new Date(0))},$e=[...e].sort((x,I)=>{const S=de(x.name),U=de(I.name);if(S&&!U)return-1;if(!S&&U)return 1;if(pe==="date")return Me(I)-Me(x);{const ce=x.displayName||x.name,ze=I.displayName||I.name;return ce.localeCompare(ze)}}),De=x=>{le(x.name),ue(x.displayName||x.name||"")},it=()=>{le(null),ue("")},ge=async x=>{const I=ve.trim();if(je!==x)try{if(Be(x),(await api.renameProject(x,I)).ok)if(I&&typeof s=="function"&&s(x,I),typeof v=="function")await v();else if(window.refreshProjects)await window.refreshProjects();else{window.location.reload();return}else console.error("Failed to rename project")}catch(S){console.error("Error renaming project:",S)}finally{Be(null),le(null),ue("")}},Re=(x,I,S,U="claude")=>{me({projectName:x,sessionId:I,sessionTitle:S,provider:U})},Et=async()=>{if(!B)return;const{projectName:x,sessionId:I,provider:S}=B;me(null);try{console.log("[Sidebar] Deleting session:",{projectName:x,sessionId:I,provider:S});const U=await Wv(api,{provider:S,projectName:x,sessionId:I});if(console.log("[Sidebar] Delete response:",{ok:U.ok,status:U.status}),U.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),c?c(I):console.warn("[Sidebar] No onSessionDelete callback provided");else{const ce=await U.text();console.error("[Sidebar] Failed to delete session:",{status:U.status,error:ce}),alert(b("messages.deleteSessionFailed"))}}catch(U){console.error("[Sidebar] Error deleting session:",U),alert(b("messages.deleteSessionError"))}},st=x=>{const I=Oe(x).length;P({project:x,sessionCount:I})},j=async()=>{if(!Xe)return;const{project:x,sessionCount:I}=Xe,S=I===0;P(null),mt(U=>new Set([...U,x.name]));try{const U=await api.deleteProject(x.name,!S);if(U.ok)d&&d(x.name);else{const ce=await U.json();console.error("Failed to delete project"),alert(ce.error||b("messages.deleteProjectFailed"))}}catch(U){console.error("Error deleting project:",U),alert(b("messages.deleteProjectError"))}finally{mt(U=>{const ce=new Set(U);return ce.delete(x.name),ce})}},M=async x=>{if(!x.detailsLoaded&&typeof y=="function"){await y(x.name,{background:!0,force:!0});return}if(!(!(x.sessionMeta?.hasMore!==!1)||W[x.name])){Se(S=>({...S,[x.name]:!0}));try{const S=Oe(x).length,U=await api.historyIndex(x.name);if(U.ok){const ce=await U.json(),ze=Array.isArray(ce.sessions)?ce.sessions:[],ft=new Set(Oe(x).map(St=>St.id)),Ue=ze.filter(St=>!ft.has(St.id)).slice(0,5).map(St=>({...St,__provider:St.provider||St.__provider||"claude"}));Ae(St=>({...St,[x.name]:[...St[x.name]||[],...Ue]})),(Ue.length===0||S+Ue.length>=ze.length)&&(x.sessionMeta={...x.sessionMeta,hasMore:!1})}}catch(S){console.error("Error loading more sessions:",S)}finally{Se(S=>({...S,[x.name]:!1}))}}},H=!!Y,ae=Uv({isProjectLockedMode:H}),Ie=H?$e.filter(x=>x.name===Y):$e,te=t||Ie[0]||null,we=K?"bottom":"right",ut=K?"end":"start",gt=K?4:8,C="flex items-center justify-center p-1 text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50",w=Pi({basename:typeof window<"u"&&window.__ROUTER_BASENAME__||"",returnPath:typeof window<"u"?Ri(window.location):"",projectPath:Yv(te)});return r.jsxs(r.Fragment,{children:[D&&us.createPortal(r.jsx(Bv,{onClose:()=>oe(!1),onProjectCreated:x=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),Xe&&us.createPortal(r.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:r.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[r.jsx("div",{className:"p-6",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:r.jsx(ro,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteProject")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:Xe.project.displayName||Xe.project.name}),"?"]}),Xe.sessionCount>0&&r.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[r.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:b("deleteConfirmation.sessionCount",{count:Xe.sessionCount})}),r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:b("deleteConfirmation.allConversationsDeleted")})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Ge,{variant:"outline",className:"flex-1",onClick:()=>P(null),children:b("actions.cancel")}),r.jsxs(Ge,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:j,children:[r.jsx(qn,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),B&&us.createPortal(r.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:r.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[r.jsx("div",{className:"p-6",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:r.jsx(ro,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteSession")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:B.sessionTitle||b("sessions.unnamed")}),"?"]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Ge,{variant:"outline",className:"flex-1",onClick:()=>me(null),children:b("actions.cancel")}),r.jsxs(Ge,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:Et,children:[r.jsx(qn,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),r.jsxs("div",{className:"h-full flex flex-col bg-muted/10 border-r border-border/60 md:select-none",style:Z&&K?{paddingTop:"44px"}:{},children:[r.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:Z&&K?{paddingTop:"16px"}:{},children:[r.jsxs("div",{className:"flex h-10 items-center justify-between gap-2 px-1",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[r.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-6 h-6 rounded-md flex-shrink-0"}),r.jsx("div",{className:"min-w-0",children:r.jsx("h1",{className:"text-sm font-semibold leading-none text-foreground truncate",children:b("app.title")})})]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[ae.topRowActionIds.includes(xt.THEME_TOGGLE)&&r.jsx(_a,{variant:"icon",className:C}),ae.topRowActionIds.includes(xt.HIDE_SIDEBAR)&&V&&r.jsx(Ge,{variant:"ghost",size:"sm",className:"flex h-auto w-auto shrink-0 bg-transparent p-1 text-muted-foreground transition-colors hover:text-foreground",onClick:V,title:b("tooltips.hideSidebar"),"aria-label":b("tooltips.hideSidebar"),children:r.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]})]}),r.jsxs("div",{className:"mt-1 flex flex-col px-1 space-y-0.5",children:[ae.primaryActionIds.includes(xt.NEW_SESSION)&&r.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:()=>te&&l(te),disabled:!te||u,children:[r.jsx(fo,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:b("sessions.newSession")})]}),ae.primaryActionIds.includes(xt.IMAGE_PLAYGROUND)&&r.jsxs("a",{href:w,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",title:b("imagePlayground.open"),"aria-label":b("imagePlayground.open"),children:[r.jsx(xi,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:b("imagePlayground.open")})]}),ae.primaryActionIds.includes(xt.REMOTE_ACCESS)&&r.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:Q,children:[r.jsx(gi,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:b("ccConnect.actions.open")||"Remote Access"})]})]}),r.jsxs("div",{className:"mt-3 flex items-center justify-between px-1",children:[r.jsx("div",{className:"text-sm font-medium text-foreground/85",children:b(ae.titleKey)}),r.jsxs("div",{className:"flex items-center gap-1",children:[ae.projectActionIds.includes(xt.NEW_PROJECT)&&r.jsx("button",{className:C,onClick:()=>oe(!0),title:b("projects.newProject"),"aria-label":b("projects.newProject"),children:r.jsx(Sr,{className:"h-4 w-4"})}),ae.projectActionIds.includes(xt.REFRESH)&&r.jsx("button",{className:C,onClick:async()=>{be(!0);try{await v()}finally{be(!1)}},disabled:he,title:b("actions.refresh")||"Refresh","aria-label":b("actions.refresh")||"Refresh",children:r.jsx(Ta,{className:yt("h-4 w-4",he&&"animate-spin")})}),ae.projectActionIds.includes(xt.THEME_TOGGLE)&&r.jsx(_a,{variant:"icon",className:C})]})]})]}),r.jsx(Ru,{className:"flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-2 py-2 md:px-3 md:py-2",children:r.jsx("div",{className:"space-y-1 overflow-x-hidden pb-safe-area-inset-bottom",children:u?r.jsx("div",{className:"flex min-h-[240px] items-start justify-center px-4 pt-10 md:min-h-[280px] md:px-6 md:pt-12",children:r.jsx("div",{className:"w-full max-w-[320px] text-center space-y-4",children:r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:f&&f.total>0?r.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${f.current/f.total*100}%`}}):r.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),f?.currentProject&&r.jsx("p",{className:"mx-auto max-w-[260px] break-words text-base font-medium leading-6 text-foreground",title:f.currentProject,children:f.currentProject.split("-").slice(-2).join("/")}),f&&f.total>0?r.jsxs("p",{className:"text-sm text-muted-foreground",children:[f.current,"/",f.total,r.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:b("projects.projects")})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.loadingProjects")})]})})}):e.length===0?r.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[r.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:r.jsx(pa,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.runClaudeCli")})]}):Ie.map(x=>{const I=$.has(x.name),S=t?.name===x.name,U=!!m?.[x.name],ce=p?.[x.name]||null,ze=de(x.name),ft=Ke.has(x.name),Ue=H&&x.name===Y,St=Ue||I,Ct=x.displayName||x.name,Kt=Jv(Ct,K?22:28);return r.jsxs("div",{className:yt("space-y-2",ft&&"pointer-events-none opacity-50"),children:[!Ue&&r.jsxs("div",{className:"group md:group",children:[r.jsx("div",{className:"md:hidden",children:r.jsxs("div",{className:yt("mx-1 flex min-h-10 items-center gap-2 px-2 py-2 text-muted-foreground transition-colors active:scale-[0.98]",S?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==x.name&&o(x),g(x)},onTouchEnd:fe(()=>{t?.name!==x.name&&o(x),g(x)}),children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:I?r.jsx(no,{className:yt("h-4 w-4",ze?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(pa,{className:yt("h-4 w-4",ze?"text-yellow-600 dark:text-yellow-400":S?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:ee===x.name?r.jsx("input",{type:"text",value:ve,onChange:X=>ue(X.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:b("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:X=>X.stopPropagation(),onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),X.stopPropagation(),ge(x.name)),X.key==="Escape"&&(X.preventDefault(),X.stopPropagation(),it())},style:{fontSize:"16px"}}):r.jsx("div",{className:yt(fa,S&&"font-semibold"),children:Kt})})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:ee===x.name?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:X=>{X.stopPropagation(),ge(x.name)},title:b("tooltips.save"),disabled:je===x.name,children:r.jsx(In,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:X=>{X.stopPropagation(),it()},title:b("tooltips.cancel"),children:r.jsx(on,{className:"h-3.5 w-3.5"})})]}):r.jsxs(Yr,{children:[r.jsx(Xr,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:X=>X.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(Jo,{className:"h-4 w-4"})})}),r.jsx(jr,{children:r.jsxs(Zr,{side:we,align:ut,sideOffset:gt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:X=>X.stopPropagation(),children:[r.jsxs(dn,{className:wr,onSelect:X=>{X.preventDefault(),De(x)},children:[r.jsx(bl,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),r.jsxs(dn,{className:wr,onSelect:X=>{X.preventDefault(),Ne(x.name)},children:[r.jsx(kl,{className:yt("h-4 w-4",ze&&"fill-yellow-400 text-yellow-500")}),b(ze?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(jl,{className:"my-1 h-px bg-border"}),r.jsxs(dn,{className:Xo,onSelect:X=>{X.preventDefault(),st(x)},children:[r.jsx(qn,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})}),r.jsxs("div",{role:"button",tabIndex:0,className:yt("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",ee===x.name?"h-auto":"h-9",S?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==x.name&&o(x),g(x)},onTouchEnd:fe(()=>{t?.name!==x.name&&o(x),g(x)}),onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&(X.preventDefault(),t?.name!==x.name&&o(x),g(x))},title:x.fullPath||Ct,children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:I?r.jsx(no,{className:yt("h-4 w-4",ze?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(pa,{className:yt("h-4 w-4",ze?"text-yellow-600 dark:text-yellow-400":S?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:ee===x.name?r.jsx("input",{type:"text",value:ve,onChange:X=>ue(X.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:b("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),X.stopPropagation(),ge(x.name)),X.key==="Escape"&&(X.preventDefault(),X.stopPropagation(),it())},onClick:X=>X.stopPropagation()}):r.jsx("div",{className:yt(fa,S&&"font-semibold"),children:Kt})})]}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:ee===x.name?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:X=>{X.stopPropagation(),ge(x.name)},title:b("tooltips.save"),disabled:je===x.name,children:r.jsx(In,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:X=>{X.stopPropagation(),it()},title:b("tooltips.cancel"),children:r.jsx(on,{className:"h-3.5 w-3.5"})})]}):r.jsxs(Yr,{children:[r.jsx(Xr,{asChild:!0,children:r.jsx("button",{className:yt("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:X=>X.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(Jo,{className:"h-4 w-4"})})}),r.jsx(jr,{children:r.jsxs(Zr,{side:we,align:ut,sideOffset:gt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:X=>X.stopPropagation(),children:[r.jsxs(dn,{className:wr,onSelect:X=>{X.preventDefault(),De(x)},children:[r.jsx(bl,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),r.jsxs(dn,{className:wr,onSelect:X=>{X.preventDefault(),Ne(x.name)},children:[r.jsx(kl,{className:yt("h-4 w-4",ze&&"fill-yellow-400 text-yellow-500")}),b(ze?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(jl,{className:"my-1 h-px bg-border"}),r.jsxs(dn,{className:Xo,onSelect:X=>{X.preventDefault(),st(x)},children:[r.jsx(qn,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})]}),St&&r.jsxs("div",{className:yt("space-y-1",Ue?"px-1 md:px-0":"px-0"),children:[ce&&!U?r.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-xs text-destructive transition-colors hover:bg-destructive/10",onClick:()=>{typeof y=="function"&&y(x.name,{background:!0,force:!0})},title:ce.message,children:[r.jsx(ro,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"min-w-0 truncate",children:b("sessions.loadFailed")})]}):!x.detailsLoaded||U?Array.from({length:3}).map((X,Ht)=>r.jsx("div",{className:"flex h-9 items-center rounded-lg px-3",children:r.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-muted",style:{width:`${60+Ht*15}%`}})},Ht)):Oe(x).length===0&&!W[x.name]?r.jsx("div",{className:"px-3 py-2 text-left",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:b("sessions.noSessions")})}):Oe(x).map(X=>{const Ht=X.__provider==="codex",jn=X.__provider==="gemini",Ft=X.__provider==="opencode",en=Ht||jn||Ft,gn=Ve===X.id&&!Ht,vn=n?.id===X.id,tn=Ht?X.summary||X.name||b("projects.codexSession"):Ft?X.summary||X.name||b("projects.opencodeSession"):X.summary||X.name||b("projects.newSession"),Ze=en&&X.createdAt||X.lastActivity,Gt=lt===X.id||Te===X.id;return r.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>ct(X.id),onMouseLeave:()=>ct(ke=>ke===X.id?null:ke),children:[r.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:r.jsxs("div",{className:yt("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",vn?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),onClick:()=>{o(x),ie(X,x.name)},onTouchEnd:fe(()=>{o(x),ie(X,x.name)}),children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:r.jsx(_l,{provider:X.__provider})}),r.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:gn?r.jsx("input",{type:"text",value:nt,onChange:ke=>Pe(ke.target.value),onKeyDown:ke=>{ke.stopPropagation(),ke.key==="Enter"?updateSessionSummary(x.name,X.id,nt):ke.key==="Escape"&&(He(null),Pe(""))},onClick:ke=>ke.stopPropagation(),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}):r.jsx("div",{className:fa,title:tn,children:tn})}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:gn?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:ke=>{ke.stopPropagation(),updateSessionSummary(x.name,X.id,nt)},title:b("tooltips.save"),children:r.jsx(In,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:ke=>{ke.stopPropagation(),He(null),Pe("")},title:b("tooltips.cancel"),children:r.jsx(on,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:r.jsxs(Yr,{children:[r.jsx(Xr,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md p-0 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:ke=>ke.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(Jo,{className:"h-4 w-4"})})}),r.jsx(jr,{children:r.jsxs(Zr,{side:we,align:ut,sideOffset:gt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:ke=>ke.stopPropagation(),children:[!Ht&&r.jsxs(dn,{className:wr,onSelect:ke=>{ke.preventDefault(),He(X.id),Pe(X.summary||X.name||b("projects.newSession"))},children:[r.jsx(wl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),r.jsxs(dn,{className:Xo,onSelect:ke=>{ke.preventDefault(),Re(x.name,X.id,tn,X.__provider)},children:[r.jsx(qn,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]})})})]})}),r.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:r.jsxs("div",{className:yt("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",vn?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),children:[r.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 overflow-hidden text-left",onClick:()=>ie(X,x.name),onTouchEnd:fe(()=>ie(X,x.name)),children:[r.jsx("span",{className:yt("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",vn||gn?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:r.jsx(_l,{provider:X.__provider})}),gn?r.jsx("input",{type:"text",value:nt,onChange:ke=>Pe(ke.target.value),onKeyDown:ke=>{ke.stopPropagation(),ke.key==="Enter"?updateSessionSummary(x.name,X.id,nt):ke.key==="Escape"&&(He(null),Pe(""))},onClick:ke=>ke.stopPropagation(),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}):r.jsx("span",{className:"block min-w-0 w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-sm text-foreground",title:tn,children:tn})]}),r.jsx("div",{className:"relative flex shrink-0 items-center justify-end pl-1 min-w-[28px]",children:gn?r.jsxs(r.Fragment,{children:[r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:ke=>{ke.stopPropagation(),updateSessionSummary(x.name,X.id,nt)},title:b("tooltips.save"),children:r.jsx(In,{className:"h-3.5 w-3.5"})}),r.jsx("button",{className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:ke=>{ke.stopPropagation(),He(null),Pe("")},title:b("tooltips.cancel"),children:r.jsx(on,{className:"h-3.5 w-3.5"})})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:yt("text-[11px] text-muted-foreground whitespace-nowrap transition-opacity duration-200",Gt?"opacity-0":"opacity-100"),children:Qv(Ze,se,b)}),Gt&&r.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 flex items-center justify-end",children:r.jsxs(Yr,{onOpenChange:ke=>Je(ke?X.id:null),children:[r.jsx(Xr,{asChild:!0,children:r.jsx("button",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md p-0 text-muted-foreground transition-all hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",onClick:ke=>ke.stopPropagation(),onFocus:()=>ct(X.id),"aria-label":b("actions.settings"),children:r.jsx(Jo,{className:"h-4 w-4"})})}),r.jsx(jr,{children:r.jsxs(Zr,{side:we,align:ut,sideOffset:gt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:ke=>ke.stopPropagation(),children:[!Ht&&r.jsxs(dn,{className:wr,onSelect:ke=>{ke.preventDefault(),He(X.id),Pe(X.summary||X.name||b("projects.newSession"))},children:[r.jsx(wl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),r.jsxs(dn,{className:Xo,onSelect:ke=>{ke.preventDefault(),Re(x.name,X.id,tn,X.__provider)},children:[r.jsx(qn,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]})})]})})]})})]},X.id)}),x.detailsLoaded&&Oe(x).length>0&&x.sessionMeta?.hasMore!==!1&&r.jsx(Ge,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>M(x),disabled:W[x.name],children:W[x.name]?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),b("sessions.loading")]}):r.jsxs(r.Fragment,{children:[r.jsx(pi,{className:"w-3 h-3"}),b("sessions.showMore")]})})]})]},x.name)})})}),_&&r.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[r.jsx("div",{className:"hidden md:block",children:r.jsxs(Ge,{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:q,children:[r.jsxs("div",{className:"relative",children:[r.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})}),r.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:z?.title||`Version ${N}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})}),r.jsx("div",{className:"md:hidden p-3 pb-2",children:r.jsxs("button",{className:"flex h-12 w-full items-center justify-start gap-3 rounded-xl bg-blue-50 dark:bg-blue-900/20 px-4 transition-all duration-150 active:scale-[0.98]",onClick:q,children:[r.jsxs("div",{className:"relative",children:[r.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})}),r.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),r.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[r.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:z?.title||`Version ${N}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})})]})]})]})}function Xv(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Pl(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:Xv(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function Tl(e,t){return e||""}function Zv(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 e0(e,t,n){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof n=="string"?n:""}function t0(e,t,n,o){const s=e0(e,t,t),a=Tl(s);if(e==="Bash"){const l=t?.command||"";return{activityKind:"command",title:o("activity.actions.runCommand"),summary:Zv(l)||o("activity.actions.commandPending"),filePath:s,icon:id,heavy:!0}}if(e==="Grep"||e==="Glob"){const l=t?.pattern||t?.glob||"",c=Tl(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:nf,heavy:!1}}return e==="Read"?{activityKind:"read",title:o("activity.actions.readFile"),summary:a||o("activity.actions.readPending"),filePath:s,icon:ph,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:o("activity.actions.updateFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:lh,heavy:!0}:e==="Write"?{activityKind:"write",title:o("activity.actions.createFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:dh,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:o("activity.actions.updateTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:yl,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:o("activity.actions.readTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:yl,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:o("activity.actions.generatePlan"),summary:o("activity.actions.planSummary"),filePath:"",icon:Xc,heavy:!0}:{activityKind:"tool",title:o("activity.actions.runTool"),summary:e,filePath:s,icon:rf,heavy:!0}}function n0({status:e,messages:t=[],pendingPermissionRequests:n=[],t:o}){if(n.length>0){const a=n[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&&!Pl(s.toolResult)&&!s.toolEndedAt){const a=mi(s.toolInput)||{},l=Pl(s.toolResult),c=t0(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 F={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",AWAITING_INPUT:"awaiting_input",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},vs=new Set([F.CONNECTING,F.QUEUED,F.STREAMING,F.AWAITING_APPROVAL,F.AWAITING_INPUT]),sn=new Set([F.COMPLETED,F.ABORTED,F.ERRORED]);function oo(e){return sn.has(Ut(e,null))}function At(e){return e==null?"":String(e).replace(/\r\n/g,`
|
|
198
|
+
`).trim()}function Fa(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:At(e.content),isError:!!e.isError}}function r0(e,t){if(!e||!t)return!1;const n=String(e.type||""),o=String(t.type||"");if(n!==o)return!1;const s=!!e.isToolUse,a=!!t.isToolUse;if(s!==a)return!1;if(s&&a){const l=Fa(e.toolResult),c=Fa(t.toolResult);return At(e.toolName)===At(t.toolName)&&At(e.toolInput)===At(t.toolInput)&&l.content===c.content&&l.isError===c.isError}return!!e.isThinking!=!!t.isThinking?!1:At(e.content)===At(t.content)}function o0(e,t){const n=Math.min(e.length,t.length);let o=0;for(;o<n&&r0(e[o],t[o]);)o+=1;return o}function sr(e){const t=e?.clientRequestId||e?.extensions?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function s0(e){return String(e?.type||"").trim().toLowerCase()==="user"&&!!sr(e)}function Ti(e,t){const n=sr(t),o=At(t?.content),s=At(t?.provider||t?.__provider).toLowerCase();return e.some(a=>{if(String(a?.type||"").trim().toLowerCase()!=="user")return!1;const l=sr(a);if(n&&l===n)return!0;if(!o||At(a?.content)!==o)return!1;const c=At(a?.provider||a?.__provider).toLowerCase();return!s||!c||s===c})}function Ir(e){return String(e?.type||"").trim().toLowerCase()==="user"}function $a(e){if(!Array.isArray(e))return"[]";try{return JSON.stringify(e)}catch{return String(e)}}function Ml(e){return Array.isArray(e)?$a(e.map(t=>({data:t?.data||t?.image||"",mimeType:t?.mimeType||"application/octet-stream",name:t?.name||t?.filename||""}))):"[]"}function a0(e,t){if(!Ir(e)||!Ir(t))return!1;const n=At(e?.content),o=At(t?.content);if(!n||n!==o)return!1;const s=At(e?.provider||e?.__provider).toLowerCase(),a=At(t?.provider||t?.__provider).toLowerCase();if(s&&a&&s!==a||$a(e?.contentBlocks)!==$a(t?.contentBlocks)||Ml(e?.images)!==Ml(t?.images))return!1;const l=sr(e),c=sr(t);return l&&c?l===c:!!(l||c)}function i0(e,t){return{...e,provider:e?.provider||t?.provider,__provider:e?.__provider||t?.__provider,clientRequestId:sr(e)||sr(t),contentBlocks:Array.isArray(e?.contentBlocks)&&e.contentBlocks.length>0?e.contentBlocks:t?.contentBlocks,images:Array.isArray(e?.images)&&e.images.length>0?e.images:t?.images,eventId:e?.eventId||t?.eventId,appliedConversationEventIds:[...Array.isArray(e?.appliedConversationEventIds)?e.appliedConversationEventIds:[],...Array.isArray(t?.appliedConversationEventIds)?t.appliedConversationEventIds:[],...t?.eventId?[t.eventId]:[]].filter(Boolean)}}function Dl(e=[]){const t=Array.isArray(e)?e:[],n=[];let o=0;for(const s of t){if(!Ir(s)){n.push(s),o=n.length;continue}let a=-1;for(let l=n.length-1;l>=o;l-=1)if(a0(n[l],s)){a=l;break}a>=0?n[a]=i0(n[a],s):n.push(s)}return n}function ys(e){return String(e?.type||"").trim().toLowerCase()!=="assistant"||e?.isLoadingIndicator?!1:e?.isToolUse||e?.isThinking||e?.reasoning?!0:!!At(e?.content)}function Xn(e){return e.filter(ys).length}function l0(e){if(!ys(e))return null;if(e?.isToolUse){const t=Fa(e.toolResult);return["tool",At(e.toolName),At(e.toolInput),t.content,t.isError?"error":"ok"].join("\0")}return[e?.isThinking||e?.reasoning?"reasoning":"answer",At(e.content||e.reasoning)].join("\0")}function c0(e,t){e.set(t,(e.get(t)||0)+1)}function Ll(e){const t=new Map;return e.forEach(n=>{const o=l0(n);o&&c0(t,o)}),t}function d0(e,t){const n=Ll(e);if(n.size===0)return!1;const o=Ll(t);if(o.size===0)return!1;for(const[s,a]of o.entries()){const l=n.get(s)||0;if(l===0||a<l)return!1}for(const s of n.keys())if(!o.has(s))return!1;return!0}function Ol(e,t){const n=e.filter(Ir),o=t.filter(Ir);return o.length===0||o.length>n.length?!1:o.every(s=>Ti(n,s))}function u0(e,t){const n=e.filter(s=>s0(s)&&!Ti(t,s));if(n.length===0)return t;if(t.length===0)return n;const o=t.findIndex(s=>String(s?.type||"").trim().toLowerCase()!=="user");return o<0?[...t,...n]:[...t.slice(0,o),...n,...t.slice(o)]}function Fl(e){const t=e?.timestamp;if(t instanceof Date){const n=t.getTime();return Number.isFinite(n)?n:0}return normalizeTimeMs(t)}function p0(e,t){const n=At(t?.content);if(n){const a=e.findIndex(l=>{if(!ys(l))return!1;const c=At(l?.content||l?.reasoning);return!!(c&&n.includes(c))});if(a>=0)return a}const o=Fl(t);if(o>0){const a=e.findIndex(l=>ys(l)&&Fl(l)>=o);if(a>=0)return a}const s=e.findIndex(a=>String(a?.type||"").trim().toLowerCase()!=="user");return s>=0?s:e.length}function m0(e,t){return t.filter(Ir).reduce((n,o)=>{if(Ti(n,o))return n;const s=p0(n,o);return[...n.slice(0,s),o,...n.slice(s)]},e)}function f0(e=[],t=[],n={}){const o=Dl(e),s=Dl(t),a=!!n.preserveLocalTail,l=!!n.preserveLocalAssistantReplies;if(o.length===0)return s;if(s.length===0)return a||l&&Xn(o)>0?o:s;const c=o0(o,s);return c===o.length&&c===s.length?s:a&&c===s.length&&o.length>s.length||l&&Xn(o)>Xn(s)&&Ol(o,s)?o:l&&Xn(o)>Xn(s)?m0(o,s):l&&Xn(s)>Xn(o)&&Ol(o,s)&&d0(o,s)?o:u0(o,s)}function Kr(e,t){return typeof t=="function"?t(e):t}function $l(e,t={}){const n=vs.has(e),o=vs.has(e);return{isLoading:n,canAbortSession:o,...t}}function Ut(e,t=F.IDLE){const n=String(e||"").trim().toLowerCase();return Object.values(F).includes(n)?n:t}function za(e){return String(e?.rawRef?.type||"").trim().toLowerCase()==="session-status"}function Ba(e){if(!e||e.kind!==qe.SESSION_STATE_CHANGED||Ut(e.payload?.state,null)!==F.IDLE)return!1;const n=String(e.rawRef?.sourceType||"").trim().toLowerCase();return n==="acp-session-loaded-idle"||n==="acp-prompt-idle"}function h0(e=[],t=0){for(let n=t-1;n>=0;n-=1){const o=e[n];if(!(!o||typeof o!="object")){if(Ba(o))return!0;if(o.kind===qe.SESSION_STATE_CHANGED)return!1}}return!1}function Ou(e){return e===qe.APPROVAL_REQUEST||e===qe.APPROVAL_RESOLVED||e===qe.ELICITATION_REQUEST||e===qe.ELICITATION_RESOLVED||e===qe.ASSISTANT_TEXT_START||e===qe.ASSISTANT_TEXT_DELTA||e===qe.ASSISTANT_CONTENT_BLOCK||e===qe.REASONING_START||e===qe.REASONING_DELTA||e===qe.TOOL_CALL_START||e===qe.TOOL_CALL_INPUT||e===qe.TOOL_CALL_END||e===qe.TOOL_RESULT||e===qe.PLAN_UPDATE||e===qe.SYSTEM_NOTICE}function x0(e=[]){let t=!1,n=!1;for(let o=e.length-1;o>=0;o-=1){const s=e[o];if(!(!s||typeof s!="object")){if(Ba(s))return F.IDLE;if(s.kind===qe.ERROR)return n?F.IDLE:F.ERRORED;if(s.kind===qe.SESSION_STATE_CHANGED){const a=Ut(s.payload?.state,null);if(!a)continue;if(a===F.IDLE){if(Ba(s)&&(n=!0),za(s)){t=!0;continue}return F.IDLE}if(sn.has(a))return n?F.IDLE:a;if(za(s))continue;return t||n?F.IDLE:a}if(s.kind===qe.APPROVAL_REQUEST)return t||n?F.IDLE:F.AWAITING_APPROVAL;if(s.kind===qe.ELICITATION_REQUEST)return t||n?F.IDLE:F.AWAITING_INPUT;if(s.kind===qe.APPROVAL_RESOLVED||s.kind===qe.ELICITATION_RESOLVED||Ou(s.kind))return t||n||h0(e,o)?F.IDLE:F.STREAMING}}return t||n?F.IDLE:null}function g0(e=[]){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(!(!n||typeof n!="object")){if(n.kind===qe.ERROR)return F.ERRORED;if(n.kind===qe.SESSION_STATE_CHANGED){const o=Ut(n.payload?.state,null);if(!o||o===F.IDLE||za(n))continue;return sn.has(o)?o:null}if(Ou(n.kind))return null}}return null}function v0({recoveredPhase:e=null,recoveredPhaseFromHistory:t=null}={}){const n=Ut(t,null);if(n&&sn.has(n))return n;const o=Ut(e,null);return o&&sn.has(o)?o:F.IDLE}function y0({terminalPhase:e=null,recoveredPhaseFromHistory:t=null}={}){const n=Ut(t,null);if(n===F.IDLE||sn.has(n))return n;const o=Ut(e,null);return o&&sn.has(o)?o:n||F.IDLE}function b0({shouldBeProcessing:e=!1,isLoading:t=!1,recoveredPhase:n=null,runtimePhase:o=null}={}){if(!e||t)return!1;const s=Ut(n,null);if(s===F.IDLE||sn.has(s))return!1;const a=Ut(o,null);return!sn.has(a)}function bs(e){return typeof e=="string"&&e.trim()?e.trim():null}function w0({recoveredPhase:e=null,runtimePhase:t=null,recoveredSessionId:n=null,currentSessionId:o=null}={}){const s=Ut(e,null);if(!s)return!1;const a=Ut(t,null);if(sn.has(a)&&s!==F.IDLE&&!sn.has(s)){const l=bs(n),c=bs(o);if(!l||!c||l===c)return!1}return!0}function k0({terminalRunState:e=null,sessionId:t=null,nowMs:n=Date.now(),maxAgeMs:o=12e4}={}){const s=bs(e?.sessionId),a=bs(t);if(!s||!a||s!==a||!oo(e?.phase))return!1;const l=Number(e?.updatedAt||0),c=Number(n),d=Number(o);return!Number.isFinite(l)||l<=0||!Number.isFinite(c)||!Number.isFinite(d)?!1:c-l<=d}function S0(e,t){return!e||typeof e!="object"?t:e.kind===qe.SESSION_STATE_CHANGED?Ut(e.payload?.state,t):e.kind===qe.APPROVAL_REQUEST?F.AWAITING_APPROVAL:e.kind===qe.ELICITATION_REQUEST?F.AWAITING_INPUT:e.kind===qe.APPROVAL_RESOLVED||e.kind===qe.ELICITATION_RESOLVED?F.STREAMING:e.kind===qe.ERROR?F.ERRORED:e.kind===qe.ASSISTANT_TEXT_START||e.kind===qe.ASSISTANT_TEXT_DELTA||e.kind===qe.ASSISTANT_CONTENT_BLOCK||e.kind===qe.REASONING_START||e.kind===qe.REASONING_DELTA||e.kind===qe.TOOL_CALL_START||e.kind===qe.TOOL_CALL_INPUT||e.kind===qe.TOOL_CALL_END||e.kind===qe.TOOL_RESULT||e.kind===qe.PLAN_UPDATE||e.kind===qe.ELICITATION_RESOLVED||e.kind===qe.SYSTEM_NOTICE?F.STREAMING:t}function j0(e,t){const n=t?.payload||{},o=n.requestId||t?.extensions?.requestId||null,s=n.toolCall&&typeof n.toolCall=="object"?n.toolCall:null,a=Array.isArray(n.options)?n.options:Array.isArray(n.context?.options)?n.context.options:[];return!o||e.some(l=>l?.requestId===o)?e:[...e,{requestId:o,toolName:s?.title||n.toolName||"UnknownTool",input:s?.rawInput??n.input,context:{...n.context||{},kind:s?.kind||n.context?.kind||null,options:a},toolCall:s,options:a,message:n.message||null,sessionId:t?.sessionId||n.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function C0(e,t){const o=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return o?e.filter(s=>s?.requestId!==o):e}function N0(e,t){const n=t?.payload||{},o=n.requestId||t?.extensions?.requestId||null;return!o||e.some(s=>s?.requestId===o)?e:[...e,{requestId:o,mode:n.mode||"form",message:n.message||"",requestedSchema:n.requestedSchema&&typeof n.requestedSchema=="object"?n.requestedSchema:null,url:n.url||null,elicitationId:n.elicitationId||null,scope:n.scope&&typeof n.scope=="object"?n.scope:{},sessionId:t?.sessionId||n.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function E0(e,t){const o=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return o?e.filter(s=>s?.requestId!==o):e}function I0(e,t){return t?sn.has(e)||e===F.AWAITING_APPROVAL||e===F.AWAITING_INPUT||vs.has(e)?e:F.STREAMING:e===F.COMPLETED||e===F.ABORTED||e===F.ERRORED?e:F.IDLE}function A0(e=[]){return{messages:e,pendingPermissionRequests:[],pendingElicitationRequests:[],phase:F.IDLE,isLoading:!1,canAbortSession:!1}}function _0(e,t){switch(t.type){case"replace_messages":return{...e,messages:Kr(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Kr(e.pendingPermissionRequests,t.value)};case"replace_elicitations":return{...e,pendingElicitationRequests:Kr(e.pendingElicitationRequests,t.value)};case"set_phase":{const n=Ut(t.phase,e.phase);return{...e,phase:n,...$l(n,t.overrides)}}case"set_loading":{const n=!!Kr(e.isLoading,t.value);if(n&&sn.has(Ut(e.phase,null)))return e;const o=I0(e.phase,n);return{...e,phase:o,isLoading:n,canAbortSession:n?e.canAbortSession||vs.has(o):!1}}case"set_can_abort":return{...e,canAbortSession:!!Kr(e.canAbortSession,t.value)};case"apply_conversation_event":{const n=of(e.messages,t.event,t.provider),o=t.suppressPhase?e.phase:S0(t.event,e.phase);let s=e.pendingPermissionRequests,a=e.pendingElicitationRequests;if(t.event?.kind===qe.APPROVAL_REQUEST)s=j0(s,t.event);else if(t.event?.kind===qe.APPROVAL_RESOLVED)s=C0(s,t.event);else if(t.event?.kind===qe.ELICITATION_REQUEST)a=N0(a,t.event);else if(t.event?.kind===qe.ELICITATION_RESOLVED)a=E0(a,t.event);else if(t.event?.kind===qe.SESSION_STATE_CHANGED){const l=Ut(t.event?.payload?.state,"");(l===F.COMPLETED||l===F.ABORTED||l===F.ERRORED||l===F.IDLE)&&(s=[],a=[])}return{...e,messages:n,pendingPermissionRequests:s,pendingElicitationRequests:a,phase:o,...$l(o)}}default:return e}}const R0=({node:e,inline:t,className:n,children:o,...s})=>{const{t:a}=Ot("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 r.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${n||""}`,...s,children:o});const f=/language-(\w+)/.exec(n||""),y=f?f[1]:"text",v=d,_=()=>{const N=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator?.clipboard?.writeText)navigator.clipboard.writeText(v).then(N).catch(()=>{const E=document.createElement("textarea");E.value=v,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy")}catch{}document.body.removeChild(E),N()});else{const E=document.createElement("textarea");E.value=v,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy")}catch{}document.body.removeChild(E),N()}}catch{}};return r.jsxs("div",{className:"relative group my-2",children:[y&&y!=="text"&&r.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:y}),r.jsx("button",{type:"button",onClick:_,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?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),a("codeBlock.copied")]}):r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),a("codeBlock.copy")]})}),r.jsx(pf,{language:y,style:mf,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:y&&y!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},P0={code:R0,blockquote:({children:e})=>r.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),a:({href:e,children:t})=>r.jsx("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:t}),p:({children:e})=>r.jsx("div",{className:"mb-2 last:mb-0",children:e}),table:({children:e})=>r.jsx("div",{className:"overflow-x-auto my-2",children:r.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>r.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>r.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:e}),td:({children:e})=>r.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})},Ua=({children:e,className:t})=>{const n=sf(af(String(e??""))),o=i.useMemo(()=>[lf,cf],[]),s=i.useMemo(()=>[df],[]);return r.jsx("div",{className:t,children:r.jsx(uf,{remarkPlugins:o,rehypePlugins:s,components:P0,children:n})})};i.memo(({message:e,prevMessage:t,provider:n,showThinking:o,isActiveStreamingCard:s})=>{const{t:a}=Ot("chat"),l=e.provider||e.__provider||n||"claude",c=l==="codex",d=l==="gemini",u=l==="opencode",m=t&&t.type===e.type&&(t.type==="assistant"||t.type==="user"||t.type==="tool"||t.type==="error");return r.jsx("div",{className:`chat-message ${e.type} ${m?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?r.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[r.jsxs("div",{className:"bg-primary text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[r.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&r.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((p,f)=>r.jsx("img",{src:p.data,alt:p.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(p.data,"_blank")},f))}),r.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!m&&r.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-primary rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):r.jsxs("div",{className:"w-full",children:[!m&&r.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.type==="error"?r.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):e.type==="tool"?r.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:c?r.jsx(ko,{className:"w-full h-full"}):d?r.jsx(So,{className:"w-full h-full"}):u?r.jsx(jo,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):r.jsx(wo,{className:"w-full h-full"})}),r.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")})]}),r.jsxs("div",{className:"w-full",children:[e.isToolUse?r.jsx(ff,{toolName:e.toolName||"Tool",argsText:typeof e.toolInput=="string"?e.toolInput:JSON.stringify(e.toolInput??{},null,2),result:e.toolResult,isError:!!(e.toolResult?.isError||e.isError),status:e.isStreaming||e.toolResult==null?{type:"running"}:e.toolResult?.isError||e.isError?{type:"incomplete",reason:"error"}:{type:"complete"}}):e.isThinking?r.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:r.jsxs("details",{className:"group",open:s,children:[r.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[r.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r.jsx("span",{children:a("thinking.emoji")})]}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:r.jsx(Ua,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):r.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[o&&e.reasoning&&r.jsxs("details",{className:"mb-3",open:s,children:[r.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:a("thinking.emoji")}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:r.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const p=hf(Ra(String(e.content||""))),f=p.trim();if((f.startsWith("{")||f.startsWith("["))&&(f.endsWith("}")||f.endsWith("]")))try{const y=JSON.parse(f),v=JSON.stringify(y,null,2);return r.jsxs("div",{className:"my-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),r.jsx("span",{className:"font-medium",children:"JSON Response"})]}),r.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:r.jsx("pre",{className:"p-4 overflow-x-auto",children:r.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:v})})})]})}catch{}return e.type==="assistant"?r.jsx(Ua,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:p}):r.jsx("div",{className:"whitespace-pre-wrap",children:p})})()]}),r.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${m?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});function T0({hasSelectedProject:e=!1,hasMessages:t=!1,hasSessionContext:n=!1,hasLoadedSessionMessages:o=!1,hasHydratedSessionMessages:s=!1,isLoading:a=!1,isLoadingSessionMessages:l=!1}={}){return e?t||a?"messages":l||n&&(s||!o)?"loading-session-messages":n?"continue":"provider-selection":"no-project"}function M0({canAbortSession:e=!1,hasInput:t=!1,isInputDisabled:n=!1,isLoading:o=!1,pendingQueueCount:s=0,pendingQueueLimit:a=3}={}){const l=s>=a;return o&&t?{buttonType:"button",kind:"submit",disabled:n||l}:o&&e?{buttonType:"button",kind:"stop",disabled:!1}:{buttonType:"button",kind:"submit",disabled:o||!t||n||l}}function D0({discoveredSessionId:e=null,currentSessionId:t=null,selectedSessionId:n=null,pendingViewSessionId:o=null}={}){const s=String(e||"").trim();if(!s)return!1;const a=String(t||"").trim(),l=String(n||"").trim(),c=String(o||"").trim();return a||l?!1:!c||c===s}function L0({discoveredSessionId:e=null,activeViewSessionId:t=null,hasActiveViewSession:n=!1,hasPendingViewSession:o=!1,isActiveRunMessage:s=!1,pendingViewSessionId:a=null}={}){const l=String(e||"").trim();if(!l)return!1;const c=String(t||"").trim();if(n)return!!(s&&c&&l===c);const d=String(a||"").trim();return o?!d||d===l:!!s}function O0({modes:e=[],disabled:t=!1}={}){return(Array.isArray(e)?e.filter(o=>o?.id):[]).length>1&&!t}function F0({nextState:e=null,previousState:t=null}={}){return e==="continue"&&t!==null&&t!=="continue"}function $0({isOpen:e=!1,commands:t=[]}={}){return!!e}function z0(e){return String(e||"").trim().replace(/^\//,"").toLowerCase()}function B0(e){const t=String(e||"").trim();return t?t.startsWith("/")?t:`/${t}`:""}function U0({skillCommands:e=[],acpCommands:t=[],apiCommands:n=[]}={}){const o=[],s=new Set;for(const a of[e,t,n]){const l=Array.isArray(a)?a:[];for(const c of l){const d=B0(c?.name),u=z0(d);!u||s.has(u)||(s.add(u),o.push({...c,name:d}))}}return o}function q0({hasSlashCommands:e=!1}={}){return e?"input.placeholder":"input.placeholderWithoutCommands"}function W0({hasSlashCommands:e=!1,sendByCtrlEnter:t=!1}={}){return e?t?"input.hintText.ctrlEnter":"input.hintText.enter":t?"input.hintText.ctrlEnterWithoutCommands":"input.hintText.enterWithoutCommands"}function Fu(e,t){return Number.isInteger(e)&&e>=0&&e<t?e:-1}function K0(e=[],t=-1){const n=Array.isArray(e)?e:[],o=Fu(t,n.length),s=o>=0?n[o]:null;return{activeImage:s,activeIndex:o,isOpen:s!==null}}const H0=Av,$u=i.forwardRef(({className:e,...t},n)=>r.jsx(Eu,{ref:n,className:yt("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...t}));$u.displayName=Eu.displayName;const zu=i.forwardRef(({className:e,...t},n)=>r.jsx(Iu,{ref:n,className:yt("inline-flex items-center justify-center whitespace-nowrap rounded-lg px-3 py-2 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));zu.displayName=Iu.displayName;const G0=i.forwardRef(({className:e,...t},n)=>r.jsx(Au,{ref:n,className:yt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...t}));G0.displayName=Au.displayName;const V0=[{id:"claude",label:"Claude Code",Logo:wo},{id:"codex",label:"Codex",Logo:ko},{id:"gemini",label:"Gemini",Logo:So},{id:"opencode",label:"OpenCode",Logo:jo}],Q0="h-[1em] w-[1em] flex-shrink-0",J0="h-[1em] w-auto max-w-[1.25em] flex-shrink-0 text-current";function Y0({provider:e,onSelect:t}){return r.jsx(H0,{value:e,onValueChange:t,className:"flex justify-center",children:r.jsx($u,{className:"h-auto flex-col items-stretch sm:h-10 sm:flex-row sm:items-center",children:V0.map(({id:n,label:o,Logo:s})=>r.jsxs(zu,{value:n,className:"justify-start gap-1.5",children:[r.jsx("span",{"aria-hidden":"true",className:"inline-flex items-center justify-center leading-none",children:r.jsx(s,{className:n==="opencode"?J0:Q0})}),r.jsx("span",{children:o})]},n))})})}function X0(e,t){const n=e.split(`
|
|
199
|
+
`),o=t.split(`
|
|
200
|
+
`),s=[];let a=0,l=0;for(;a<n.length||l<o.length;){const c=n[a],d=o[l];a>=n.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 Z0({selectedProject:e,selectedSession:t,currentSessionId:n,provider:o,chatMessages:s,threadMessages:a,isLoading:l,statusPresentation:c,shouldShowClaudeStatus:d,isLoadingSessionMessages:u,isLoadingMoreMessages:m,hasMoreMessages:p,totalMessages:f,sessionMessages:y,hasLoadedSessionMessages:v=!1,hasHydratedSessionMessages:_=!1,visibleMessageCount:N,pendingPermissionRequests:E,pendingElicitationRequests:z,scrollContainerRef:q,messagesEndRef:Z,onScroll:K,onLoadEarlierSessionMessages:V,onLoadEarlierMessages:T,onProviderSelection:Y,onFileOpen:D,onShowSettings:oe,onGrantToolPermission:Q,onPermissionDecision:b,onElicitationDecision:$,autoExpandTools:L,showThinking:ee,showRawParameters:le}){const{t:ve}=Ot("chat"),ue=o==="codex"?"Codex":o==="gemini"?"Gemini":o==="opencode"?"OpenCode":"Claude",W=i.useMemo(()=>{const je=new Map;return(Be,Ve)=>{const He=`${Be.length}-${Ve.length}-${Be.slice(0,50)}`;if(je.has(He))return je.get(He);const nt=X0(Be,Ve);if(je.set(He,nt),je.size>100){const Pe=je.keys().next().value;je.delete(Pe)}return nt}},[]),Se=i.useMemo(()=>xf(a),[a]),Ce=i.useMemo(()=>gf(a),[a]),Ae=s.length===0?null:r.jsxs(r.Fragment,{children:[m&&r.jsx("div",{className:"pb-3 text-center text-gray-500 dark:text-gray-400",children:r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),r.jsx("p",{className:"text-sm",children:ve("session.loading.olderMessages")})]})}),p&&!m&&r.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:f>0&&r.jsxs("span",{children:[ve("session.messages.showingOf",{shown:y.length,total:f})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:V,children:ve("session.messages.loadEarlier")}),r.jsx("span",{className:"ml-1 text-xs",children:ve("session.messages.scrollToLoad")})]})}),!t&&!p&&s.length>N&&r.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[ve("session.messages.showingLast",{count:N,total:s.length})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:T,children:ve("session.messages.loadEarlier")})]})]}),se=s.length===0?null:r.jsxs(r.Fragment,{children:[r.jsx(vf,{phaseText:c?.phaseText,elapsedSeconds:c?.elapsedSeconds,startedAt:c?.startedAt,isLoading:d,className:"max-w-[var(--thread-max-width,46rem)]"}),E.map(je=>r.jsx(yf,{request:je,className:"mx-1 my-3 sm:mx-0",onSelectOption:Be=>b(je.requestId,{optionId:Be,outcome:{outcome:"selected",optionId:Be}}),onCancel:()=>b(je.requestId,{cancelled:!0,outcome:{outcome:"cancelled"}})},je.requestId)),z.map(je=>r.jsx(bf,{request:je,className:"mx-1 my-3 sm:mx-0",onSubmit:Be=>$(je.requestId,{action:"accept",content:Be}),onDecline:()=>$(je.requestId,{action:"decline"}),onCancel:()=>$(je.requestId,{action:"cancel"})},je.requestId))]}),J=T0({hasSelectedProject:!!e,hasMessages:s.length>0,hasSessionContext:!!(t||n),hasLoadedSessionMessages:v,hasHydratedSessionMessages:_,isLoading:l,isLoadingSessionMessages:u}),pe=i.useRef(J),[xe,he]=i.useState(J);i.useEffect(()=>{const je=pe.current;if(pe.current=J,xe===J)return;if(!F0({nextState:J,previousState:je})){he(J);return}const Be=window.setTimeout(()=>{he(J)},180);return()=>{window.clearTimeout(Be)}},[J,xe]);const be=e&&xe==="no-project"?J:xe;return e?r.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:be==="loading-session-messages"?r.jsx("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-gray-400 sm:px-6 sm:py-5 mt-8",children:r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),r.jsx("p",{children:ve("session.loading.sessionMessages")})]})}):be==="provider-selection"?r.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"w-full max-w-3xl text-center",children:[r.jsx("h2",{className:"mb-2 text-3xl font-semibold tracking-tight text-foreground sm:text-4xl",children:ve("providerSelection.title")}),r.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:ve("providerSelection.description")}),r.jsx(Y0,{provider:o,onSelect:Y})]})}):be==="continue"?r.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:[r.jsx("p",{className:"mb-3 text-2xl font-semibold text-foreground",children:ve("session.continue.title")}),r.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:ve("session.continue.description")})]})}):r.jsxs(r.Fragment,{children:[r.jsx(wf,{messages:Ce,convertMessage:kf,isRunning:l,scrollContainerRef:q,onScroll:K,messagesEndRef:Z,provider:o,providerLabel:ue,createDiff:W,onFileOpen:D,onShowSettings:oe,onGrantToolPermission:Q,showThinking:ee,showRawParameters:le,autoExpandTools:L,selectedProject:e,markdownRenderer:Ua,topContent:Ae,bottomContent:se}),r.jsx(Sf,{planData:Se})]})}):r.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"max-w-lg px-8 py-10 text-center text-muted-foreground",children:[r.jsx("div",{className:"mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:r.jsx(gi,{className:"h-7 w-7"})}),r.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})})}const un=({children:e,content:t,position:n="top",className:o="",delay:s=500})=>{const[a,l]=i.useState(!1),[c,d]=i.useState(null),u=()=>{const y=setTimeout(()=>{l(!0)},s);d(y)},m=()=>{c&&(clearTimeout(c),d(null)),l(!1)},p=()=>{switch(n){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},f=()=>{switch(n){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return t?r.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:m,children:[e,a&&r.jsxs("div",{className:yt("absolute z-50 w-max max-w-[min(32rem,calc(100vw-2rem))] px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-normal break-words pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",p(),o),children:[t,r.jsx("div",{className:yt("absolute w-0 h-0 border-4 border-transparent",f())})]})]}):e};function ey(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ty(e){if(typeof e!="string")return"";const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]||e}const Ar="1",zl=5,Bl="replace",qa="append",nn="comments";function fn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Sn(e){return typeof e=="string"&&e.trim().length>0}function kr(e){return typeof e!="string"?void 0:e.trim()||void 0}function ny(e){if(!fn(e))return;const t={};for(const[n,o]of Object.entries(e))if(typeof o=="string"){const s=o.trim();s&&(t[n]=s)}else(typeof o=="number"||typeof o=="boolean"||o===null)&&(t[n]=o);return Object.keys(t).length>0?t:void 0}function ry(e){if(!fn(e))return null;const t=kr(e.id),n=kr(e.body);if(!t||!n)return null;const o={id:t,body:n},s=kr(e.origin);s&&(o.origin=s);const a=ny(e.target);a&&(o.target=a);const l=kr(e.preview);l&&(o.preview=l);const c=kr(e.updatedAt);return c&&(o.updatedAt=c),o}function ws(e){if(!Array.isArray(e))return[];const t=new Map;for(const n of e){const o=ry(n);o&&t.set(o.id,o)}return Array.from(t.values())}function Mi(e){return ws(e?.extensions?.[nn])}function uo(e){if(!fn(e))return;const t={...e};if(Object.prototype.hasOwnProperty.call(t,nn)){const n=ws(t[nn]);n.length>0?t[nn]=n:delete t[nn]}return Object.keys(t).length>0?t:void 0}function oy(e,t){const n=new Map;for(const o of ws(e))n.set(o.id,o);for(const o of ws(t))n.set(o.id,o);return Array.from(n.values())}function sy(e,t){const n=uo(e)||{},o=uo(t)||{},s={...n,...o};if(Object.prototype.hasOwnProperty.call(n,nn)||Object.prototype.hasOwnProperty.call(o,nn)){const a=oy(n[nn],o[nn]);a.length>0?s[nn]=a:delete s[nn]}return Object.keys(s).length>0?s:void 0}function Wa(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function Bs(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!fn(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 ar(e){return Bs(e)?.path||""}function ay(e){const t=Bs(e);return t?Sn(t.displayName)?t.displayName:ty(t.path):""}function iy(e,t=72){if(typeof e!="string")return"";const n=e.trim().replace(/\s+/g," ");if(n.length<=t)return n;const o=n.split(/\s*>\s*/).filter(Boolean);if(o.length<=1)return`...${n.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 Ul(e){if(!e)return"";const t=[];Sn(e.label)&&t.push(e.label.trim());const n=iy(e.selector);return n&&t.push(n),t.join(" · ")}function ly(e){return e?Sn(e.systemContext)||Sn(ar(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:fn(e.extensions)&&Object.keys(e.extensions).length>0:!1}function cy(e){return e?Sn(e.systemContext)||Sn(ar(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:Mi(e).length>0:!1}function Di(e){if(!fn(e)||e.version!==Ar||typeof e.systemContext!="string")return null;const t=Bs(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const n=[];for(const a of e.selectedElements){if(!fn(a)||typeof a.tag!="string"||typeof a.selector!="string"||typeof a.label!="string")return null;n.push({tag:a.tag,selector:a.selector,label:a.label})}if(e.extensions!==void 0&&!fn(e.extensions))return null;const o=uo(e.extensions),s={version:Ar,systemContext:e.systemContext,currentFile:t,selectedElements:n};return o!==void 0&&(s.extensions=o),s}function dy(e){if(!fn(e)||e.version!==void 0&&e.version!==Ar||e.systemContext!==void 0&&typeof e.systemContext!="string"||e.selectedElements!==void 0&&!Array.isArray(e.selectedElements))return null;const t={};if(e.systemContext!==void 0&&(t.systemContext=e.systemContext),e.currentFile!==void 0){const n=Bs(e.currentFile);if(!n)return null;t.currentFile=n}if(e.selectedElements!==void 0){const n=[];for(const o of e.selectedElements){if(!fn(o)||typeof o.tag!="string"||typeof o.selector!="string"||typeof o.label!="string")return null;n.push({tag:o.tag,selector:o.selector,label:o.label})}t.selectedElements=n}if(e.extensions!==void 0){if(!fn(e.extensions))return null;const n=uo(e.extensions);t.extensions=n||{}}return t}function uy(e){return`${e.tag}::${e.selector}::${e.label}`}function py(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,n=[];for(const o of e){const s=uy(o);t.has(s)||(t.add(s),n.push(o))}return n}function Bu(){return{version:Ar,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function my(e,t){const n=Di(e)||Bu(),o=dy(t);if(!o)return null;const s={...n};if(o.systemContext!==void 0&&(s.systemContext=o.systemContext),o.currentFile!==void 0&&Sn(ar(o.currentFile))&&(s.currentFile=o.currentFile),o.selectedElements!==void 0&&(s.selectedElements=py([...Array.isArray(n.selectedElements)?n.selectedElements:[],...o.selectedElements])),o.extensions!==void 0){const a=sy(n.extensions,o.extensions);a?s.extensions=a:delete s.extensions}return s}function fy(e,t){const n=Di(e)||Bu(),o=kr(t);if(!o)return n;const s=Mi(n).filter(d=>d.id!==o),a={...fn(n.extensions)?n.extensions:{}};if(s.length>0?a[nn]=s:delete a[nn],Object.keys(a).length>0)return{...n,extensions:a};const{extensions:l,...c}=n;return c}function hy(e){return typeof e!="string"?Bl:e.trim().toLowerCase()===qa?qa:Bl}function ql(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const o=Wa(e);if(!o)return null;try{t=JSON.parse(o)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const n=Di(t);return n||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function xy(e){if(!e)return null;const t={version:Ar,systemContext:e.systemContext||"",currentFile:ar(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};if(e.extensions!==void 0){const n=uo(e.extensions);n&&(t.extensions=n)}return t}function gy(e,t){return`<dynamic_context version="${Ar}">
|
|
201
|
+
${JSON.stringify(e,null,2)}
|
|
202
|
+
</dynamic_context>
|
|
203
|
+
|
|
204
|
+
<user_message>
|
|
205
|
+
${t}
|
|
206
|
+
</user_message>`}function vy({visibleDynamicContext:e,visibleSelectedElements:t,hiddenSelectedElements:n,visibleContextComments:o,onDismissSystemContext:s,onDismissCurrentFile:a,onDismissSelectedElement:l,onDismissContextComment:c}){const{t:d}=Ot("chat"),u=Array.isArray(o)?o:[];return e?r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Sn(e.systemContext)&&r.jsx(un,{content:e.systemContext,className:"whitespace-normal break-words max-w-sm",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[260px] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-300 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 12h16M4 19h16"})}),r.jsx("span",{className:"truncate",children:d("input.dynamicContext.systemChip")}),r.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:d("input.dynamicContext.removeSystem"),"aria-label":d("input.dynamicContext.removeSystem"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),Sn(ar(e.currentFile))&&r.jsx(un,{content:ar(e.currentFile),className:"whitespace-normal break-words max-w-sm",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[260px] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-emerald-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),r.jsx("span",{className:"truncate",children:ay(e.currentFile)}),r.jsx("button",{type:"button",onClick:a,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:d("input.dynamicContext.removeCurrentFile"),"aria-label":d("input.dynamicContext.removeCurrentFile"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),t.map((m,p)=>r.jsx(un,{content:Ul(m),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-normal break-words",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[min(22rem,calc(100vw-4rem))] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",title:m.selector,children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 15l2 5L7 17l3-10 10 3-5 2z"})}),r.jsx("span",{className:"truncate",children:m.tag||d("input.dynamicContext.elementFallback")}),r.jsx("button",{type:"button",onClick:()=>l(m),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:d("input.dynamicContext.removeElement"),"aria-label":d("input.dynamicContext.removeElement"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},`${m.selector}-${p}`)),n.length>0&&r.jsx(un,{content:n.map(Ul).join(`
|
|
207
|
+
`),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:r.jsxs("div",{className:"inline-flex items-center gap-1 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-muted-foreground",children:["+",n.length]})}),u.map(m=>{const p=m.preview||m.body,f=[m.preview,m.body,m.target?.filePath].filter(Boolean).join(`
|
|
208
|
+
`);return r.jsx(un,{content:f,className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[min(22rem,calc(100vw-4rem))] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h6m-8 8l3.5-3.5H19a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v9.5a2 2 0 002 2h.5V20z"})}),r.jsx("span",{className:"truncate",children:p}),r.jsx("button",{type:"button",onClick:()=>c(m.id),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:d("input.dynamicContext.removeComment","Remove comment"),"aria-label":d("input.dynamicContext.removeComment","Remove comment"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},m.id)})]})}):null}function yy({file:e,index:t,onPreview:n,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]),r.jsxs("div",{className:"relative group",children:[r.jsx("button",{type:"button",onClick:()=>n(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:r.jsx("img",{src:l,alt:e.name,className:"h-20 w-20 object-cover rounded-lg"})}),s!==void 0&&s<100&&r.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:r.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),a&&r.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:r.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),r.jsx("button",{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:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}function by({attachedImages:e,uploadingImages:t,imageErrors:n,onRemove:o}){const[s,a]=i.useState(-1),[l,c]=i.useState(null),d=i.useMemo(()=>K0(e,s),[e,s]);return i.useEffect(()=>{if(!d.isOpen)return;const u=p=>{p.key==="Escape"&&a(-1)},m=document.body.style.overflow;return document.body.style.overflow="hidden",window.addEventListener("keydown",u),()=>{document.body.style.overflow=m,window.removeEventListener("keydown",u)}},[d.isOpen]),i.useEffect(()=>{const u=Fu(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?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsx("div",{className:"flex flex-wrap gap-2",children:e.map((u,m)=>r.jsx(yy,{file:u,index:m,onPreview:a,onRemove:()=>o(m),uploadProgress:t.get(u.name),error:n.get(u.name)},`${u.name}-${m}`))})}),d.isOpen&&l&&r.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:[r.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:r.jsx(on,{className:"h-5 w-5"})}),r.jsxs("div",{className:"flex max-h-full w-full max-w-5xl flex-col items-center gap-3",onClick:u=>u.stopPropagation(),children:[r.jsx("img",{src:l,alt:d.activeImage?.name||"Preview",className:"max-h-[82vh] w-auto max-w-full rounded-2xl object-contain shadow-2xl"}),r.jsx("div",{className:"max-w-full truncate px-4 text-center text-sm text-white/80",children:d.activeImage?.name})]})]})]}):null}const Zo="relative flex min-h-9 w-full cursor-default select-none items-center rounded-lg px-3 py-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:opacity-50";function wy(e,t){return!Array.isArray(e)||e.length===0?"":e.find(n=>n.value===t)?.label||e[0]?.label||""}function ky({modelValue:e="",modelOptions:t=[],modelLabel:n="",onModelChange:o,modelSelectionDisabled:s=!1,isLoadingModels:a=!1,loadingLabel:l="Loading models...",disabled:c=!1,thinkingOptions:d=[],thinkingValue:u="",thinkingLabel:m="Thinking depth",onThinkingChange:p,onRefreshRequested:f,className:y=""}){const v=Array.isArray(t)?t.filter(K=>K?.value):[],_=Array.isArray(d)?d.filter(K=>K?.value):[],N=_.length>0,E=a||v.length>0,z=c||!E&&!N,q=c||s||a,Z=wy(_,u);return!E&&!N?null:r.jsx("div",{className:yt("relative min-w-0 max-w-full",y),children:r.jsxs(Yr,{onOpenChange:K=>{K&&f?.()},children:[r.jsx(Xr,{asChild:!0,children:r.jsx("button",{type:"button",className:"inline-flex h-8 w-auto min-w-0 max-w-full items-center justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none outline-none transition-colors hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 disabled:cursor-not-allowed disabled:opacity-50 sm:h-8 sm:px-1.5 sm:text-xs",disabled:z,children:r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1",children:[a?r.jsx(Bt,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}):null,r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-normal text-muted-foreground",children:a?l:n}),Z?r.jsx("span",{className:"hidden max-w-[80px] truncate text-xs font-normal text-muted-foreground/70 sm:inline",children:Z}):null,r.jsx(pi,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})})}),r.jsx(jr,{children:r.jsxs(Zr,{align:"start",sideOffset:6,className:"z-50 w-[min(20rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-border/70 bg-background text-foreground shadow-lg",children:[r.jsx("div",{className:"max-h-72 overflow-y-auto p-1.5",children:a?r.jsxs(dn,{disabled:!0,className:Zo,children:[r.jsx(Bt,{className:"mr-2 h-3.5 w-3.5 animate-spin text-muted-foreground"}),l]}):v.map(({value:K,label:V})=>r.jsxs(dn,{disabled:q,className:Zo,onSelect:()=>{o?.(K)},children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:V}),K===e?r.jsx(In,{className:"ml-3 h-4 w-4 flex-shrink-0 text-foreground"}):null]},K))}),N?r.jsx("div",{className:"border-t border-border/70 bg-background p-1.5",children:r.jsxs(Hg,{children:[r.jsxs(Gg,{className:yt(Zo,"gap-2"),children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:m}),Z?r.jsx("span",{className:"max-w-[7rem] truncate text-xs text-muted-foreground",children:Z}):null,r.jsx(hi,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]}),r.jsx(jr,{children:r.jsx(Vg,{sideOffset:8,alignOffset:-4,className:"z-50 min-w-44 overflow-hidden rounded-xl border border-border/70 bg-background p-1.5 text-foreground shadow-lg",children:r.jsx(qg,{value:u,onValueChange:p,children:_.map(K=>r.jsxs(Wg,{value:K.value,className:Zo,children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:K.label}),r.jsx(Kg,{children:r.jsx(In,{className:"ml-3 h-4 w-4 flex-shrink-0 text-foreground"})})]},K.value))})})})]})}):null]})})]})})}function Sy(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 jy({composer:e,isLoading:t,chatMessages:n,sendByCtrlEnter:o}){const{t:s}=Ot("chat"),{provider:a,currentModel:l,modelOptions:c,selectedModelLabel:d,isModelSelectionLocked:u,isOpencodeModelLoading:m,refreshModelAndThinkingOptions:p,permissionMode:f,acpModes:y,acpModeId:v,handleAcpModeChange:_,selectedPermissionShortLabel:N,permissionDropdownTitle:E,providerModeConfig:z,getPermissionModeLabel:q,providerThinkingConfig:Z,thinkingMode:K,setThinkingMode:V,thoughtLevel:T,setThoughtLevel:Y,thoughtLevelOptions:D,tokenBudget:oe,input:Q,isInputFocused:b,setIsInputFocused:$,textareaRef:L,inputContainerRef:ee,inputHighlightRef:le,isFileMentionsEnabled:ve,hasSlashCommandsAvailable:ue,showFileDropdown:W,filteredFiles:Se,selectedFileIndex:Ce,selectFile:Ae,showCommandMenu:se,filteredCommands:J,selectedCommandIndex:pe,handleCommandSelect:xe,commandQuery:he,frequentCommands:be,slashPosition:je,setShowCommandMenu:Be,setSelectedCommandIndex:Ve,setSlashPosition:He,setCommandQuery:nt,getRootProps:Pe,getInputProps:lt,isDragActive:ct,openImagePicker:Te,attachedImages:Je,uploadingImages:_e,imageErrors:Qe,removeAttachedImage:Ke,visibleDynamicContext:mt,visibleSelectedElements:Xe,hiddenSelectedElements:P,visibleContextComments:B,handleDismissSystemContext:me,handleDismissCurrentFile:Fe,handleDismissSelectedElement:rt,handleDismissContextComment:fe,renderInputWithMentions:g,handleInputChange:ie,handleTextareaClick:Ne,handleKeyDown:de,handlePaste:Oe,syncInputOverlayScroll:Me,handleTextareaInput:$e,activeInputProvider:De,isActiveProviderNotInstalled:it,unavailablePlaceholder:ge,isInputDisabled:Re,activeProviderInstallReason:Et,activeProviderInstallHint:st,isCheckingProviderInstallation:j,checkProviderInstallation:M,providerCheckLoadingByName:H,pendingMessageQueue:ae,pendingQueueLimit:Ie,queueNotice:te,immediateSendingId:we,handleRemovePendingMessage:ut,handleSendPendingMessageNow:gt,handleSubmit:C,handleAbortSession:w,isUserScrolledUp:x,scrollToBottom:I,setProviderModel:S,setPermissionMode:U,selectedSession:ce,canAbortSession:ze,modelSelectorRef:ft,permissionSelectorRef:Ue,activeProviderInstallState:St,activeInputProviderLabel:Ct}=e,Kt=M0({canAbortSession:ze,hasInput:!!Q.trim(),isInputDisabled:Re,isLoading:t,pendingQueueCount:ae.length,pendingQueueLimit:Ie}),X=O0({disabled:Re||!ce?.id,modes:y}),Ht=$0({isOpen:se,commands:J}),jn=q0({hasSlashCommands:ue}),Ft=W0({hasSlashCommands:ue,sendByCtrlEnter:o}),en=Array.isArray(D)&&D.length>0,gn=en?D.map(Ze=>({value:Ze.value,label:Ze.label,description:Ze.description})):Z.enabled?Z.modes.map(Ze=>{const ke={"think-hard":"thinkHard","think-harder":"thinkHarder"}[Ze]||Ze;return{value:Ze,label:s(`thinkingMode.modes.${ke}.name`),description:s(`thinkingMode.modes.${ke}.description`)}}):[],vn=en?T:K,tn=en?Y:V;return r.jsxs("div",{className:"flex-shrink-0 bg-background px-3 py-3 sm:px-4 sm:py-4 pb-2 sm:pb-4 md:pb-6",children:[r.jsx("div",{ref:ee,className:"mx-auto mb-3 w-full max-w-[46rem]"}),r.jsxs("form",{onSubmit:C,className:"relative mx-auto w-full max-w-[46rem]",children:[x&&n.length>0&&r.jsx("button",{type:"button",onClick:I,className:"absolute -top-12 right-0 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-muted/80 text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring",title:"滚动到底部",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})}),ct&&r.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center rounded-2xl border border-dashed border-primary bg-primary/5",children:r.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4",children:[r.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),r.jsx("p",{className:"text-sm font-medium",children:"将图片拖到这里"})]})}),r.jsx(by,{attachedImages:Je,uploadingImages:_e,imageErrors:Qe,onRemove:Ke}),r.jsx(vy,{visibleDynamicContext:mt,visibleSelectedElements:Xe,hiddenSelectedElements:P,visibleContextComments:B,onDismissSystemContext:me,onDismissCurrentFile:Fe,onDismissSelectedElement:rt,onDismissContextComment:fe}),ve&&W&&Se.length>0&&r.jsx("div",{className:"chat-floating-panel absolute bottom-full left-0 right-0 z-50 mb-2 max-h-48 overflow-y-auto rounded-2xl",children:Se.map((Ze,Gt)=>r.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${Gt===Ce?"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:ke=>{ke.preventDefault(),ke.stopPropagation()},onClick:ke=>{ke.preventDefault(),ke.stopPropagation(),Ae(Ze)},children:[r.jsx("div",{className:"font-medium text-sm",children:Ze.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:Ze.path})]},Ze.path))}),r.jsx(jf,{commands:J,selectedIndex:pe,onSelect:xe,onClose:()=>{Be(!1),He(-1),nt(""),Ve(-1)},position:{top:L.current?Math.max(16,L.current.getBoundingClientRect().top-316):0,left:L.current?L.current.getBoundingClientRect().left:16,bottom:L.current?window.innerHeight-L.current.getBoundingClientRect().top+8:90},isOpen:Ht,frequentCommands:he?[]:be}),r.jsxs("div",{...Pe(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${e.isTextareaExpanded?"chat-input-expanded":""} ${b?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[r.jsx("input",{...lt()}),r.jsx("div",{ref:le,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-[24px]",children:r.jsx("div",{className:"chat-input-placeholder block w-full px-4 pt-4 pb-14 text-xs leading-5 text-transparent whitespace-pre-wrap break-words sm:text-base sm:leading-6",children:g(Q)})}),r.jsxs("div",{className:"relative z-10 flex flex-col",children:[ae.length>0&&r.jsxs("div",{className:"border-b border-border/60 px-3 pb-2 pt-3",children:[r.jsx("div",{className:"flex flex-col gap-1.5",children:ae.map(Ze=>r.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-lg bg-muted/45 px-2.5 py-1.5 text-xs text-muted-foreground",children:[r.jsx("span",{className:"flex-shrink-0 text-muted-foreground/70",children:"↳"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground/80",title:Ze.text,children:Ze.text}),r.jsxs("button",{type:"button",onClick:()=>gt(Ze.id),disabled:!!we,className:"inline-flex h-6 flex-shrink-0 items-center gap-1 rounded-md px-1.5 text-[11px] font-medium text-primary transition-colors hover:bg-primary/10 disabled:cursor-not-allowed disabled:opacity-50",title:s("input.pendingQueue.sendNow"),"aria-label":s("input.pendingQueue.sendNow"),children:[r.jsx(Th,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:"hidden sm:inline",children:we===Ze.id?s("input.pendingQueue.sendingNow"):s("input.pendingQueue.sendNow")})]}),r.jsx("button",{type:"button",onClick:()=>ut(Ze.id),disabled:!!we,className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:cursor-not-allowed disabled:opacity-50",title:s("input.pendingQueue.remove"),"aria-label":s("input.pendingQueue.remove"),children:r.jsx(qn,{className:"h-3.5 w-3.5"})})]},Ze.id))}),te?r.jsx("div",{className:"mt-1 px-1 text-[11px] text-muted-foreground",children:te}):r.jsx("div",{className:"mt-1 px-1 text-[11px] text-muted-foreground/80",children:s("input.pendingQueue.count",{count:ae.length,limit:Ie})})]}),r.jsx("div",{className:"relative px-4 pt-4",children:r.jsx("textarea",{ref:L,value:Q,onChange:ie,onClick:Ne,onKeyDown:de,onPaste:Oe,onScroll:Ze=>Me(Ze.target),onFocus:()=>$(!0),onBlur:()=>$(!1),onInput:$e,placeholder:it?ge:s(jn,{provider:De==="codex"?s("messageTypes.codex"):De==="gemini"?s("messageTypes.gemini"):De==="opencode"?"OpenCode":s("messageTypes.claude")}),disabled:Re,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"}})}),it&&r.jsxs("div",{className:"mx-3 mt-2 rounded-xl border border-amber-200 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-100",children:[r.jsx("div",{children:Et||ge}),st&&r.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:st}),r.jsx("div",{className:"mt-2",children:r.jsx("button",{type:"button",onClick:()=>M(De,{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:j,children:s(j?"input.checkingInstallation":"input.recheckInstallation")})})]}),r.jsxs("div",{className:"flex items-end justify-between gap-2 px-3 pb-3 pt-2 sm:items-center",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-hidden sm:gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{Re||Te()},disabled:Re,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:s("input.attachImages"),children:[r.jsx(fo,{className:"h-4 w-4 sm:hidden"}),r.jsx("svg",{className:"hidden h-5 w-5 sm:block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})]}),(m||c.length>0||gn.length>0)&&r.jsx("div",{ref:ft,className:"relative min-w-0 max-w-[5.75rem] flex-[0_1_auto] sm:max-w-[8rem] md:max-w-[10rem]",children:r.jsx(ky,{modelValue:l,modelOptions:c,modelLabel:d,onModelChange:S,modelSelectionDisabled:u,isLoadingModels:m,loadingLabel:s("input.loadingModels"),disabled:Re,thinkingOptions:gn,thinkingValue:vn,thinkingLabel:s("thinkingMode.selector.depth"),onThinkingChange:tn,onRefreshRequested:p})}),r.jsx("div",{className:"relative min-w-0 max-w-[5.5rem] flex-[0_1_auto] sm:max-w-[9rem]",ref:Ue,children:r.jsxs(Zc,{value:f,onValueChange:Ze=>{U(Ze),ce&&localStorage.setItem(`permissionMode-${ce.id}`,Ze)},disabled:Re,children:[r.jsx(ed,{className:"inline-flex h-8 w-auto !min-w-0 max-w-full justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 sm:h-8 sm:px-1.5 sm:text-xs",children:r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-normal text-muted-foreground",children:N||E||s("input.clickToChangeMode")}),r.jsx(pi,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(td,{children:r.jsxs(Cf,{children:[r.jsx(Nf,{children:E}),z.modes.map(Ze=>r.jsx(nd,{value:Ze,children:q(Ze,{short:!0})},Ze))]})})]})}),X?r.jsx(Ef,{modes:y,value:v,onValueChange:_,disabled:Re||!ce?.id,label:"智能体模式",className:"max-w-[5.5rem] flex-[0_1_auto] sm:max-w-[9rem]",triggerClassName:"w-auto shrink"}):null,oe!==null&&r.jsxs("div",{className:"hidden cursor-help items-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground sm:flex",title:"Token Budget",children:[r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})}),r.jsx("span",{children:Sy(oe)})]}),null]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative group hidden sm:block",children:[r.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:s("input.commands"),children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),r.jsx("div",{className:"chat-floating-panel absolute bottom-full right-0 z-50 mb-2 hidden w-64 rounded-lg p-3 text-xs text-muted-foreground group-hover:block",children:r.jsx("p",{children:s(Ft)})})]}),r.jsx("button",{type:Kt.buttonType,disabled:Kt.disabled,"data-axhub-composer-primary-action":"true","data-axhub-composer-primary-kind":Kt.kind,"aria-label":Kt.kind==="stop"?s("input.stop"):s("input.send"),title:Kt.kind==="stop"?s("input.stop"):s("input.send"),onClick:Ze=>{if(Ze.preventDefault(),Kt.kind==="stop"){w();return}C(Ze)},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:Kt.kind==="stop"?r.jsx(qh,{className:"h-4 w-4 fill-current"}):r.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h12m-5-5 5 5-5 5"})})})]})]})]})]})]})]})}function rr(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.replace(/\\/g,"/");return n==="/"?"/":/^[A-Za-z]:\/?$/.test(n)?`${n[0]}:/`:n.replace(/\/+$/,"")}function eo(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 so(e,t){const n=rr(t);return n?[e?.fullPath,e?.path].some(o=>rr(o)===n):!1}function Cy(e,t,n={}){if(!t||!Array.isArray(e))return null;const o=typeof n.provider=="string"?n.provider.trim().toLowerCase():"",s=typeof n.projectName=="string"?n.projectName.trim():"",a=rr(n.projectPath);for(const l of e){if(!((!s||l?.name===s)&&(!a||so(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 m=u.items?.find(p=>p?.id===t);if(m)return{project:l,session:m,provider:u.provider}}}return null}function Uu({projects:e,queryProject:t=null,queryCwd:n=null}){if(!Array.isArray(e)||e.length===0)return null;const o=rr(t),s=rr(n);return e.find(a=>so(a,s)?!0:o?[a?.name,a?.fullPath,a?.path].some(l=>rr(l)===o):!1)||null}function Ny({projects:e,queryProject:t=null,queryCwd:n=null}){const o=Uu({projects:e,queryProject:t,queryCwd:n});return!!(o&&!o.detailsLoaded)}function Ey(e,t){return Object.freeze({value:e,label:t})}function Hr(e,t){return Object.freeze({OPTIONS:Object.freeze(t.map(([n,o])=>Ey(n,o))),DEFAULT:e})}const Co=Object.freeze({claude:Hr("sonnet",[["sonnet","Sonnet"],["opus","Opus"],["haiku","Haiku"],["opusplan","Opus Plan"],["sonnet[1m]","Sonnet [1M]"]]),cursor:Hr("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:Hr("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:Hr("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:Hr("kimi-k2.5",[["kimi-k2.5","Kimi K2.5"]])}),Iy=Co.claude;Co.cursor;const qu=Co.codex,Ay=Co.gemini,_y=Co.opencode,Ry=["claude","codex","gemini","opencode"],Gr="unknown",Py="installed",es="not_installed",Ty="checking",My=["claude","codex","gemini","opencode"],Dy=1800*1e3;function Tt(e){const t=String(e||"").trim().toLowerCase();return Ry.includes(t)?t:"claude"}function Wl({urlProvider:e,selectedSessionProvider:t,storedProvider:n}={}){return typeof t=="string"&&t.trim().length>0?Tt(t):typeof e=="string"&&e.trim().length>0?Tt(e):Tt(n)}function Ly(e){switch(e){case"codex":return qu;case"gemini":return Ay;case"opencode":return _y;case"claude":default:return Iy}}function Us(e){return`${Tt(e)}-model`}function Li(e){return`${Us(e)}-selection-source`}function ts(e){const t=Tt(e),n=Us(t),o=Li(t);return localStorage.getItem(o)!=="manual"?"":localStorage.getItem(n)||""}function Oy(e,t){const n=Tt(e);localStorage.setItem(Us(n),t),localStorage.setItem(Li(n),"manual")}function Fy(e){const t=Tt(e);localStorage.removeItem(Us(t)),localStorage.removeItem(Li(t))}function Wu(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const $y=new Set(qu.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function zy(e){if(!Wu(e))return!1;const t=e.trim().toLowerCase();return $y.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function By(e,t){return Tt(e)==="codex"?zy(t):Wu(t)}function ns(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}const Kl=new WeakMap;let Hl=0;function Ku(e){const t=e instanceof Date?e.getTime():new Date(e||Date.now()).getTime();return Number.isNaN(t)?Date.now():t}function Hu(e){return String(e||"").replace(/\s+/g," ").trim().slice(0,120)}function Uy(e,t){const n=Ku(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=Hu(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,n,a,l,d,c,t].join(":")}function qy(e,t){if(e?.__threadMessageId)return String(e.__threadMessageId);if(e?.eventMessageId)return[String(e.eventMessageId),Ku(e?.timestamp),Hu(e?.content||e?.reasoning||e?.toolName),t].join(":");const n=e?.id||e?.messageId||e?.toolCallId||e?.toolId||e?.requestId;if(n)return String(n);if(e&&typeof e=="object"){const o=Kl.get(e);if(o)return o;const s=Uy(e,t);return Kl.set(e,s),s}return Hl+=1,`runtime:${Hl}:${t}`}const kt={setItem:(e,t)=>{try{if(e.startsWith("chat_messages_")&&typeof t=="string")try{const n=JSON.parse(t);if(Array.isArray(n)&&n.length>50){const o=n.slice(-50);t=JSON.stringify(o)}}catch(n){console.warn("Could not parse chat messages for truncation:",n)}localStorage.setItem(e,t)}catch(n){if(n.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:",n)}},getItem:e=>{try{return localStorage.getItem(e)}catch(t){return console.error("localStorage getItem error:",t),null}},removeItem:e=>{try{localStorage.removeItem(e)}catch(t){console.error("localStorage removeItem error:",t)}}};function Oi(e){return e?`draft_input_${e}`:""}function Gl(e,t=kt){const n=Oi(e);return n&&t.getItem(n)||""}function ks(e,t=kt){const n=Oi(e);n&&t.removeItem(n)}function Wy(e,t,n=kt){if(t===""){ks(e,n);return}const o=Oi(e);o&&n.setItem(o,t)}function Gu(e){return e?`chat_messages_${e}`:""}function Vu(e,t=null){return e?t?`chat_messages_${e}__session_${t}`:Gu(e):""}function Ky(e,t=null){const n=Vu(e,t);if(!n)return[];const o=kt.getItem(n);if(!o)return[];try{return fi(JSON.parse(o))}catch(s){return console.warn("Failed to parse cached chat messages:",s),[]}}function Qu(e,t=null,n=[]){const o=Vu(e,t);if(!o)return;const s=fi(n);if(s.length===0){kt.removeItem(o);return}kt.setItem(o,JSON.stringify(s)),t&&kt.removeItem(Gu(e))}const Ju="claude-settings";function Hy(){const e=kt.getItem(Ju);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 Gy(e){if(!e)return{success:!1};const t=Hy(),n=t.allowedTools.includes(e),o=n?t.allowedTools:[...t.allowedTools,e],s=t.disallowedTools.filter(l=>l!==e),a={...t,allowedTools:o,disallowedTools:s,lastUpdated:new Date().toISOString()};return kt.setItem(Ju,JSON.stringify(a)),{success:!0,alreadyAllowed:n,updatedSettings:a}}function Vy({autoScrollToBottom:e,hasMessages:t,isLoadingSession:n}){return!!(e&&t&&!n)}const Qy=100;function Vl(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function Jy(e,t){if(!e||!t)return!1;const n=Vl(e),o=Vl(t);return n&&o&&n===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 Yy({selectedProject:e,selectedProjectRef:t,selectedSession:n,currentSessionId:o,setCurrentSessionId:s,provider:a,runtimePhase:l,isLoading:c,isLoadingRef:d,processingSessions:u,autoScrollToBottom:m,externalMessageUpdate:p,ws:f,sendMessage:y,chatMessages:v,setChatMessages:_,setIsLoading:N,setCanAbortSession:E,setRuntimePhase:z,setClaudeStatus:q,setPendingPermissionRequests:Z,setPendingElicitationRequests:K,resetStreamingState:V,clearLocalRunGuard:T,localRunGuardRef:Y,terminalRunStateRef:D,pendingViewSessionRef:oe,isSystemSessionChange:Q,setIsSystemSessionChange:b,onSessionInactive:$,onSessionNotProcessing:L,onSessionProcessing:ee}){const[le,ve]=i.useState([]),[ue,W]=i.useState(!1),[Se,Ce]=i.useState(!1),[Ae,se]=i.useState(0),[J,pe]=i.useState(!1),[xe,he]=i.useState(0),[be,je]=i.useState(null),[Be,Ve]=i.useState(!1),[He,nt]=i.useState(100),[Pe,lt]=i.useState(null),ct=i.useRef(null),Te=i.useRef(null),Je=i.useRef(!1),_e=i.useRef(!1),Qe=i.useRef(0),Ke=i.useRef(!1),mt=i.useRef(null),Xe=i.useRef({height:0,top:0}),P=i.useRef(new Map),B=i.useRef(p),me=i.useRef(null),Fe=i.useRef(n),rt=i.useRef(o),fe=i.useRef(l),g=e?.fullPath||e?.path||null;i.useEffect(()=>()=>{P.current.forEach(w=>clearTimeout(w)),P.current.clear(),me.current&&(clearTimeout(me.current),me.current=null)},[]),i.useEffect(()=>{Fe.current=n},[n]),i.useEffect(()=>{rt.current=o},[o]),i.useEffect(()=>{fe.current=l},[l]);const ie=i.useCallback(async(w,x,I=!1,S="claude",U=null)=>{if(!w||!x)return[];const ce=!I;ce?W(!0):Ce(!0);try{const ze=U??(I?Qe.current:0),ft=await et.sessionEvents(S,x,w,g,Qy,ze);if(!ft.ok)throw new Error("Failed to load session messages");const Ue=await ft.json();if(ce&&Ue.tokenUsage&&je(Ue.tokenUsage),Ue.hasMore!==void 0){pe(Ue.hasMore),he(Ue.total);const Ct=ze+(Ue.events?.length||0);return Qe.current=Ct,se(Ct),Ue.events||[]}const St=Ue.events||Ue.messages||[];return pe(!1),he(St.length),Qe.current=St.length,se(St.length),St}catch(ze){return console.error("Error loading session messages:",ze),[]}finally{ce?W(!1):Ce(!1)}},[g]),Ne=i.useCallback((w,x="claude")=>If(w,x).map(I=>({...I,provider:I.provider||x})),[]),de=n?.__provider||a||"claude",Oe=i.useMemo(()=>Ne(le,de),[de,Ne,le]),Me=i.useCallback((w=[])=>x0(w),[]),$e=i.useCallback((w=[])=>g0(w),[]),De=i.useCallback(w=>!(w===F.COMPLETED||w===F.ABORTED||w===F.ERRORED),[]),it=i.useCallback((w,x)=>{if(!x)return x;const I=D?.current||null,S=I?.sessionId===w&&oo(I?.phase)&&Date.now()-Number(I?.updatedAt||0)<12e4?I.phase:null,U=S||fe.current,ce=Fe.current?.id||rt.current||(S?w:null);return w0({recoveredPhase:x,runtimePhase:U,recoveredSessionId:w,currentSessionId:ce})?(z(x),(x===F.COMPLETED||x===F.ABORTED||x===F.ERRORED)&&(T(w),q(null),w&&($?.(w),L?.(w))),x):U||x},[T,$,L,q,z]),ge=i.useCallback(async(w,x)=>{const I=t.current;if(!I?.name||!w)return null;const S=await ie(I.name,w,!1,x||de);return Array.isArray(S)&&S.length>0&&ve(S),Me(S)},[de,Me,ie,t]),Re=i.useCallback(async(w,x)=>{const I=await ge(w,x);return it(w,I)},[ge,it]),Et=i.useCallback((w,x=[])=>{const I=Me(x);return it(w,I),I},[Me,it]),st=i.useCallback((w,x)=>x===F.COMPLETED||x===F.ABORTED||x===F.ERRORED?(it(w,x),x):null,[it]),j=i.useCallback((w,x)=>{if(!w)return;const I=P.current.get(w);I&&clearTimeout(I);const S=setTimeout(()=>{P.current.delete(w);const U=n?.id||o||null;!U||U!==w||(Re(w,x),y&&y({type:"check-session-status",sessionId:w,provider:x||de}))},1200);P.current.set(w,S)},[de,o,Re,n?.id,y]),M=i.useCallback(()=>{Te.current&&(Te.current.scrollTop=Te.current.scrollHeight)},[]),H=i.useCallback(()=>{if(!Te.current)return!1;const{scrollTop:w,scrollHeight:x,clientHeight:I}=Te.current;return x-w-I<50},[]),ae=i.useCallback(async(w=null)=>{const x=w||Te.current;if(!x||_e.current||Se||!J||!n||!e)return!1;const I=n.__provider||a||"claude";_e.current=!0;const S=x.scrollHeight,U=x.scrollTop,ce=Qe.current;try{const ze=await ie(e.name,n.id,!0,I,ce);return ze.length>0&&(mt.current={height:S,top:U},ve(ft=>[...ze,...ft])),!0}finally{_e.current=!1}},[J,Se,ie,a,e,n]),Ie=i.useCallback(async()=>{if(Te.current){const w=Te.current,x=H();Ve(!x),w.scrollTop<100?Ke.current||await ae(w)&&(Ke.current=!0):Ke.current=!1}},[H,ae]);i.useLayoutEffect(()=>{if(!mt.current||!Te.current)return;const{height:w,top:x}=mt.current,I=Te.current,U=I.scrollHeight-w;I.scrollTop=x+Math.max(U,0),mt.current=null},[v.length]),i.useEffect(()=>{let w=!1,x=null;return(async()=>{if(n&&e){const S=n.__provider||Tt(localStorage.getItem("selected-provider"));Je.current=!0,sessionStorage.removeItem("pendingSessionId");const U=o!==null&&o!==n.id;let ce=null;if(U?(Q||(V(),T(),oe.current=null,_([]),ve([]),lt(null),q(null),E(!1)),Qe.current=0,se(0),pe(!1),he(0),je(null),N(!1)):o===null&&(Qe.current=0,se(0),pe(!1),he(0),lt(null)),s(n.id),Q)w||b(!1);else{const ze=`${n.__provider||S||"claude"}:${e.name}:${n.id}`,ft=await ie(e.name,n.id,!1,n.__provider||S||"claude");if(w)return;ve(ft),lt(ze),ce=Et(n.id,ft),ce||z(F.IDLE),f&&y&&De(ce)&&y({type:"check-session-status",sessionId:n.id,provider:S})}}else{const U=oe.current?.sessionId||null||d.current&&(o||Y.current.sessionId)||null,ce=!!(U||d.current);Q||ce||(V(),T(),oe.current=null,_([]),ve([]),lt(null),q(null),E(!1),N(!1)),s(U),Qe.current=0,se(0),pe(!1),he(0),je(null),U||lt(null)}x=setTimeout(()=>{w||(Je.current=!1)},250)})(),()=>{w=!0,x&&clearTimeout(x)}},[n?.id,n?.__provider,e?.name,e?.fullPath,e?.path,ie,Q,V,T,Et,y,z,De,f]),i.useEffect(()=>{const w=B.current;if(p<=w||(B.current=p,!n||!e))return;const x=n.id,I=e.name,S=e.fullPath||e.path||null,U=async()=>{try{const ce=n.__provider||Tt(localStorage.getItem("selected-provider")),ze=await ie(I,x,!1,n.__provider||ce||"claude"),ft=t.current,Ue=Fe.current,St=ft?.fullPath||ft?.path||null;if(Ue?.id!==x||ft?.name!==I||St!==S)return;ve(ze),m&&H()&&setTimeout(()=>M(),200)}catch(ce){console.error("Error reloading messages from external update:",ce)}};return me.current&&clearTimeout(me.current),me.current=setTimeout(()=>{me.current=null,U()},500),()=>{me.current&&(clearTimeout(me.current),me.current=null)}},[m,p,H,ie,M,e,t,n]),i.useEffect(()=>{B.current=p},[p,e?.name,n?.id]),i.useEffect(()=>{n?.id&&(oe.current=null)},[oe,n?.id]),i.useEffect(()=>{const w=n?.id||o||null,x=Y.current,I=D?.current||null,S=!!(w&&I?.sessionId===w&&oo(I?.phase)&&Date.now()-Number(I?.updatedAt||0)<12e4),U=!!(x.startedAt&&(!x.sessionId||!w||x.sessionId===w)&&l!==F.IDLE&&!oo(l));_(ce=>f0(ce,Oe,{preserveLocalTail:U,preserveLocalAssistantReplies:S}))},[Oe,o,Y,l,n?.id,_,D]),i.useEffect(()=>{e?.name&&Qu(e.name,n?.id||null,v)},[v,e?.name,n?.id]),i.useEffect(()=>{const w=fi(v);Af(v,w)||_(w)},[v,_]),i.useEffect(()=>{o&&c&&ee&&ee(o)},[o,c,ee]),i.useEffect(()=>{if(o&&u){const w=u.has(o),x=$e(le),I=x||Me(le);if(w&&x){L?.(o);return}b0({shouldBeProcessing:w,isLoading:c,recoveredPhase:I,runtimePhase:l})&&z(F.STREAMING,{canAbortSession:!0})}},[o,Me,$e,c,L,u,l,le,z]);const te=i.useMemo(()=>n||v.length<=He?v:v.slice(-He),[v,n,He]),we=i.useMemo(()=>{const w=te.map((I,S)=>({...I,__threadMessageId:qy(I,S)}));return w.length===0||!c||w.some(I=>I?.type==="assistant"&&!!(I.isStreaming||I.isToolUse||I.isThinking||I.reasoning))?w:[...w,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:n?.__provider||a||"claude"}]},[c,a,n?.__provider,te]);i.useEffect(()=>{if(!(typeof window>"u")){if(window.sessionStorage?.getItem("axhub-chat-debug")!=="1"){delete window.__AXHUB_CHAT_DEBUG__;return}window.__AXHUB_CHAT_DEBUG__={chatMessages:v,threadMessages:we,sessionMessages:le,currentSessionId:o,selectedSessionId:n?.id||null,runtimePhase:l,isLoading:c}}},[v,o,c,l,n?.id,le,we]),i.useEffect(()=>{if(!m&&Te.current){const w=Te.current;Xe.current={height:w.scrollHeight,top:w.scrollTop}}}),i.useEffect(()=>{if(Te.current&&v.length>0)if(m)Be||setTimeout(()=>M(),50);else{const w=Te.current,x=Xe.current.height,I=Xe.current.top,U=w.scrollHeight-x;U>0&&I>0&&(w.scrollTop=I+U)}},[m,v.length,Be,M]),i.useEffect(()=>{if(!Te.current||!Vy({autoScrollToBottom:m,hasMessages:v.length>0,isLoadingSession:Je.current}))return;Ve(!1);const w=setTimeout(()=>{M()},200);return()=>{clearTimeout(w)}},[m,v.length,M,e?.name,n?.id]),i.useEffect(()=>{const w=Te.current;if(w)return w.addEventListener("scroll",Ie),()=>w.removeEventListener("scroll",Ie)},[Ie]),i.useEffect(()=>{if(!e||!n?.id||eo(n.id)){je(null);return}if((n.__provider||a||"claude")!=="claude")return;(async()=>{try{const I=`${Wn(e.name,"/sessions")}/${encodeURIComponent(n.id)}/token-usage`,S=await Zt(I);if(S.ok){const U=await S.json();je(U)}else je(null)}catch(I){console.error("Failed to fetch initial token usage:",I)}})()},[a,e,n?.__provider,n?.id]);const ut=i.useCallback(()=>{nt(w=>w+100)},[]),gt=i.useCallback(w=>{!w||typeof w!="object"||ve(x=>{const I=Array.isArray(x)?x:[];return I.some(S=>Jy(S,w))?I:[...I,w]})},[]),C=i.useCallback(()=>{oe.current=null,sessionStorage.removeItem("pendingSessionId"),s(null),ve([]),lt(null),_([]),Z([]),K?.([]),b(!1),z(F.IDLE),q(null),E(!1),je(null),Ve(!1),e?.name&&(kt.removeItem(`chat_messages_${e.name}`),ks(e.name))},[oe,e?.name,E,_,q,s,b,K,Z,z]);return{sessionMessages:le,setSessionMessages:ve,isLoadingSessionMessages:ue,isLoadingMoreMessages:Se,messagesOffset:Ae,hasMoreMessages:J,totalMessages:xe,tokenBudget:be,setTokenBudget:je,hasHydratedSessionMessages:Oe.length>0,scrollContainerRef:Te,messagesEndRef:ct,isUserScrolledUp:Be,setIsUserScrolledUp:Ve,visibleMessageCount:He,threadMessages:we,hasLoadedSessionMessages:!!(e?.name&&n?.id&&Pe===`${n.__provider||a||"claude"}:${e.name}:${n.id}`),scrollToBottom:M,handleScroll:Ie,loadOlderMessages:ae,loadEarlierMessages:ut,loadSessionMessages:ie,appendSessionConversationEvent:gt,inferRuntimePhaseFromSessionEvents:Me,inferTerminalPhaseFromSessionEvents:$e,recoverAndSettleSessionRuntime:Re,recoverTerminalSessionPhase:st,scheduleSessionStatusRecovery:j,resetSessionHistoryForNewChat:C}}function Xy(e=0,t=null){const n=Number(t?.__messageSeq||0);return!Number.isFinite(n)||n<=0?!0:n>Number(e||0)}const Fi=new Set(["succeeded","failed","canceled"]);function pn(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ka(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.floor(t):0}function Ss(e){return String(e||"").trim().toLowerCase()||null}function Yu(){return{activeRunId:null,lastEventSeq:0,provider:null,sessionId:null,clientRequestId:null,status:null}}function nr(e=null){const t=e||Yu();return{activeRunId:t.activeRunId||null,lastEventSeq:Ka(t.lastEventSeq),provider:t.provider||null,sessionId:t.sessionId||null,clientRequestId:t.clientRequestId||null,status:t.status||null}}function Ha(e=null,t=null){const n=nr(e),o=pn(t?.runId||t?.run?.runId);if(!o)return n;const s=Ka(t?.runEventSeq||t?.seq);if(s&&s<n.lastEventSeq&&o===n.activeRunId)return n;const a=t?.run&&typeof t.run=="object"?t.run:null,l=Ss(t?.event?.status||a?.status||t?.status||n.status),c=Math.max(n.activeRunId===o?n.lastEventSeq:0,s,Ka(a?.lastEventSeq)),d=pn(t?.sessionId||a?.sessionId)||n.sessionId,u=pn(t?.provider||a?.provider)||n.provider,m=pn(t?.clientRequestId||a?.clientRequestId)||n.clientRequestId;return{activeRunId:Fi.has(l)?null:o,lastEventSeq:c,provider:u,sessionId:d,clientRequestId:m,status:l}}function Zy(e){if(!e||typeof e!="object")return null;if(e.type==="conversation-event"){const t=e.event&&typeof e.event=="object"?{...e.event,extensions:{...e.event.extensions||{},runtimeReplay:!0}}:e.event;return{type:"conversation-event",provider:e.provider,sessionId:e.sessionId,clientRequestId:e.clientRequestId,runId:e.runId,runEventSeq:e.seq,event:t,replayed:!0}}return e.type==="run-state"?{type:"run-state",provider:e.provider,sessionId:e.sessionId,clientRequestId:e.clientRequestId,runId:e.runId,runEventSeq:e.seq,event:e.event,replayed:!0}:null}function Ql(e=null,t={}){let n=nr(e);const o=[];return(Array.isArray(t?.events)?t.events:[]).forEach(s=>{const a=Zy(s);a&&(n=Ha(n,a),o.push(a))}),t?.run&&(n=Ha(n,{runId:t.run.runId,runEventSeq:t.run.lastEventSeq,provider:t.run.provider,sessionId:t.run.sessionId,clientRequestId:t.run.clientRequestId,run:t.run,event:{status:t.run.status}})),{state:n,messages:o}}function Jl(e=null,t=null){const n=nr(e),o=pn(t?.runId);return o?{activeRunId:Fi.has(Ss(t?.status))?null:o,lastEventSeq:n.activeRunId===o?n.lastEventSeq:0,provider:pn(t?.provider)||n.provider,sessionId:pn(t?.sessionId)||n.sessionId,clientRequestId:pn(t?.clientRequestId)||n.clientRequestId,status:Ss(t?.status)||n.status}:n}function rs(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?t:0}function eb(e=[],{provider:t=null,sessionId:n=null}={}){const o=pn(t),s=pn(n);return!Array.isArray(e)||!o||!s?null:e.filter(l=>pn(l?.provider)===o&&pn(l?.sessionId)===s&&Fi.has(Ss(l?.status))).sort((l,c)=>{const d=Math.max(rs(c?.updatedAt),rs(c?.createdAt)),u=Math.max(rs(l?.updatedAt),rs(l?.createdAt));return d-u})[0]||null}const tb="acp-capabilities:v1";function Xu(e){return String(e||"").trim().toLowerCase()||"unknown"}function nb(e){return String(e||"").trim()}function ha(e){if(e!==void 0)return JSON.parse(JSON.stringify(e))}function Zu(e,t=null){const n=encodeURIComponent(Xu(e)),o=nb(t);return`${tb}:${n}:${o?encodeURIComponent(o):"global"}`}function qs(e,t){return!t||typeof t!="object"?null:{...ha(t),provider:Xu(t.provider||e),ttl:Number.isFinite(Number(t.ttl))&&Number(t.ttl)>0?Number(t.ttl):rd,updatedAt:t.updatedAt||new Date().toISOString(),capabilities:t.capabilities&&typeof t.capabilities=="object"?ha(t.capabilities):{},metadata:t.metadata&&typeof t.metadata=="object"?ha(t.metadata):{}}}function Cr(e,t=null,n=kt){const o=Zu(e,t),s=n.getItem(o);if(!s)return null;try{return qs(e,JSON.parse(s))}catch{return n.removeItem(o),null}}function ep(e,t=null,n=null,o=kt){const s=qs(e,n),a=Zu(e,t);return s?(o.setItem(a,JSON.stringify(s)),s):(o.removeItem(a),null)}function rb(e,t=Date.now()){if(!e||typeof e!="object")return!1;const n=Date.parse(e.updatedAt||"");if(!Number.isFinite(n))return!1;const o=Number(e.ttl||rd);return Number.isFinite(o)&&o>0&&Number(t)-n<o}function Yl(e,{force:t=!1,now:n=Date.now()}={}){return t?!0:!rb(e,n)}function tp(e,t=null,n=null,o=kt){const s=Cr(e,t,o),a=qs(e,n),l=to(s,a);return ep(e,t,l,o)}function Xl(e){const t=Date.parse(e?.updatedAt||"");return Number.isFinite(t)?t:0}function ob(e,t=null,n=null,o=kt){const s=qs(e,n);if(!s)return Cr(e,t,o);const a=Cr(e,t,o),l=Xl(a),c=Xl(s);return a&&l>c?a:ep(e,t,s,o)}function Zl(e,t={}){const n=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&&n.length===0?e||null:{availableModes:n.length>0?n:Array.isArray(e?.availableModes)?e.availableModes:[],currentModeId:o||e?.currentModeId||null}}function sb(e={}){return Pa(e)}function ab({isLoading:e=!1,runtimePhase:t=null}={}){return!!e||[F.CONNECTING,F.QUEUED,F.STREAMING,F.AWAITING_APPROVAL,F.AWAITING_INPUT].includes(t)}function ib(e){const t=String(e||"").trim().toLowerCase();return t==="succeeded"?F.COMPLETED:t==="failed"?F.ERRORED:t==="canceled"?F.ABORTED:null}function np(e){return["running",F.CONNECTING,F.QUEUED,F.STREAMING,F.AWAITING_APPROVAL,F.AWAITING_INPUT].includes(String(e||"").trim().toLowerCase())}function lb(e){return!e||typeof e!="object"?!1:e.kind==="session_state_changed"?np(e.payload?.state):e.kind==="approval_request"||e.kind==="approval_resolved"||e.kind==="elicitation_request"||e.kind==="elicitation_resolved"||e.kind==="assistant_text_start"||e.kind==="assistant_text_delta"||e.kind==="assistant_content_block"||e.kind==="reasoning_start"||e.kind==="reasoning_delta"||e.kind==="tool_call_start"||e.kind==="tool_call_input"||e.kind==="tool_call_end"||e.kind==="tool_result"||e.kind==="plan_update"}function cb({latestMessage:e,provider:t,claudeStatus:n,selectedProject:o,selectedSession:s,currentSessionId:a,setCurrentSessionId:l,isLoading:c,runtimePhase:d,sendMessage:u,persistCurrentChatCache:m,setRuntimePhase:p,setIsSystemSessionChange:f,setPendingPermissionRequests:y,setIsLoading:v,setCanAbortSession:_,setClaudeStatus:N,setChatMessages:E,setTokenBudget:z,setAcpSessionModeState:q,setAcpAvailableCommands:Z,setAcpCapabilitySnapshot:K,applyRealtimeConversationEvent:V,streamBufferRef:T,streamTimerRef:Y,clearLocalRunGuard:D,markTerminalRunState:oe,terminalRunStateRef:Q,syncLocalRunGuardSession:b,shouldIgnoreStaleIdleSignal:$,pendingViewSessionRef:L,appendSessionConversationEvent:ee,recoverAndSettleSessionRuntime:le,recoverTerminalSessionPhase:ve,inferRuntimePhaseFromSessionEvents:ue,inferTerminalPhaseFromSessionEvents:W,scheduleSessionStatusRecovery:Se,sessionMessages:Ce,setSessionMessages:Ae,loadSessionMessages:se,onSessionInactive:J,onSessionNotProcessing:pe,onSessionProcessing:xe,onReplaceTemporarySession:he,onNavigateToSession:be,onProcessRealtimeMessage:je,t:Be}){const Ve=i.useRef(null),He=i.useRef(new Set),nt=i.useRef(0),Pe=i.useRef(Yu()),lt=i.useRef(null),ct=i.useRef(0),Te=i.useRef(null),Je=i.useRef(null),_e=s?.__provider||t||"claude",Qe=i.useCallback((fe,g)=>{if(!g)return null;const ie=o?.fullPath||o?.path||null,Ne=Tt(fe||_e||t||"claude"),de=tp(Ne,ie,g);return de&&K?.(Oe=>to(Oe,de)),de},[_e,t,o?.fullPath,o?.path,K]),Ke=i.useCallback((fe,g={})=>{const ie=_f({provider:fe||_e||t,configOptions:g.configOptions||[],modeState:g.modeState||null,tokenUsage:g.tokenUsage||null,availableCommands:g.availableCommands||[],source:g.source||"realtime"});return Object.keys(ie.capabilities||{}).length===0&&!ie.metadata?.tokenUsage&&!(Array.isArray(ie.metadata?.availableCommands)&&ie.metadata.availableCommands.length>0)?null:Qe(fe,ie)},[_e,Qe,t]),mt=i.useCallback(fe=>{!fe||typeof fe!="object"||(ct.current+=1,Te.current?.({...fe,__messageSeq:`replay-${ct.current}`}))},[]),Xe=i.useCallback(async(fe="manual")=>{const g=nr(Pe.current);if(!(!g.activeRunId||lt.current===g.activeRunId)){lt.current=g.activeRunId;try{const ie=await et.runEvents(g.activeRunId,g.lastEventSeq);if(!ie.ok){if(ie.status!==404)throw new Error(`Run replay failed with ${ie.status}`);Pe.current={...g,activeRunId:null};return}const Ne=await ie.json(),{state:de,messages:Oe}=Ql(Pe.current,Ne);Pe.current=de,Oe.forEach(Me=>mt(Me))}catch(ie){console.warn("[WARN] Run replay failed:",ie instanceof Error?ie.message:String(ie))}finally{lt.current=null}}},[_e,mt]),P=i.useCallback(async(fe=null)=>{const g=fe?.runId||null;if(!g||lt.current===g)return;const ie=nr(Pe.current),Ne=Number(fe?.lastEventSeq||0),de=Je.current,Oe=ie.activeRunId===g?ie.lastEventSeq:de?.runId===g?Number(de.lastEventSeq||0):0;if(!(Ne>0&&Oe>=Ne)){lt.current=g;try{const Me=await et.runEvents(g,Oe);if(!Me.ok){if(Me.status!==404)throw new Error(`Run replay failed with ${Me.status}`);return}const $e=await Me.json(),{state:De,messages:it}=Ql(Pe.current,$e);Pe.current=De,it.forEach(Re=>mt(Re));const ge=nr(De);!ge.activeRunId&&Ne>0&&(Je.current={runId:g,lastEventSeq:Math.max(ge.lastEventSeq,Ne)})}catch(Me){console.warn("[WARN] Terminal run replay failed:",Me instanceof Error?Me.message:String(Me))}finally{lt.current=null}}},[mt]),B=i.useCallback((fe,g,ie)=>{fe&&(oe(fe,ie),le(fe,g).then(Ne=>{const de=y0({terminalPhase:ie,recoveredPhaseFromHistory:Ne});p(de),(de===F.IDLE||de===F.COMPLETED||de===F.ABORTED||de===F.ERRORED)&&(D(fe),_(!1),N(null),J?.(fe),pe?.(fe))}).catch(Ne=>{console.warn("[WARN] Terminal run recovery failed:",Ne instanceof Error?Ne.message:String(Ne)),oe(fe,ie),p(ie)}))},[D,oe,J,pe,le,_,N,p]);i.useEffect(()=>()=>{Y.current&&(clearTimeout(Y.current),Y.current=null),T.current=""},[T,Y]),i.useEffect(()=>{Ve.current=n},[n]);const me=i.useCallback(fe=>{const g=Q?.current||null;return k0({terminalRunState:g,sessionId:fe})?g.phase:null},[Q]),Fe=i.useCallback(fe=>{const g=me(fe);return g?(p(g),_(!1),N(null),fe&&(J?.(fe),pe?.(fe)),!0):!1},[me,J,pe,_,N,p]);i.useEffect(()=>{const fe=s?.id||a||null,g=s?.__provider||t||"claude";if(!fe)return;let ie=!1;return(async()=>{try{const de=await et.sessionRuns(g,fe,"active");if(!de.ok||ie)return;const Oe=await de.json(),Me=Array.isArray(Oe?.runs)?Oe.runs[0]:null;if(!Me||ie)return;Pe.current=Jl(Pe.current,Me),Xe("session_active_run_discovered")}catch(de){console.warn("[WARN] Active run discovery failed:",de instanceof Error?de.message:String(de))}})(),()=>{ie=!0}},[a,t,Xe,s]),i.useEffect(()=>{const fe=s?.id||a||null,g=s?.__provider||t||"claude";if(!fe||!ab({isLoading:c,runtimePhase:d}))return;let ie=!1,Ne=0,de=null;const Oe=async()=>{Ne+=1;try{const Me=await et.sessionRuns(g,fe,"active");if(ie)return;if(Me.ok){const Re=await Me.json(),Et=Array.isArray(Re?.runs)?Re.runs[0]:null;if(Et){Pe.current=Jl(Pe.current,Et),Xe("session_active_run_discovered"),!ie&&Ne<240&&(de=setTimeout(Oe,1e3));return}}const $e=await et.sessionRuns(g,fe,null);if(!$e.ok||ie)return;const De=await $e.json(),it=eb(De?.runs,{provider:g,sessionId:fe}),ge=ib(it?.status);if(it&&ge&&!ie){if(await P(it),ie)return;B(fe,g,ge);return}}catch(Me){console.warn("[WARN] Terminal run discovery failed:",Me instanceof Error?Me.message:String(Me))}!ie&&Ne<240&&(de=setTimeout(Oe,1e3))};return de=setTimeout(Oe,500),()=>{ie=!0,de&&clearTimeout(de)}},[a,c,t,B,Xe,P,d,s]);const rt=i.useCallback(fe=>{if(!fe||!Xy(nt.current,fe))return;Number.isFinite(Number(fe.__messageSeq))&&Number(fe.__messageSeq)>0&&(nt.current=Number(fe.__messageSeq));const g=fe,ie=nr(Pe.current);Pe.current=Ha(Pe.current,g);const Ne=String(g?.event?.status||g?.run?.status||g?.status||"").trim().toLowerCase();g?.runId&&["succeeded","failed","canceled"].includes(Ne)&&(Je.current={runId:g.runId,lastEventSeq:Number(g.runEventSeq||g.seq||g.run?.lastEventSeq||0)});const de=g.data?.message||g.data,Me=["projects_updated","session-created"].includes(g.type),$e=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),De=g.type==="conversation-event"?String(g.event?.payload?.state||"").trim().toLowerCase():"",it=g.type==="conversation-event"&&(g.event?.kind==="error"||g.event?.kind==="session_state_changed"&&["streaming","awaiting_approval","awaiting_input","completed","aborted","errored"].includes(De)),Re=g.type==="claude-response"&&de&&de.type==="system"&&de.subtype==="init"?de?.session_id:null,Et=sessionStorage.getItem("pendingSessionId");let st=s?.id||a||L.current?.sessionId||null;const j=!!(g.runId&&(g.runId===ie.activeRunId||ie.status&&ie.activeRunId===null&&ie.sessionId===g.sessionId&&g.runId===(g.run?.runId||g.runId))),M=Re&&(!st||Re===st),H=Me||M,ae=!g.sessionId&&L.current&&!L.current.sessionId&&(/error/i.test(g.type||"")||g.type==="conversation-event"&&g.event?.kind==="error"),Ie=C=>{C&&(J?.(C),pe?.(C))},te=C=>{C&&xe?.(C)},we=(C,w)=>D0({discoveredSessionId:C,currentSessionId:a,selectedSessionId:s?.id||null,pendingViewSessionId:L.current?.sessionId||null})?(L.current&&(L.current.sessionId=C),l(C),b(C),f(!0),be?.(C,w||_e,o?.fullPath||o?.path||null),!0):!1;if(!H){if(g.sessionId&&!ns(g.sessionId)&&L0({discoveredSessionId:g.sessionId,hasActiveViewSession:!!st,activeViewSessionId:st,hasPendingViewSession:!!L.current,isActiveRunMessage:j,pendingViewSessionId:L.current?.sessionId||null})&&(we(g.sessionId,g.provider||g.event?.provider||_e),st=g.sessionId),!st&&(g.sessionId&&($e.has(g.type)||it)&&(De==="streaming"||De==="awaiting_approval"||De==="awaiting_input"?te(g.sessionId):Ie(g.sessionId)),!ae)||!g.sessionId&&!ae)return;if(!ae&&g.sessionId!==st){const C=ns(st),w=!!(g.sessionId&&Et&&g.sessionId===Et);if(C&&(w||!ns(g.sessionId||"")))l(g.sessionId),L.current&&(L.current.sessionId=g.sessionId);else{g.sessionId&&($e.has(g.type)||it)&&(De==="streaming"||De==="awaiting_approval"||De==="awaiting_input"?te(g.sessionId):Ie(g.sessionId)),console.log("Skipping message for different session:",g.sessionId,"current:",st);return}}}const ut=g?.event?.sessionId||g.sessionId||st||null,gt=!!(ut&&He.current.has(ut));if(g.type==="conversation-event"&&g.event){const C=g.event.sessionId||g.sessionId||st||null,w=g.event.rawRef?.type||null,x=g.event.kind==="session_state_changed"?String(g.event.payload?.state||"").trim().toLowerCase():"";if(C&&He.current.add(C),x==="idle"&&$(C,w)){Se(C,g.event.provider||_e);return}const I=!!(C&&lb(g.event)&&me(C));if(!!(C&&(C===(s?.id||null)||C===(a||null)||C===(L.current?.sessionId||null)))&&ee(g.event),V(g.event,g.event.provider||_e,{suppressPhase:I}),I&&Fe(C),g.event.kind==="mode_update"){const U=hl(g.event.payload);q(ce=>Zl(ce,g.event.payload)),U&&Ke(g.event.provider||_e,{modeState:U,source:"conversation-event"})}if(g.event.kind==="available_commands_update"){const U=ps(g.event.payload);Z(U),Ke(g.event.provider,{availableCommands:U,source:"realtime-event"})}if(g.event.kind==="config_option_update"){const U=xl(g.event.payload||{});U.length>0&&Ke(g.event.provider||_e,{configOptions:U,source:"conversation-event"})}if(g.event.kind==="usage_update"){const U=sb(g.event.payload);U&&(z(U),Ke(g.event.provider||_e,{tokenUsage:U,source:"conversation-event"}))}if(!I&&g.event.kind==="approval_request"&&p(F.AWAITING_APPROVAL),!I&&g.event.kind==="approval_resolved"&&p(F.STREAMING),!I&&g.event.kind==="elicitation_request"&&p(F.AWAITING_INPUT),!I&&g.event.kind==="elicitation_resolved"&&p(F.STREAMING),!I&&(g.event.kind==="assistant_text_start"||g.event.kind==="assistant_text_delta"||g.event.kind==="assistant_content_block"||g.event.kind==="reasoning_start"||g.event.kind==="reasoning_delta"||g.event.kind==="tool_call_start"||g.event.kind==="tool_call_input"||g.event.kind==="tool_call_end"||g.event.kind==="tool_result"||g.event.kind==="plan_update")&&p(F.STREAMING),(g.event.kind==="error"||g.event.payload?.state==="errored")&&(D(C),oe(C,F.ERRORED),p(F.ERRORED),N(null),C&&(Ie(C),B(C,g.event.provider||_e,F.ERRORED))),g.event.kind==="session_state_changed"){const U=x;!I&&U==="streaming"?(p(F.STREAMING),C&&xe&&xe(C)):!I&&U==="awaiting_approval"?(p(F.AWAITING_APPROVAL),C&&xe&&xe(C)):!I&&U==="awaiting_input"?(p(F.AWAITING_INPUT),C&&xe&&xe(C)):U==="completed"?(D(C),oe(C,F.COMPLETED),p(F.COMPLETED),N(null),C&&(Ie(C),B(C,g.event.provider||_e,F.COMPLETED))):U==="aborted"?(D(C),oe(C,F.ABORTED),p(F.ABORTED),N(null),C&&(Ie(C),B(C,g.event.provider||_e,F.ABORTED))):U==="errored"&&(D(C),oe(C,F.ERRORED),p(F.ERRORED),N(null),C&&(Ie(C),B(C,g.event.provider||_e,F.ERRORED)))}return}switch(g.type){case"ws-connection-state":g.state==="connecting"&&(d===F.QUEUED||c)?p(F.CONNECTING,{canAbortSession:!1}):g.state==="connected"&&d===F.CONNECTING&&p(F.QUEUED),g.state==="connected"&&Xe("websocket_connected");break;case"run-state":{const C=String(g.event?.status||g.run?.status||"").trim().toLowerCase(),w=g.sessionId||g.run?.sessionId||a||null;if(np(C)&&Fe(w))break;C==="queued"?p(F.QUEUED):C==="running"?(p(F.STREAMING),w&&xe?.(w)):C==="awaiting_approval"?(p(F.AWAITING_APPROVAL),w&&xe?.(w)):C==="awaiting_input"?(p(F.AWAITING_INPUT),w&&xe?.(w)):C==="succeeded"?(D(w),oe(w,F.COMPLETED),p(F.COMPLETED),N(null),w&&(J?.(w),pe?.(w),B(w,g.provider||_e,F.COMPLETED))):C==="failed"?(D(w),oe(w,F.ERRORED),p(F.ERRORED),N(null),w&&(J?.(w),pe?.(w),B(w,g.provider||_e,F.ERRORED))):C==="canceled"&&(D(w),oe(w,F.ABORTED),p(F.ABORTED),N(null),w&&(J?.(w),pe?.(w),B(w,g.provider||_e,F.ABORTED)));break}case"connection-error":p(F.ERRORED),N(null),E(C=>[...C,{type:"error",content:g.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":p(F.ERRORED),_(!1),N(null),E(C=>[...C,{type:"error",content:g.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(g.sessionId){const C=Tt(g.provider||_e||t||"claude"),w=L.current?.sessionId||a||null,x=ns(g.sessionId);if(!(!a||C==="codex"&&g.sessionId!==a)||x)break;sessionStorage.setItem("pendingSessionId",g.sessionId);try{const U=localStorage.getItem("session-provider-map"),ce=U?JSON.parse(U):{};ce[g.sessionId]=C,localStorage.setItem("session-provider-map",JSON.stringify(ce))}catch{}if(m(g.sessionId),g.modes){const U=hl(g.modes);q(ce=>Zl(ce,g.modes)),U&&Ke(C,{modeState:U,source:"session-created"})}(g.configOptions||g.tokenUsage||g.availableCommands||g.capabilitySnapshot)&&(g.capabilitySnapshot?Qe(C,g.capabilitySnapshot):Ke(C,{configOptions:xl(g.configOptions||[]),tokenUsage:Pa(g.tokenUsage||null),availableCommands:ps(g.availableCommands||[]),source:"session-created"})),Array.isArray(g.availableCommands)&&Z(ps(g.availableCommands));const S=Pa(g.tokenUsage||null);S&&z(S),L.current&&(L.current.sessionId=g.sessionId),l(g.sessionId),b(g.sessionId),xe?.(g.sessionId),f(!0),he&&he(g.sessionId,w),y(U=>U.map(ce=>ce.sessionId?ce:{...ce,sessionId:g.sessionId})),be&&be(g.sessionId,C,o?.fullPath||o?.path||null),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":g.data&&z(g.data);break;case"claude-response":{const C=gt&&!(g.data?.type==="system"&&g.data?.subtype==="init");if(!C&&de&&typeof de=="object"&&de.type){if(de.type==="content_block_delta"&&de.delta?.text){const w=Jn(de.delta.text);T.current+=w,Y.current||(Y.current=setTimeout(()=>{const x=T.current;T.current="",Y.current=null,x&&E(I=>{const S=[...I],U=S[S.length-1];return U&&U.type==="assistant"&&!U.isToolUse&&U.isStreaming?S[S.length-1]={...U,content:(U.content||"")+x}:S.push({type:"assistant",content:x,timestamp:new Date,isStreaming:!0}),S})},100));return}if(de.type==="content_block_stop"){Y.current&&(clearTimeout(Y.current),Y.current=null);const w=T.current;T.current="",w&&E(x=>{const I=[...x],S=I[I.length-1];return S&&S.type==="assistant"&&!S.isToolUse&&S.isStreaming?I[I.length-1]={...S,content:(S.content||"")+w}:I.push({type:"assistant",content:w,timestamp:new Date,isStreaming:!0}),I}),E(x=>{const I=[...x],S=I[I.length-1];return S&&S.type==="assistant"&&S.isStreaming&&(I[I.length-1]={...S,isStreaming:!1}),I});return}}if(g.data.type==="system"&&g.data.subtype==="init"&&g.data.session_id&&a&&g.data.session_id!==a&&M){f(!0),m(g.data.session_id),be?.(g.data.session_id,"claude",o?.fullPath||o?.path||null);return}if(g.data.type==="system"&&g.data.subtype==="init"&&g.data.session_id&&!a&&M){f(!0),m(g.data.session_id),be?.(g.data.session_id,"claude",o?.fullPath||o?.path||null);return}if(g.data.type==="system"&&g.data.subtype==="init"&&g.data.session_id&&a&&g.data.session_id===a&&M)return;if(C)break;if(Array.isArray(de.content)){for(const w of de.content)if(w.type==="tool_use"){const x=w.input?JSON.stringify(w.input,null,2):"";E(I=>[...I,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:w.name,toolInput:x,toolId:w.id,toolResult:null}])}else if(w.type==="text"&&w.text?.trim()){let x=Jn(w.text);x=Ra(x),E(I=>[...I,{type:"assistant",content:x,timestamp:new Date}])}}else if(typeof de.content=="string"&&de.content.trim()){let w=Jn(de.content);w=Ra(w),E(x=>[...x,{type:"assistant",content:w,timestamp:new Date}])}if(de.role==="user"&&Array.isArray(de.content))for(const w of de.content)w.type==="tool_result"&&E(x=>x.map(I=>I.isToolUse&&I.toolId===w.tool_use_id?{...I,toolResult:{content:w.content,isError:w.is_error,timestamp:new Date}}:I));break}case"claude-output":if(gt)break;{const C=String(g.data||"");C.trim()&&(T.current+=T.current?`
|
|
209
|
+
${C}`:C,Y.current||(Y.current=setTimeout(()=>{const w=T.current;T.current="",Y.current=null,w&&E(x=>{const I=[...x],S=I[I.length-1];return S&&S.type==="assistant"&&!S.isToolUse&&S.isStreaming?I[I.length-1]={...S,content:S.content?`${S.content}
|
|
210
|
+
${w}`:w}:I.push({type:"assistant",content:w,timestamp:new Date,isStreaming:!0}),I})},100)))}break;case"claude-interactive-prompt":E(C=>[...C,{type:"assistant",content:g.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":if(gt||t!=="claude"||!g.requestId||Fe(g.sessionId||a||s?.id||null))break;y(C=>C.some(w=>w.requestId===g.requestId)?C:[...C,{requestId:g.requestId,toolName:g.toolName||"UnknownTool",input:g.input,context:g.context,toolCall:g.toolCall||null,options:Array.isArray(g.options)?g.options:Array.isArray(g.context?.options)?g.context.options:[],message:g.message||null,sessionId:g.sessionId||null,receivedAt:new Date}]),v(!0),_(!0),N(od({phaseText:Be("activity.stage.waitingPermission"),detailText:g.toolName?Be("activity.requestTool",{tool:Tf(g.toolName)}):Be("activity.permission.title"),canAbort:!0}));break;case"claude-permission-cancelled":if(gt||!g.requestId)break;y(C=>{const w=C.filter(x=>x.requestId!==g.requestId);return w.length===0&&N(null),w});break;case"claude-error":if(gt)break;D(g.sessionId||a||null),v(!1),_(!1),N(null),E(C=>[...C,{type:"error",content:`出错了:${g.error}`,timestamp:new Date}]);break;case"claude-complete":{if(gt)break;const C=g.sessionId||a||sessionStorage.getItem("pendingSessionId");D(C),(C===a||!a)&&(v(!1),_(!1),N(null)),C&&(J?.(C),pe?.(C));const w=sessionStorage.getItem("pendingSessionId");w&&!a&&g.exitCode===0&&(l(w),sessionStorage.removeItem("pendingSessionId")),o&&g.exitCode===0&&kt.removeItem(`chat_messages_${o.name}`),y([]);break}case"codex-response":{const C=g.data;if(!C||gt)break;if(C.type==="item_delta"&&C.delta){const w=Jn(String(C.delta));if(w){const x=`codex:${C.itemType||"item"}:${C.itemId||"unknown"}`;E(I=>{const S=[...I];let U=-1;for(let ce=S.length-1;ce>=0;ce-=1){const ze=S[ce];if(ze?.codexItemKey===x&&ze.type==="assistant"&&!ze.isToolUse){U=ce;break}}if(U===-1)S.push({type:"assistant",content:w,timestamp:new Date,isStreaming:!0,isThinking:!!C.isReasoning,codexItemKey:x});else{const ce=S[U],ze=ce.content||"";ze.endsWith(w)||(ce.content=ze+w),ce.isStreaming=!0}return S})}break}if(C.type==="item_done"){const w=`codex:${C.itemType||"item"}:${C.itemId||"unknown"}`,x=typeof C.content=="string"?Jn(C.content):"";E(I=>{const S=[...I];let U=-1;for(let ce=S.length-1;ce>=0;ce-=1){const ze=S[ce];if(ze?.codexItemKey===w&&ze.type==="assistant"&&!ze.isToolUse){U=ce;break}}if(U!==-1){const ce=S[U];x&&x!==(ce.content||"")&&(ce.content=x),ce.isStreaming=!1}else x.trim()&&S.push({type:"assistant",content:x,timestamp:new Date,isStreaming:!1,isThinking:!!C.isReasoning});return S});break}if(C.type==="item")switch(C.itemType){case"agent_message":if(C.message?.content?.trim()){const w=Jn(C.message.content);if(Pf(w))break;E(x=>{const I=x[x.length-1];return I&&I.type==="assistant"&&!I.isToolUse&&!I.isThinking&&(I.content||"").trim()===w.trim()?x:[...x,{type:"assistant",content:w,timestamp:new Date}]})}break;case"reasoning":if(C.message?.content?.trim()){const w=Jn(C.message.content);E(x=>{const I=x[x.length-1];return I&&I.type==="assistant"&&!I.isToolUse&&I.isThinking&&(I.content||"").trim()===w.trim()?x:[...x,{type:"assistant",content:w,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":C.command&&E(w=>[...w,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:C.command,toolResult:C.output||null,exitCode:C.exitCode}]);break;case"file_change":if(C.changes?.length>0){const w=C.changes.map(x=>`${x.kind}: ${x.path}`).join(`
|
|
211
|
+
`);E(x=>[...x,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:w,toolResult:`Status: ${C.status}`}])}break;case"mcp_tool_call":E(w=>[...w,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${C.server}:${C.tool}`,toolInput:JSON.stringify(C.arguments,null,2),toolResult:C.result?JSON.stringify(C.result,null,2):C.error?.message||null}]);break;case"error":C.message?.content&&E(w=>[...w,{type:"error",content:C.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",C.itemType,C)}C.type==="turn_complete"&&v(!1),C.type==="turn_failed"&&(v(!1),E(w=>[...w,{type:"error",content:C.error?.message||"Turn failed",timestamp:new Date}]));break}case"codex-complete":{if(gt)break;const C=g.sessionId||a||sessionStorage.getItem("pendingSessionId");D(C),(C===a||!a)&&(v(!1),_(!1),N(null),E(I=>I.map(S=>S?.codexItemKey&&S.isStreaming?{...S,isStreaming:!1}:S))),C&&(J?.(C),pe?.(C));const w=sessionStorage.getItem("pendingSessionId"),x=g.actualSessionId||w;w&&!a&&(l(x),f(!0),be?.(x,"codex",o?.fullPath||o?.path||null),sessionStorage.removeItem("pendingSessionId")),o&&C&&se(o.name,C,!1,"codex").then(I=>{Array.isArray(I)&&I.length>0&&Ae(I)}).catch(I=>{console.error("Error reloading Codex session after completion:",I)}),o&&kt.removeItem(`chat_messages_${o.name}`);break}case"codex-error":if(gt)break;D(g.sessionId||a||null),v(!1),_(!1),E(C=>C.map(w=>w?.codexItemKey&&w.isStreaming?{...w,isStreaming:!1}:w)),E(C=>[...C,{type:"error",content:g.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(gt)break;const C=g.sessionId||a;D(C),C===a&&(v(!1),_(!1),N(null)),C&&(J?.(C),pe?.(C)),y([]),E(w=>[...w,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(gt)break;const C=g.sessionId||a||s?.id||null,w=g.provider||s?.__provider||_e,x=C===a||s&&C===s.id,I=ue(Ce),S=W(Ce);if(x&&g.isProcessing){if(Fe(C))break;if(S){ve(C,S);break}v(!0),_(!0),xe?.(C)}else if(x&&g.isProcessing===!1){if($(C,"session-status")){Se(C,w);break}le(C,w).then(U=>{const ce=v0({recoveredPhase:I,recoveredPhaseFromHistory:U});if(ce!==F.IDLE){p(ce);return}p(F.IDLE),_(!1),N(null)})}break}case"claude-status":{const C=g.data;if(C){if(Fe(g.sessionId||a||s?.id||null)){Ve.current=null;break}let w={text:"Working...",tokens:0,can_interrupt:!0};C.message?w.text=C.message:C.status?w.text=C.status:typeof C=="string"&&(w.text=C),C.tokens?w.tokens=C.tokens:C.token_count&&(w.tokens=C.token_count),C.can_interrupt!==void 0&&(w.can_interrupt=C.can_interrupt);const x=Rf(C,Be,Ve.current);Ve.current=x,N(x),v(!0),_(w.can_interrupt)}break}}},[_e,ee,V,D,me,a,ue,W,c,se,oe,be,he,J,pe,xe,L,m,t,Fe,le,B,ve,Xe,d,Se,o,s,Ce,Z,q,_,E,N,l,v,f,y,p,Ae,z,$,b,Be]);i.useEffect(()=>{Te.current=rt,je?.(rt)},[je,rt]),i.useEffect(()=>{rt(e)},[e,rt])}function Ln(e){return Array.isArray?Array.isArray(e):sp(e)==="[object Array]"}function db(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ub(e){return e==null?"":db(e)}function An(e){return typeof e=="string"}function rp(e){return typeof e=="number"}function pb(e){return e===!0||e===!1||mb(e)&&sp(e)=="[object Boolean]"}function op(e){return typeof e=="object"}function mb(e){return op(e)&&e!==null}function rn(e){return e!=null}function xa(e){return!e.trim().length}function sp(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const fb="Incorrect 'index' type",hb=e=>`Invalid value for key ${e}`,xb=e=>`Pattern length exceeds max of ${e}.`,gb=e=>`Missing ${e} property in key`,vb=e=>`Property 'weight' in key '${e}' must be a positive integer`,ec=Object.prototype.hasOwnProperty;class yb{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(o=>{let s=ap(o);this._keys.push(s),this._keyMap[s.id]=s,n+=s.weight}),this._keys.forEach(o=>{o.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ap(e){let t=null,n=null,o=null,s=1,a=null;if(An(e)||Ln(e))o=e,t=tc(e),n=Ga(e);else{if(!ec.call(e,"name"))throw new Error(gb("name"));const l=e.name;if(o=l,ec.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(vb(l));t=tc(l),n=Ga(l),a=e.getFn}return{path:t,id:n,weight:s,src:o,getFn:a}}function tc(e){return Ln(e)?e:e.split(".")}function Ga(e){return Ln(e)?e.join("."):e}function bb(e,t){let n=[],o=!1;const s=(a,l,c)=>{if(rn(a))if(!l[c])n.push(a);else{let d=l[c];const u=a[d];if(!rn(u))return;if(c===l.length-1&&(An(u)||rp(u)||pb(u)))n.push(ub(u));else if(Ln(u)){o=!0;for(let m=0,p=u.length;m<p;m+=1)s(u[m],l,c+1)}else l.length&&s(u,l,c+1)}};return s(e,An(t)?t.split("."):t,0),o?n:n[0]}const wb={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},kb={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},Sb={location:0,threshold:.6,distance:100},jb={useExtendedSearch:!1,getFn:bb,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var We={...kb,...wb,...Sb,...jb};const Cb=/[^ ]+/g;function Nb(e=1,t=3){const n=new Map,o=Math.pow(10,t);return{get(s){const a=s.match(Cb).length;if(n.has(a))return n.get(a);const l=1/Math.pow(a,.5*e),c=parseFloat(Math.round(l*o)/o);return n.set(a,c),c},clear(){n.clear()}}}class $i{constructor({getFn:t=We.getFn,fieldNormWeight:n=We.fieldNormWeight}={}){this.norm=Nb(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,o)=>{this._keysMap[n.id]=o})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,An(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();An(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,o=this.size();n<o;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!rn(t)||xa(t))return;let o={v:t,i:n,n:this.norm.get(t)};this.records.push(o)}_addObject(t,n){let o={i:n,$:{}};this.keys.forEach((s,a)=>{let l=s.getFn?s.getFn(t):this.getFn(t,s.path);if(rn(l)){if(Ln(l)){let c=[];const d=[{nestedArrIndex:-1,value:l}];for(;d.length;){const{nestedArrIndex:u,value:m}=d.pop();if(rn(m))if(An(m)&&!xa(m)){let p={v:m,i:u,n:this.norm.get(m)};c.push(p)}else Ln(m)&&m.forEach((p,f)=>{d.push({nestedArrIndex:f,value:p})})}o.$[a]=c}else if(An(l)&&!xa(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 ip(e,t,{getFn:n=We.getFn,fieldNormWeight:o=We.fieldNormWeight}={}){const s=new $i({getFn:n,fieldNormWeight:o});return s.setKeys(e.map(ap)),s.setSources(t),s.create(),s}function Eb(e,{getFn:t=We.getFn,fieldNormWeight:n=We.fieldNormWeight}={}){const{keys:o,records:s}=e,a=new $i({getFn:t,fieldNormWeight:n});return a.setKeys(o),a.setIndexRecords(s),a}function os(e,{errors:t=0,currentLocation:n=0,expectedLocation:o=0,distance:s=We.distance,ignoreLocation:a=We.ignoreLocation}={}){const l=t/e.length;if(a)return l;const c=Math.abs(o-n);return s?l+c/s:c?1:l}function Ib(e=[],t=We.minMatchCharLength){let n=[],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&&n.push([o,s]),o=-1)}return e[a-1]&&a-o>=t&&n.push([o,a-1]),n}const er=32;function Ab(e,t,n,{location:o=We.location,distance:s=We.distance,threshold:a=We.threshold,findAllMatches:l=We.findAllMatches,minMatchCharLength:c=We.minMatchCharLength,includeMatches:d=We.includeMatches,ignoreLocation:u=We.ignoreLocation}={}){if(t.length>er)throw new Error(xb(er));const m=t.length,p=e.length,f=Math.max(0,Math.min(o,p));let y=a,v=f;const _=c>1||d,N=_?Array(p):[];let E;for(;(E=e.indexOf(t,v))>-1;){let T=os(t,{currentLocation:E,expectedLocation:f,distance:s,ignoreLocation:u});if(y=Math.min(T,y),v=E+m,_){let Y=0;for(;Y<m;)N[E+Y]=1,Y+=1}}v=-1;let z=[],q=1,Z=m+p;const K=1<<m-1;for(let T=0;T<m;T+=1){let Y=0,D=Z;for(;Y<D;)os(t,{errors:T,currentLocation:f+D,expectedLocation:f,distance:s,ignoreLocation:u})<=y?Y=D:Z=D,D=Math.floor((Z-Y)/2+Y);Z=D;let oe=Math.max(1,f-D+1),Q=l?p:Math.min(f+D,p)+m,b=Array(Q+2);b[Q+1]=(1<<T)-1;for(let L=Q;L>=oe;L-=1){let ee=L-1,le=n[e.charAt(ee)];if(_&&(N[ee]=+!!le),b[L]=(b[L+1]<<1|1)&le,T&&(b[L]|=(z[L+1]|z[L])<<1|1|z[L+1]),b[L]&K&&(q=os(t,{errors:T,currentLocation:ee,expectedLocation:f,distance:s,ignoreLocation:u}),q<=y)){if(y=q,v=ee,v<=f)break;oe=Math.max(1,2*f-v)}}if(os(t,{errors:T+1,currentLocation:f,expectedLocation:f,distance:s,ignoreLocation:u})>y)break;z=b}const V={isMatch:v>=0,score:Math.max(.001,q)};if(_){const T=Ib(N,c);T.length?d&&(V.indices=T):V.isMatch=!1}return V}function _b(e){let t={};for(let n=0,o=e.length;n<o;n+=1){const s=e.charAt(n);t[s]=(t[s]||0)|1<<o-n-1}return t}const js=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 lp{constructor(t,{location:n=We.location,threshold:o=We.threshold,distance:s=We.distance,includeMatches:a=We.includeMatches,findAllMatches:l=We.findAllMatches,minMatchCharLength:c=We.minMatchCharLength,isCaseSensitive:d=We.isCaseSensitive,ignoreDiacritics:u=We.ignoreDiacritics,ignoreLocation:m=We.ignoreLocation}={}){if(this.options={location:n,threshold:o,distance:s,includeMatches:a,findAllMatches:l,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m},t=d?t:t.toLowerCase(),t=u?js(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const p=(y,v)=>{this.chunks.push({pattern:y,alphabet:_b(y),startIndex:v})},f=this.pattern.length;if(f>er){let y=0;const v=f%er,_=f-v;for(;y<_;)p(this.pattern.substr(y,er),y),y+=er;if(v){const N=f-er;p(this.pattern.substr(N),N)}}else p(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:o,includeMatches:s}=this.options;if(t=n?t:t.toLowerCase(),t=o?js(t):t,this.pattern===t){let _={isMatch:!0,score:0};return s&&(_.indices=[[0,t.length-1]]),_}const{location:a,distance:l,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:m}=this.options;let p=[],f=0,y=!1;this.chunks.forEach(({pattern:_,alphabet:N,startIndex:E})=>{const{isMatch:z,score:q,indices:Z}=Ab(t,_,N,{location:a+E,distance:l,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:s,ignoreLocation:m});z&&(y=!0),f+=q,z&&Z&&(p=[...p,...Z])});let v={isMatch:y,score:y?f/this.chunks.length:1};return y&&s&&(v.indices=p),v}}class Hn{constructor(t){this.pattern=t}static isMultiMatch(t){return nc(t,this.multiRegex)}static isSingleMatch(t){return nc(t,this.singleRegex)}search(){}}function nc(e,t){const n=e.match(t);return n?n[1]:null}class Rb extends Hn{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Pb extends Hn{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 Tb extends Hn{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Mb extends Hn{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class Db extends Hn{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Lb extends Hn{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class cp extends Hn{constructor(t,{location:n=We.location,threshold:o=We.threshold,distance:s=We.distance,includeMatches:a=We.includeMatches,findAllMatches:l=We.findAllMatches,minMatchCharLength:c=We.minMatchCharLength,isCaseSensitive:d=We.isCaseSensitive,ignoreDiacritics:u=We.ignoreDiacritics,ignoreLocation:m=We.ignoreLocation}={}){super(t),this._bitapSearch=new lp(t,{location:n,threshold:o,distance:s,includeMatches:a,findAllMatches:l,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class dp extends Hn{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,o;const s=[],a=this.pattern.length;for(;(o=t.indexOf(this.pattern,n))>-1;)n=o+a,s.push([o,n-1]);const l=!!s.length;return{isMatch:l,score:l?0:1,indices:s}}}const Va=[Rb,dp,Tb,Mb,Lb,Db,Pb,cp],rc=Va.length,Ob=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Fb="|";function $b(e,t={}){return e.split(Fb).map(n=>{let o=n.trim().split(Ob).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<rc;){const m=Va[u];let p=m.isMultiMatch(c);p&&(s.push(new m(p,t)),d=!0)}if(!d)for(u=-1;++u<rc;){const m=Va[u];let p=m.isSingleMatch(c);if(p){s.push(new m(p,t));break}}}return s})}const zb=new Set([cp.type,dp.type]);class Bb{constructor(t,{isCaseSensitive:n=We.isCaseSensitive,ignoreDiacritics:o=We.ignoreDiacritics,includeMatches:s=We.includeMatches,minMatchCharLength:a=We.minMatchCharLength,ignoreLocation:l=We.ignoreLocation,findAllMatches:c=We.findAllMatches,location:d=We.location,threshold:u=We.threshold,distance:m=We.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:o,includeMatches:s,minMatchCharLength:a,findAllMatches:c,ignoreLocation:l,location:d,threshold:u,distance:m},t=n?t:t.toLowerCase(),t=o?js(t):t,this.pattern=t,this.query=$b(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:o,isCaseSensitive:s,ignoreDiacritics:a}=this.options;t=s?t:t.toLowerCase(),t=a?js(t):t;let l=0,c=[],d=0;for(let u=0,m=n.length;u<m;u+=1){const p=n[u];c.length=0,l=0;for(let f=0,y=p.length;f<y;f+=1){const v=p[f],{isMatch:_,indices:N,score:E}=v.search(t);if(_){if(l+=1,d+=E,o){const z=v.constructor.type;zb.has(z)?c=[...c,...N]:c.push(N)}}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 Qa=[];function Ub(...e){Qa.push(...e)}function Ja(e,t){for(let n=0,o=Qa.length;n<o;n+=1){let s=Qa[n];if(s.condition(e,t))return new s(e,t)}return new lp(e,t)}const Cs={AND:"$and",OR:"$or"},Ya={PATH:"$path",PATTERN:"$val"},Xa=e=>!!(e[Cs.AND]||e[Cs.OR]),qb=e=>!!e[Ya.PATH],Wb=e=>!Ln(e)&&op(e)&&!Xa(e),oc=e=>({[Cs.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function up(e,t,{auto:n=!0}={}){const o=s=>{let a=Object.keys(s);const l=qb(s);if(!l&&a.length>1&&!Xa(s))return o(oc(s));if(Wb(s)){const d=l?s[Ya.PATH]:a[0],u=l?s[Ya.PATTERN]:s[d];if(!An(u))throw new Error(hb(d));const m={keyId:Ga(d),pattern:u};return n&&(m.searcher=Ja(u,t)),m}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=s[d];Ln(u)&&u.forEach(m=>{c.children.push(o(m))})}),c};return Xa(e)||(e=oc(e)),o(e)}function Kb(e,{ignoreFieldNorm:t=We.ignoreFieldNorm}){e.forEach(n=>{let o=1;n.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))}),n.score=o})}function Hb(e,t){const n=e.matches;t.matches=[],rn(n)&&n.forEach(o=>{if(!rn(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 Gb(e,t){t.score=e.score}function Vb(e,t,{includeMatches:n=We.includeMatches,includeScore:o=We.includeScore}={}){const s=[];return n&&s.push(Hb),o&&s.push(Gb),e.map(a=>{const{idx:l}=a,c={item:t[l],refIndex:l};return s.length&&s.forEach(d=>{d(a,c)}),c})}class Rr{constructor(t,n={},o){this.options={...We,...n},this.options.useExtendedSearch,this._keyStore=new yb(this.options.keys),this.setCollection(t,o)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof $i))throw new Error(fb);this._myIndex=n||ip(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){rn(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];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,n.push(a))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:o,includeScore:s,shouldSort:a,sortFn:l,ignoreFieldNorm:c}=this.options;let d=An(t)?An(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Kb(d,{ignoreFieldNorm:c}),a&&d.sort(l),rp(n)&&n>-1&&(d=d.slice(0,n)),Vb(d,this._docs,{includeMatches:o,includeScore:s})}_searchStringList(t){const n=Ja(t,this.options),{records:o}=this._myIndex,s=[];return o.forEach(({v:a,i:l,n:c})=>{if(!rn(a))return;const{isMatch:d,score:u,indices:m}=n.searchIn(a);d&&s.push({item:a,idx:l,matches:[{score:u,value:a,norm:c,indices:m}]})}),s}_searchLogical(t){const n=up(t,this.options),o=(c,d,u)=>{if(!c.children){const{keyId:p,searcher:f}=c,y=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(d,p),searcher:f});return y&&y.length?[{idx:u,item:d,matches:y}]:[]}const m=[];for(let p=0,f=c.children.length;p<f;p+=1){const y=c.children[p],v=o(y,d,u);if(v.length)m.push(...v);else if(c.operator===Cs.AND)return[]}return m},s=this._myIndex.records,a={},l=[];return s.forEach(({$:c,i:d})=>{if(rn(c)){let u=o(n,c,d);u.length&&(a[d]||(a[d]={idx:d,item:c,matches:[]},l.push(a[d])),u.forEach(({matches:m})=>{a[d].matches.push(...m)}))}}),l}_searchObjectList(t){const n=Ja(t,this.options),{keys:o,records:s}=this._myIndex,a=[];return s.forEach(({$:l,i:c})=>{if(!rn(l))return;let d=[];o.forEach((u,m)=>{d.push(...this._findMatches({key:u,value:l[m],searcher:n}))}),d.length&&a.push({idx:c,item:l,matches:d})}),a}_findMatches({key:t,value:n,searcher:o}){if(!rn(n))return[];let s=[];if(Ln(n))n.forEach(({v:a,i:l,n:c})=>{if(!rn(a))return;const{isMatch:d,score:u,indices:m}=o.searchIn(a);d&&s.push({score:u,key:t,value:a,idx:l,norm:c,indices:m})});else{const{v:a,n:l}=n,{isMatch:c,score:d,indices:u}=o.searchIn(a);c&&s.push({score:d,key:t,value:a,norm:l,indices:u})}return s}}Rr.version="7.1.0";Rr.createIndex=ip;Rr.parseIndex=Eb;Rr.config=We;Rr.parseQuery=up;Ub(Bb);var ga={exports:{}},va,sc;function Qb(){if(sc)return va;sc=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return va=e,va}var ya,ac;function Jb(){if(ac)return ya;ac=1;var e=Qb();function t(){}function n(){}return n.resetWarningCache=t,ya=function(){function o(l,c,d,u,m,p){if(p!==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:n,resetWarningCache:t};return a.PropTypes=a,a},ya}var ic;function Yb(){return ic||(ic=1,ga.exports=Jb()()),ga.exports}var Xb=Yb();const wt=Vc(Xb),Zb=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 _r(e,t,n){const o=ew(e),{webkitRelativePath:s}=e,a=typeof t=="string"?t:typeof s=="string"&&s.length>0?s:`./${e.name}`;return typeof o.path!="string"&&lc(o,"path",a),lc(o,"relativePath",a),o}function ew(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const o=t.split(".").pop().toLowerCase(),s=Zb.get(o);s&&Object.defineProperty(e,"type",{value:s,writable:!1,configurable:!1,enumerable:!0})}return e}function lc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const tw=[".DS_Store","Thumbs.db"];function nw(e){return lr(this,void 0,void 0,function*(){return Ns(e)&&rw(e.dataTransfer)?iw(e.dataTransfer,e.type):ow(e)?sw(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?aw(e):[]})}function rw(e){return Ns(e)}function ow(e){return Ns(e)&&Ns(e.target)}function Ns(e){return typeof e=="object"&&e!==null}function sw(e){return Za(e.target.files).map(t=>_r(t))}function aw(e){return lr(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>_r(n))})}function iw(e,t){return lr(this,void 0,void 0,function*(){if(e.items){const n=Za(e.items).filter(s=>s.kind==="file");if(t!=="drop")return n;const o=yield Promise.all(n.map(lw));return cc(pp(o))}return cc(Za(e.files).map(n=>_r(n)))})}function cc(e){return e.filter(t=>tw.indexOf(t.name)===-1)}function Za(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const o=e[n];t.push(o)}return t}function lw(e){if(typeof e.webkitGetAsEntry!="function")return dc(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?mp(t):dc(e,t)}function pp(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?pp(n):[n]],[])}function dc(e,t){return lr(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const a=yield e.getAsFileSystemHandle();if(a===null)throw new Error(`${e} is not a File`);if(a!==void 0){const l=yield a.getFile();return l.handle=a,_r(l)}}const o=e.getAsFile();if(!o)throw new Error(`${e} is not a File`);return _r(o,(n=t?.fullPath)!==null&&n!==void 0?n:void 0)})}function cw(e){return lr(this,void 0,void 0,function*(){return e.isDirectory?mp(e):dw(e)})}function mp(e){const t=e.createReader();return new Promise((n,o)=>{const s=[];function a(){t.readEntries(l=>lr(this,void 0,void 0,function*(){if(l.length){const c=Promise.all(l.map(cw));s.push(c),a()}else try{const c=yield Promise.all(s);n(c)}catch(c){o(c)}}),l=>{o(l)})}a()})}function dw(e){return lr(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(o=>{const s=_r(o,e.fullPath);t(s)},o=>{n(o)})})})}var ss={},uc;function uw(){return uc||(uc=1,ss.__esModule=!0,ss.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var o=e.name||"",s=(e.type||"").toLowerCase(),a=s.replace(/\/.*$/,"");return n.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}),ss}var pw=uw();const ba=Vc(pw);function pc(e){return hw(e)||fw(e)||hp(e)||mw()}function mw(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
212
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fw(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function hw(e){if(Array.isArray(e))return ei(e)}function mc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,o)}return n}function fc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?mc(Object(n),!0).forEach(function(o){fp(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mc(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function fp(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function po(e,t){return vw(e)||gw(e,t)||hp(e,t)||xw()}function xw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
213
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hp(e,t){if(e){if(typeof e=="string")return ei(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ei(e,t)}}function ei(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function gw(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o=[],s=!0,a=!1,l,c;try{for(n=n.call(e);!(s=(l=n.next()).done)&&(o.push(l.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,c=d}finally{try{!s&&n.return!=null&&n.return()}finally{if(a)throw c}}return o}}function vw(e){if(Array.isArray(e))return e}var yw=typeof ba=="function"?ba:ba.default,bw="file-invalid-type",ww="file-too-large",kw="file-too-small",Sw="too-many-files",jw=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=t.split(","),o=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:bw,message:"File type must be ".concat(o)}},hc=function(t){return{code:ww,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},xc=function(t){return{code:kw,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Cw={code:Sw,message:"Too many files"};function xp(e,t){var n=e.type==="application/x-moz-file"||yw(e,t);return[n,n?null:jw(t)]}function gp(e,t,n){if(tr(e.size))if(tr(t)&&tr(n)){if(e.size>n)return[!1,hc(n)];if(e.size<t)return[!1,xc(t)]}else{if(tr(t)&&e.size<t)return[!1,xc(t)];if(tr(n)&&e.size>n)return[!1,hc(n)]}return[!0,null]}function tr(e){return e!=null}function Nw(e){var t=e.files,n=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=xp(d,n),m=po(u,1),p=m[0],f=gp(d,o,s),y=po(f,1),v=y[0],_=c?c(d):null;return p&&v&&!_})}function Es(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function as(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function gc(e){e.preventDefault()}function Ew(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Iw(e){return e.indexOf("Edge/")!==-1}function Aw(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Ew(e)||Iw(e)}function En(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];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!Es(o)&&c&&c.apply(void 0,[o].concat(a)),Es(o)})}}function _w(){return"showOpenFilePicker"in window}function Rw(e){if(tr(e)){var t=Object.entries(e).filter(function(n){var o=po(n,2),s=o[0],a=o[1],l=!0;return vp(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(yp))&&(console.warn('Skipped "'.concat(s,'" because an invalid file extension was provided.')),l=!1),l}).reduce(function(n,o){var s=po(o,2),a=s[0],l=s[1];return fc(fc({},n),{},fp({},a,l))},{});return[{description:"Files",accept:t}]}return e}function Pw(e){if(tr(e))return Object.entries(e).reduce(function(t,n){var o=po(n,2),s=o[0],a=o[1];return[].concat(pc(t),[s],pc(a))},[]).filter(function(t){return vp(t)||yp(t)}).join(",")}function Tw(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function Mw(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function vp(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function yp(e){return/^.*\.[\w]+$/.test(e)}var Dw=["children"],Lw=["open"],Ow=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],Fw=["refKey","onChange","onClick"];function $w(e){return Uw(e)||Bw(e)||bp(e)||zw()}function zw(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
214
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bw(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Uw(e){if(Array.isArray(e))return ti(e)}function wa(e,t){return Kw(e)||Ww(e,t)||bp(e,t)||qw()}function qw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
215
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bp(e,t){if(e){if(typeof e=="string")return ti(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ti(e,t)}}function ti(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function Ww(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o=[],s=!0,a=!1,l,c;try{for(n=n.call(e);!(s=(l=n.next()).done)&&(o.push(l.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,c=d}finally{try{!s&&n.return!=null&&n.return()}finally{if(a)throw c}}return o}}function Kw(e){if(Array.isArray(e))return e}function vc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,o)}return n}function It(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?vc(Object(n),!0).forEach(function(o){ni(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vc(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function ni(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Is(e,t){if(e==null)return{};var n=Hw(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)&&(n[o]=e[o])}return n}function Hw(e,t){if(e==null)return{};var n={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var zi=i.forwardRef(function(e,t){var n=e.children,o=Is(e,Dw),s=kp(o),a=s.open,l=Is(s,Lw);return i.useImperativeHandle(t,function(){return{open:a}},[a]),Rt.createElement(i.Fragment,null,n(It(It({},l),{},{open:a})))});zi.displayName="Dropzone";var wp={disabled:!1,getFilesFromEvent:nw,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};zi.defaultProps=wp;zi.propTypes={children:wt.func,accept:wt.objectOf(wt.arrayOf(wt.string)),multiple:wt.bool,preventDropOnDocument:wt.bool,noClick:wt.bool,noKeyboard:wt.bool,noDrag:wt.bool,noDragEventsBubbling:wt.bool,minSize:wt.number,maxSize:wt.number,maxFiles:wt.number,disabled:wt.bool,getFilesFromEvent:wt.func,onFileDialogCancel:wt.func,onFileDialogOpen:wt.func,useFsAccessApi:wt.bool,autoFocus:wt.bool,onDragEnter:wt.func,onDragLeave:wt.func,onDragOver:wt.func,onDrop:wt.func,onDropAccepted:wt.func,onDropRejected:wt.func,onError:wt.func,validator:wt.func};var ri={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function kp(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=It(It({},wp),e),n=t.accept,o=t.disabled,s=t.getFilesFromEvent,a=t.maxSize,l=t.minSize,c=t.multiple,d=t.maxFiles,u=t.onDragEnter,m=t.onDragLeave,p=t.onDragOver,f=t.onDrop,y=t.onDropAccepted,v=t.onDropRejected,_=t.onFileDialogCancel,N=t.onFileDialogOpen,E=t.useFsAccessApi,z=t.autoFocus,q=t.preventDropOnDocument,Z=t.noClick,K=t.noKeyboard,V=t.noDrag,T=t.noDragEventsBubbling,Y=t.onError,D=t.validator,oe=i.useMemo(function(){return Pw(n)},[n]),Q=i.useMemo(function(){return Rw(n)},[n]),b=i.useMemo(function(){return typeof N=="function"?N:yc},[N]),$=i.useMemo(function(){return typeof _=="function"?_:yc},[_]),L=i.useRef(null),ee=i.useRef(null),le=i.useReducer(Gw,ri),ve=wa(le,2),ue=ve[0],W=ve[1],Se=ue.isFocused,Ce=ue.isFileDialogActive,Ae=i.useRef(typeof window<"u"&&window.isSecureContext&&E&&_w()),se=function(){!Ae.current&&Ce&&setTimeout(function(){if(ee.current){var B=ee.current.files;B.length||(W({type:"closeDialog"}),$())}},300)};i.useEffect(function(){return window.addEventListener("focus",se,!1),function(){window.removeEventListener("focus",se,!1)}},[ee,Ce,$,Ae]);var J=i.useRef([]),pe=function(B){L.current&&L.current.contains(B.target)||(B.preventDefault(),J.current=[])};i.useEffect(function(){return q&&(document.addEventListener("dragover",gc,!1),document.addEventListener("drop",pe,!1)),function(){q&&(document.removeEventListener("dragover",gc),document.removeEventListener("drop",pe))}},[L,q]),i.useEffect(function(){return!o&&z&&L.current&&L.current.focus(),function(){}},[L,z,o]);var xe=i.useCallback(function(P){Y?Y(P):console.error(P)},[Y]),he=i.useCallback(function(P){P.preventDefault(),P.persist(),Qe(P),J.current=[].concat($w(J.current),[P.target]),as(P)&&Promise.resolve(s(P)).then(function(B){if(!(Es(P)&&!T)){var me=B.length,Fe=me>0&&Nw({files:B,accept:oe,minSize:l,maxSize:a,multiple:c,maxFiles:d,validator:D}),rt=me>0&&!Fe;W({isDragAccept:Fe,isDragReject:rt,isDragActive:!0,type:"setDraggedFiles"}),u&&u(P)}}).catch(function(B){return xe(B)})},[s,u,xe,T,oe,l,a,c,d,D]),be=i.useCallback(function(P){P.preventDefault(),P.persist(),Qe(P);var B=as(P);if(B&&P.dataTransfer)try{P.dataTransfer.dropEffect="copy"}catch{}return B&&p&&p(P),!1},[p,T]),je=i.useCallback(function(P){P.preventDefault(),P.persist(),Qe(P);var B=J.current.filter(function(Fe){return L.current&&L.current.contains(Fe)}),me=B.indexOf(P.target);me!==-1&&B.splice(me,1),J.current=B,!(B.length>0)&&(W({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),as(P)&&m&&m(P))},[L,m,T]),Be=i.useCallback(function(P,B){var me=[],Fe=[];P.forEach(function(rt){var fe=xp(rt,oe),g=wa(fe,2),ie=g[0],Ne=g[1],de=gp(rt,l,a),Oe=wa(de,2),Me=Oe[0],$e=Oe[1],De=D?D(rt):null;if(ie&&Me&&!De)me.push(rt);else{var it=[Ne,$e];De&&(it=it.concat(De)),Fe.push({file:rt,errors:it.filter(function(ge){return ge})})}}),(!c&&me.length>1||c&&d>=1&&me.length>d)&&(me.forEach(function(rt){Fe.push({file:rt,errors:[Cw]})}),me.splice(0)),W({acceptedFiles:me,fileRejections:Fe,isDragReject:Fe.length>0,type:"setFiles"}),f&&f(me,Fe,B),Fe.length>0&&v&&v(Fe,B),me.length>0&&y&&y(me,B)},[W,c,oe,l,a,d,f,y,v,D]),Ve=i.useCallback(function(P){P.preventDefault(),P.persist(),Qe(P),J.current=[],as(P)&&Promise.resolve(s(P)).then(function(B){Es(P)&&!T||Be(B,P)}).catch(function(B){return xe(B)}),W({type:"reset"})},[s,Be,xe,T]),He=i.useCallback(function(){if(Ae.current){W({type:"openDialog"}),b();var P={multiple:c,types:Q};window.showOpenFilePicker(P).then(function(B){return s(B)}).then(function(B){Be(B,null),W({type:"closeDialog"})}).catch(function(B){Tw(B)?($(B),W({type:"closeDialog"})):Mw(B)?(Ae.current=!1,ee.current?(ee.current.value=null,ee.current.click()):xe(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."))):xe(B)});return}ee.current&&(W({type:"openDialog"}),b(),ee.current.value=null,ee.current.click())},[W,b,$,E,Be,xe,Q,c]),nt=i.useCallback(function(P){!L.current||!L.current.isEqualNode(P.target)||(P.key===" "||P.key==="Enter"||P.keyCode===32||P.keyCode===13)&&(P.preventDefault(),He())},[L,He]),Pe=i.useCallback(function(){W({type:"focus"})},[]),lt=i.useCallback(function(){W({type:"blur"})},[]),ct=i.useCallback(function(){Z||(Aw()?setTimeout(He,0):He())},[Z,He]),Te=function(B){return o?null:B},Je=function(B){return K?null:Te(B)},_e=function(B){return V?null:Te(B)},Qe=function(B){T&&B.stopPropagation()},Ke=i.useMemo(function(){return function(){var P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},B=P.refKey,me=B===void 0?"ref":B,Fe=P.role,rt=P.onKeyDown,fe=P.onFocus,g=P.onBlur,ie=P.onClick,Ne=P.onDragEnter,de=P.onDragOver,Oe=P.onDragLeave,Me=P.onDrop,$e=Is(P,Ow);return It(It(ni({onKeyDown:Je(En(rt,nt)),onFocus:Je(En(fe,Pe)),onBlur:Je(En(g,lt)),onClick:Te(En(ie,ct)),onDragEnter:_e(En(Ne,he)),onDragOver:_e(En(de,be)),onDragLeave:_e(En(Oe,je)),onDrop:_e(En(Me,Ve)),role:typeof Fe=="string"&&Fe!==""?Fe:"presentation"},me,L),!o&&!K?{tabIndex:0}:{}),$e)}},[L,nt,Pe,lt,ct,he,be,je,Ve,K,V,o]),mt=i.useCallback(function(P){P.stopPropagation()},[]),Xe=i.useMemo(function(){return function(){var P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},B=P.refKey,me=B===void 0?"ref":B,Fe=P.onChange,rt=P.onClick,fe=Is(P,Fw),g=ni({accept:oe,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:Te(En(Fe,Ve)),onClick:Te(En(rt,mt)),tabIndex:-1},me,ee);return It(It({},g),fe)}},[ee,n,c,Ve,o]);return It(It({},ue),{},{isFocused:Se&&!o,getRootProps:Ke,getInputProps:Xe,rootRef:L,inputRef:ee,open:Te(He)})}function Gw(e,t){switch(t.type){case"focus":return It(It({},e),{},{isFocused:!0});case"blur":return It(It({},e),{},{isFocused:!1});case"openDialog":return It(It({},ri),{},{isFileDialogActive:!0});case"closeDialog":return It(It({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return It(It({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return It(It({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"reset":return It({},ri);default:return e}}function yc(){}const As=3,oi=1e4;function mo(e){return Array.isArray(e)?e.filter(Boolean):[]}function Vw(e,t,n=As){const o=mo(e),s=Number.isInteger(n)&&n>0?n:As;return t?o.length>=s?{accepted:!1,reason:"full",queue:o}:{accepted:!0,reason:null,queue:[...o,t]}:{accepted:!1,reason:"invalid",queue:o}}function Qw(e){if(!e)return null;const t=String(e.clientRequestId||e.id||"").trim();return t?{id:t,text:String(e.rawInput||""),snapshot:e,createdAt:e.createdAt||Date.now()}:null}function Jw(e,t,n=As){const o=Qw(t);return{...Vw(e,o,n),item:o,submitNow:!1}}function Yw({isLoading:e=!1,activeRun:t=null,pendingQueueLength:n=0,queueGraceUntilMs:o=0,nowMs:s=Date.now()}={}){if(e||t||Number(n)>0)return!0;const a=Number(o),l=Number(s);return Number.isFinite(a)&&Number.isFinite(l)&&a>0&&l<=a}function Xw({isLoading:e=!1,wasLoading:t=!1,currentGraceUntilMs:n=0,nowMs:o=Date.now(),graceMs:s=oi}={}){const a=Number(o),l=Number(s),c=Number(n),d=Number.isFinite(a)?a:Date.now(),u=Number.isFinite(l)&&l>0?l:oi;return e?d+u:t?0:Number.isFinite(c)&&c>0?c:0}function Zw({wasLoading:e=!1,isLoading:t=!1,activeRun:n=null,isAutoSending:o=!1,immediateSendingId:s=null,pendingQueueLength:a=0,holdForImmediateSend:l=!1,hasObservedImmediateLoading:c=!1,holdUntilMs:d=0,nowMs:u=Date.now()}={}){if(t||n||o||s||Number(a)<=0)return!1;const m=Number(d),p=Number(u);return Number.isFinite(m)&&Number.isFinite(p)&&m>0&&p<m?!1:l?!!c:!!e}function e1(e,t){const n=String(t||"").trim();return n?mo(e).filter(o=>String(o?.id||"")!==n):mo(e)}function t1(e,t){const n=mo(e),o=String(t||"").trim(),s=n.findIndex(a=>String(a?.id||"")===o);return s<0?{item:null,queue:n}:{item:n[s],queue:n.filter((a,l)=>l!==s)}}function n1(e){const t=mo(e);return t.length===0?{item:null,queue:t}:{item:t[0],queue:t.slice(1)}}async function r1({queue:e,replaceQueue:t,submitPromptSnapshot:n}={}){const o=n1(e);return typeof t=="function"&&t(o.queue),o.item?.snapshot?(typeof n=="function"&&await n(o.item.snapshot),{sent:!0,item:o.item,queue:o.queue}):{sent:!1,item:null,queue:o.queue}}async function o1({queue:e,itemId:t,replaceQueue:n,cancelActiveRun:o,submitPromptSnapshot:s}={}){const a=t1(e,t);return typeof n=="function"&&n(a.queue),a.item?.snapshot?(typeof o=="function"&&await o(),typeof s=="function"&&await s(a.item.snapshot),{sent:!0,item:a.item,queue:a.queue}):{sent:!1,item:null,queue:a.queue}}function s1(){let e=!1,t=null;return{isLocked(){return e},currentKey(){return t},tryAcquire(n=null){return e?!1:(e=!0,t=n,!0)},release(n=void 0){n!==void 0&&n!==t||(e=!1,t=null)}}}function a1(e,{isLoading:t=!1,activeRun:n=null}={}){return!e?.isLocked?.()||t||n?.runId?!1:(e.release(),!0)}const Sp=new Set(["succeeded","failed","canceled"]);function i1(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.floor(t):0}function jp(e){return String(e||"").trim().toLowerCase()}function bc(){return{id:null,event:"message",dataLines:[]}}function l1(e){const t=e.dataLines.join(`
|
|
216
|
+
`);let n=null,o=null;if(t)try{n=JSON.parse(t)}catch(s){o=s}return{id:e.id,event:e.event||"message",data:t,payload:n,error:o}}function wc(e=""){const t=[];let n=bc();return String(e||"").replace(/\r\n/g,`
|
|
217
|
+
`).replace(/\r/g,`
|
|
218
|
+
`).split(`
|
|
219
|
+
`).forEach(a=>{if(a===""){n.dataLines.length>0&&t.push(l1(n)),n=bc();return}if(a.startsWith(":"))return;const l=a.indexOf(":"),c=l===-1?a:a.slice(0,l),d=l===-1?"":a.slice(l+1),u=d.startsWith(" ")?d.slice(1):d;c==="id"?n.id=u:c==="event"?n.event=u||"message":c==="data"&&n.dataLines.push(u)}),t}function si(e,t){if(!t||typeof t!="object")return null;if(e==="end"){const n=jp(t.status||t.event?.status);return Sp.has(n)?{type:"run-state",provider:t.provider,sessionId:t.sessionId,clientRequestId:t.clientRequestId,runId:t.runId,runEventSeq:t.seq,event:{status:n}}:null}return e==="conversation-event"||t.type==="conversation-event"?{type:"conversation-event",provider:t.provider,sessionId:t.sessionId,clientRequestId:t.clientRequestId,runId:t.runId,runEventSeq:t.seq,event:t.event}:e==="run-state"||t.type==="run-state"?{type:"run-state",provider:t.provider,sessionId:t.sessionId,clientRequestId:t.clientRequestId,runId:t.runId,runEventSeq:t.seq,event:t.event}:e==="error"?{type:"error",provider:t.provider,sessionId:t.sessionId,clientRequestId:t.clientRequestId,runId:t.runId,runEventSeq:t.seq,error:t.error||t.message||"Run stream failed."}:null}function Bi(e,t){if(e==="end")return!0;const n=jp(t?.event?.status||t?.status);return Sp.has(n)}function c1(e=globalThis?.localStorage){try{return e?.getItem?.("chat-run-sse-enabled")!=="false"}catch{return!0}}function Cp({runId:e,after:t=0,onMessage:n,onError:o,onEnd:s,onDisconnect:a,fetchImpl:l=globalThis.fetch?.bind(globalThis)}={}){if(!e||typeof l!="function")return()=>{};const c=`/api/runs/${encodeURIComponent(e)}/stream?after=${encodeURIComponent(String(i1(t)))}`,d=new AbortController;let u=!1,m=!1;const p=()=>{u||(u=!0,d.abort())},f=v=>{if(u)return;if(v.error){o?.(v.error);return}const _=v.event,N=v.payload;if(_==="end"){const z=si(_,N);z&&n?.(z),m=!0,s?.(N),p();return}const E=si(_,N);E&&n?.(E),Bi(_,N)&&(m=!0,s?.(N),p())};return(async()=>{try{const v=await l(c,{method:"GET",headers:{Accept:"text/event-stream"},signal:d.signal});if(!v?.ok)throw new Error(`Run stream failed with ${v?.status||"unknown status"}`);if(!v.body?.getReader)throw new Error("Run stream response is not readable.");const _=v.body.getReader(),N=new TextDecoder;let E="";for(;!u;){const{value:z,done:q}=await _.read();if(q)break;E+=N.decode(z,{stream:!0});const Z=Math.max(E.lastIndexOf(`
|
|
220
|
+
|
|
221
|
+
`),E.lastIndexOf(`\r
|
|
222
|
+
\r
|
|
223
|
+
`));if(Z===-1)continue;const K=E.slice(0,Z+2);E=E.slice(Z+2),wc(K).forEach(f)}E+=N.decode(),E.trim()&&wc(`${E}
|
|
224
|
+
|
|
225
|
+
`).forEach(f),!u&&!m&&a?.()}catch(v){u||o?.(v)}})(),p}const Np=1800*1e3,d1="command-list:v1";function Ep(e){return String(e||"").trim().toLowerCase()||"unknown"}function u1(e){return String(e||"").trim()}function is(e){if(e!==void 0)return JSON.parse(JSON.stringify(e))}function p1(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=Array.isArray(t.builtIn)?is(t.builtIn):[],o=Array.isArray(t.skills)?is(t.skills):[],s=Array.isArray(t.custom)?is(t.custom):[];return{...is(t),builtIn:n,skills:o,custom:s,count:Number.isFinite(Number(t.count))?Number(t.count):n.length+o.length+s.length}}function Ip(e,t){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=Object.prototype.hasOwnProperty.call(t,"payload")?t.payload:t;return{provider:Ep(t.provider||e),ttl:Number.isFinite(Number(t.ttl))&&Number(t.ttl)>0?Number(t.ttl):Np,updatedAt:t.updatedAt||new Date().toISOString(),payload:p1(n)}}function Ap(e,t=null){const n=encodeURIComponent(Ep(e)),o=u1(t);return`${d1}:${n}:${o?encodeURIComponent(o):"global"}`}function m1(e,t=null,n=kt){const o=Ap(e,t),s=n.getItem(o);if(!s)return null;try{return Ip(e,JSON.parse(s))}catch{return n.removeItem(o),null}}function f1(e,t=null,n=null,o=kt){const s=Ip(e,n),a=Ap(e,t);return s?(o.setItem(a,JSON.stringify(s)),s):(o.removeItem(a),null)}function h1(e,t=Date.now()){if(!e||typeof e!="object")return!1;const n=Date.parse(e.updatedAt||"");if(!Number.isFinite(n))return!1;const o=Number(e.ttl||Np);return Number.isFinite(o)&&o>0&&Number(t)-n<o}function x1(e,{force:t=!1,now:n=Date.now()}={}){return t?!0:!h1(e,n)}const g1=1,v1="2026-05-14T03:19:23.238Z",y1={codex:{provider:"codex",source:"generated-default",updatedAt:"2026-05-14T03:19:23.238Z",ttl:18e5,agentVersion:null,capabilities:{model:{key:"model",description:"Choose which model Codex should use",value:"gpt-5.5",currentValue:"gpt-5.5",options:[{value:"gpt-5.5",label:"GPT-5.5",description:"Frontier model for complex coding, research, and real-world work.",order:0},{value:"gpt-5.4",label:"gpt-5.4",description:"Strong model for everyday coding.",order:1},{value:"gpt-5.4-mini",label:"GPT-5.4-Mini",description:"Small, fast, and cost-efficient model for simpler coding tasks.",order:2},{value:"gpt-5.3-codex",label:"gpt-5.3-codex",description:"Coding-optimized model.",order:3},{value:"gpt-5.2",label:"gpt-5.2",description:"Optimized for professional work and long-running agents.",order:4}],schema:null},mode:{key:"mode",description:"Choose an approval and sandboxing preset for your session",value:"auto",currentValue:"auto",options:[{value:"read-only",label:"Read Only",description:"Codex can read files in the current workspace. Approval is required to edit files or access the internet.",order:0},{value:"auto",label:"Default",description:"Codex can read and edit files in the current workspace, and run commands. Approval is required to access the internet or edit other files. (Identical to Agent mode)",order:1},{value:"full-access",label:"Full Access",description:"Codex can edit files outside this workspace and access the internet without asking for approval. Exercise caution when using.",order:2}],schema:null,modeState:{availableModes:[{id:"read-only",name:"Read Only",description:"Codex can read files in the current workspace. Approval is required to edit files or access the internet.",order:0},{id:"auto",name:"Default",description:"Codex can read and edit files in the current workspace, and run commands. Approval is required to access the internet or edit other files. (Identical to Agent mode)",order:1},{id:"full-access",name:"Full Access",description:"Codex can edit files outside this workspace and access the internet without asking for approval. Exercise caution when using.",order:2}],currentModeId:"auto"}},thought_level:{key:"thought_level",description:"Choose how much reasoning effort the model should use",value:"xhigh",currentValue:"xhigh",options:[{value:"low",label:"Low",description:"Fast responses with lighter reasoning",order:0},{value:"medium",label:"Medium",description:"Balances speed and reasoning depth for everyday tasks",order:1},{value:"high",label:"High",description:"Greater reasoning depth for complex problems",order:2},{value:"xhigh",label:"Xhigh",description:"Extra high reasoning depth for complex problems",order:3}],schema:null}},metadata:{tokenUsage:null,availableCommands:[]}}},b1={schemaVersion:g1,generatedAt:v1,providers:y1};function w1(e){return Mf(b1,e)}const k1=new Set(["update_context","update_prompt"]);function S1(e){return typeof e=="string"&&e.trim()?e.trim():null}function j1(e){if(!e||typeof e!="object"||Array.isArray(e)||!k1.has(e.type))return null;const t=S1(e.requestId);return e.type==="update_prompt"?typeof e.prompt!="string"?{type:"integration.prompt.update",requestId:t,payload:{}}:{type:"integration.prompt.update",requestId:t,payload:{prompt:e.prompt,autoSend:e.autoSend===!0}}:{type:"integration.context.update",requestId:t,payload:{context:e.context,mode:e.mode}}}function C1({provider:e="",sessionPinnedModel:t="",acpCurrentModel:n="",selectedProviderModel:o=""}={}){return String(e||"").trim().toLowerCase()==="codex"?t||n||"":t||n||o||""}function N1({provider:e="",acpModelOptions:t=[],runtimeModelOptions:n=[],fallbackModelOptions:o=[],sessionPinnedModel:s=""}={}){const a=String(e||"").trim().toLowerCase(),l=Array.isArray(t)?t:[],c=Array.isArray(n)?n:[],d=Array.isArray(o)?o:[],u=l.length>0?l:c.length>0?c:a==="codex"?[]:d;return a==="codex"&&u.length===0?[]:!s||u.some(m=>m?.value===s)?u:[{value:s,label:s},...u]}const kc={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"]}},Sc={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 jc(e){return kc[e]||kc.claude}function Cc(e){return Sc[e]||Sc.claude}function E1(e){return e==="claude"||e==="codex"}function I1(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}let Nc=!1;const A1=!1,ls=4e3;function Ec(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function _1(e){return new Promise(t=>setTimeout(t,e))}function R1(e){const t=String(e||"").trim().toLowerCase();return t==="succeeded"?"completed":t==="failed"?"errored":t==="canceled"?"aborted":null}function P1(e){return new Promise((t,n)=>{if(!(e instanceof Blob)){n(new Error("无效的图片文件"));return}const o=new FileReader;o.onload=()=>t(typeof o.result=="string"?o.result:""),o.onerror=()=>n(o.error||new Error("读取图片失败")),o.readAsDataURL(e)})}async function T1(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(n,o)=>{const s=await P1(n);if(!s)throw new Error("图片编码失败");return{name:n?.name||`image-${o+1}.png`,data:s,size:Number(n?.size)||0,mimeType:n?.type||"application/octet-stream"}}))}function M1(e){const t=String(e||"").trim();if(!t)return"";const n=t.split(/[\\/]/);return n[n.length-1]||t}function D1(e=[]){return Array.from(new Set(Array.isArray(e)?e.filter(Boolean):[])).map(t=>{const n=String(t||"").trim();return n?{type:"resource_link",uri:n,name:M1(n)}:null}).filter(Boolean)}function L1(){const e=mi(kt.getItem("agent-command-overrides"));if(!e||typeof e!="object"||Array.isArray(e))return;const t=Object.fromEntries(Object.entries(e).map(([n,o])=>[String(n||"").trim().toLowerCase(),typeof o=="string"?o.trim():""]).filter(([n,o])=>n&&o));return Object.keys(t).length>0?t:void 0}function _p(e,t=0){if(!e||typeof e!="object")return null;const n=String(e.modeId||e.id||e.value||"").trim();if(!n)return null;const o=`Mode ${t+1}`;return{id:n,name:String(e.name||e.label||n||o).trim()||o,description:typeof e.description=="string"?e.description:""}}function ka(e=null){const t=e?.acpModes?.availableModes||e?.modes?.availableModes||e?.availableModes||[],n=Array.isArray(t)?t.map((s,a)=>_p(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:n,currentModeId:o}}function ai(e){return Array.isArray(e?.options)?e.options.filter(t=>t&&typeof t=="object"&&String(t.value||"").trim()).map(t=>({value:String(t.value).trim(),label:String(t.label||t.value).trim()||String(t.value).trim(),description:typeof t.description=="string"?t.description:""})):[]}function O1(e){const t=Array.isArray(e?.modeState?.availableModes)?e.modeState.availableModes.map((n,o)=>_p(n,o)).filter(Boolean):[];return t.length>0?t:ai(e).map(n=>({id:n.value,name:n.label,description:n.description}))}function F1(e){return String(e||"").trim().replace(/^\//,"").toLowerCase()}function $1(e,t=0){if(!e||typeof e!="object")return null;const n=String(e.name||e.command||e.id||"").trim();if(!n)return null;const o=n.startsWith("/")?n:`/${n}`;return{...e,id:String(e.id||o||`acp-${t}`).trim(),name:o,description:typeof e.description=="string"?e.description:"",type:"acp",source:"acp"}}function z1(...e){const t=[],n=new Set;for(const o of e)for(const s of ps(o||[])){const a=F1(s.name);!a||n.has(a)||(n.add(a),t.push(s))}return t}function B1(e=null,t=null){const n=e?.acpAvailableCommands||e?.availableCommands||e?.acpCommands||[],o=t?.metadata?.availableCommands||[];return z1(n,o).map((s,a)=>$1(s,a)).filter(Boolean)}function U1(e={}){const t=Array.isArray(e.skills)?e.skills.map(o=>({...o,type:"skill",namespace:"skill",source:"skill"})):[],n=[...(Array.isArray(e.builtIn)?e.builtIn:[]).map(o=>({...o,type:"built-in"})),...(Array.isArray(e.custom)?e.custom:[]).map(o=>({...o,type:"custom"}))];return{skills:t,allCommands:n}}function q1(e=[],t=null){if(!t)return e;const n=`command_history_${t}`,o=kt.getItem(n);if(!o)return e;try{const s=JSON.parse(o);return[...e].sort((a,l)=>{const c=s[a.name]||0;return(s[l.name]||0)-c})}catch(s){return console.error("Error parsing command history:",s),e}}function W1({selectedProject:e,selectedSession:t,selectedProjectRef:n,initialProvider:o,currentSessionId:s,canAbortSession:a,isLoading:l,setChatMessages:c,setCanAbortSession:d,setRuntimePhase:u,setClaudeStatus:m,pendingPermissionRequests:p,setPendingPermissionRequests:f,setPendingElicitationRequests:y,sendMessage:v,onRunCreated:_,onRunTerminalDiscovered:N,activeRunRef:E,clearLocalRunGuard:z,markTerminalRunState:q,onSessionActive:Z,onSessionInactive:K,onSessionNotProcessing:V,onInputFocusChange:T,onShowSettings:Y,onFileOpen:D,appendSessionConversationEvent:oe,startLocalRunGuard:Q,pendingViewSessionRef:b,scrollToBottom:$,setIsUserScrolledUp:L,tokenBudget:ee,chatMessages:le,setSessionMessages:ve,resetRuntimeForNewChat:ue,urlContext:W,urlPrompt:Se,integrationClientId:Ce,latestIntegrationMessage:Ae,sendIntegrationMessage:se,sendByCtrlEnter:J}){const{t:pe}=Ot("chat"),xe=A1,[he,be]=i.useState(()=>typeof window<"u"&&e?.name?Gl(e.name):""),[je,Be]=i.useState(!1),[Ve,He]=i.useState([]),[nt,Pe]=i.useState(new Map),[lt,ct]=i.useState(new Map),[Te,Je]=i.useState(!1),[_e,Qe]=i.useState([]),[Ke,mt]=i.useState([]),[Xe,P]=i.useState([]),[B,me]=i.useState(-1),[Fe,rt]=i.useState(0),[fe,g]=i.useState(-1),[ie,Ne]=i.useState(!1),[de,Oe]=i.useState([]),[Me,$e]=i.useState([]),[De,it]=i.useState([]),[ge,Re]=i.useState([]),[Et,st]=i.useState(""),[j,M]=i.useState(!1),[H,ae]=i.useState(-1),[Ie,te]=i.useState(-1),[we,ut]=i.useState(()=>{const h=Wl({urlProvider:o,selectedSessionProvider:t?.__provider||null,storedProvider:localStorage.getItem("selected-provider")});return jc(h).defaultMode}),gt=i.useMemo(()=>ka(t),[t]),[C,w]=i.useState(()=>gt.currentModeId),[x,I]=i.useState("none"),[S,U]=i.useState(()=>Wl({urlProvider:o,selectedSessionProvider:t?.__provider||null,storedProvider:localStorage.getItem("selected-provider")})),[ce,ze]=i.useState(()=>ts("claude")),[ft,Ue]=i.useState(()=>ts("codex")),[St,Ct]=i.useState(()=>ts("gemini")),[Kt,X]=i.useState(()=>ts("opencode")),[Ht,jn]=i.useState({}),[Ft,en]=i.useState({}),[gn,vn]=i.useState({}),[tn,Ze]=i.useState({}),[Gt,ke]=i.useState({}),[Pr,dr]=i.useState({}),[Ks,Tr]=i.useState({}),Fn=i.useMemo(()=>ql(W),[W]),[Hs,Mr]=i.useState(Fn),[an,A]=i.useState(Fn),[G,ne]=i.useState(!1),[Ee,Le]=i.useState([]),[Ye,dt]=i.useState(null),[$t,Mt]=i.useState(null),[jt,yn]=i.useState(0),pt=i.useRef(null),Rn=i.useRef(null),Dt=i.useRef(null),$n=i.useRef(null),zn=i.useRef(null),zt=i.useRef(null),Pt=i.useRef(s1()),Dr=i.useRef(Fn),Cn=i.useRef([]),Gs=i.useRef(!1),Pn=i.useRef(null),qi=i.useRef(l),Wi=i.useRef(l),Lr=i.useRef(!1),No=i.useRef(!1),Or=i.useRef(0),Eo=i.useRef(0),Io=i.useRef(0),Ki=i.useRef({projectName:e?.name||null,sessionId:t?.id||null}),Ao=i.useRef(!1),Tn=i.useRef(null),Hi=i.useRef(S),_o=i.useRef(new Map),Ro=i.useRef(new Map),Po=i.useRef(new Map),Gi=i.useRef(new Set),Mn=i.useMemo(()=>jc(S),[S]),Dn=i.useMemo(()=>U0({skillCommands:De,acpCommands:Me,apiCommands:de}),[Me,de,De]),Bp=Dn.length>0,Gn=i.useMemo(()=>Cc(S),[S]),_t=e?.fullPath||e?.path||null,Vs=t?.acpCapabilitySnapshot||null,Qs=Ht[S]||null,Vt=Qs?.capabilities||{},Vi=i.useMemo(()=>ai(Vt.model),[Vt.model]),ur=i.useMemo(()=>ai(Vt.thought_level),[Vt.thought_level]),[pr,Js]=i.useState(""),Ys=i.useMemo(()=>ka(t),[t]),Xs=i.useMemo(()=>O1(Vt.mode),[Vt.mode]),Fr=i.useMemo(()=>{const h=Xs.length>0?Xs:Ys.availableModes,k=typeof Vt.mode?.currentValue=="string"?Vt.mode.currentValue.trim():"";return{availableModes:h,currentModeId:k||Ys.currentModeId||h[0]?.id||""}},[Vt.mode,Xs,Ys]),To=S==="claude"?ce:S==="codex"?ft:S==="gemini"?St:Kt,Qi=i.useMemo(()=>Ly(S).OPTIONS,[S]),Ji=i.useMemo(()=>(Ft[S]||[]).map(h=>({value:h,label:h})),[Ft,S]),Mo=t?.__provider===S&&By(S,t?.model)?t.model.trim():"",Up=typeof Vt.model?.currentValue=="string"?Vt.model.currentValue.trim():"",Nn=C1({provider:S,sessionPinnedModel:Mo,acpCurrentModel:Up,selectedProviderModel:To}),Do=i.useMemo(()=>N1({provider:S,acpModelOptions:Vi,runtimeModelOptions:Ji,fallbackModelOptions:Qi,sessionPinnedModel:Mo}),[S,Vi,Ji,Qi,Mo]),qp=Do.find(h=>h.value===Nn)?.label||Nn||pe("providerSelection.selectModel"),Wp=!!Mo,Kp=S==="opencode"&&!!tn.opencode,Zs=i.useCallback((h,{short:k=!1}={})=>{let R=pe("codex.modes.default");return h==="acceptEdits"?R=pe("codex.modes.acceptEdits"):h==="bypassPermissions"?R=pe("codex.modes.bypassPermissions"):h==="plan"&&(R=pe("codex.modes.plan")),k?R.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):R},[pe]),Hp=i.useMemo(()=>Zs(we,{short:!0}),[Zs,we]),Gp=i.useMemo(()=>pe("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[pe]),Lo=i.useCallback((h,k,R)=>{const O=tp(h,k,R);return O&&jn(re=>({...re,[h]:to(re[h],O)})),O},[]),mr=i.useCallback((h=S,k=_t,{force:R=!1}={})=>{const O=Tt(h||"claude"),re=`${O}:${k||"global"}`;if(!R){const ot=Cr(O,k);if(!Yl(ot))return ot&&jn(bt=>({...bt,[O]:to(bt[O],ot)})),Promise.resolve(ot)}if(_o.current.has(re))return _o.current.get(re);const ye=et.providerAcpCapabilities(O,k,{force:R}).then(async ot=>{if(!ot.ok)throw new Error(`HTTP ${ot.status}`);return ot.json()}).then(ot=>Lo(O,k,ot?.capabilitySnapshot||ot)).catch(()=>Cr(O,k)).finally(()=>{_o.current.delete(re)});return _o.current.set(re,ye),ye},[Lo,S,_t]),fr=i.useCallback((h=S,k=_t,{force:R=!1}={})=>{const O=Tt(h);if(!k)return Promise.resolve(null);const re=`runtime-models:v2:${O}:${k}`,ye=mi(kt.getItem(re)),ot=Array.isArray(ye?.models)?ye.models:[],bt=typeof ye?.currentModel=="string"?ye.currentModel.trim():"",Wt=Number(ye?.timestamp||0),Qn=ot.length>0&&Date.now()-Wt<Dy;if(!R&&Qn)return en(vt=>({...vt,[O]:ot})),bt&&vn(vt=>({...vt,[O]:{...vt?.[O]||{},currentModel:bt}})),Promise.resolve(ye);if(Ro.current.has(re))return Ro.current.get(re);Ze(vt=>({...vt,[O]:!0}));const Bn=et.providerDiscovery(O,k,{force:R}).then(async vt=>{if(!vt.ok)throw new Error(`HTTP ${vt.status}`);return vt.json()}).then(vt=>{const cn=Array.isArray(vt?.models)?vt.models.map(Qt=>Qt.id):[],Br=typeof vt?.currentModel=="string"?vt.currentModel.trim():"";vn(Qt=>({...Qt,[O]:vt})),en(Qt=>({...Qt,[O]:cn})),cn.length>0&&kt.setItem(re,JSON.stringify({models:cn,currentModel:Br||"",timestamp:Date.now()}))}).catch(()=>{en(vt=>({...vt,[O]:ot}))}).finally(()=>{Ro.current.delete(re),Ze(vt=>({...vt,[O]:!1}))});return Ro.current.set(re,Bn),Bn},[S,_t]),ea=i.useCallback((h,k=e?.name)=>{const{skills:R,allCommands:O}=U1(h);it(R),Oe(q1(O,k))},[e?.name]),hr=i.useCallback((h=S,k=_t,R=e?.name,{force:O=!1}={})=>{if(!k)return it([]),Oe([]),Promise.resolve(null);const re=Tt(h),ye=m1(re,k);if(ye?.payload&&ea(ye.payload,R),!x1(ye,{force:O}))return Promise.resolve(ye);const ot=`${re}:${k}`;if(Po.current.has(ot))return Po.current.get(ot);const bt=Zt("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:k,provider:re})}).then(async Wt=>{if(!Wt.ok)throw new Error("Failed to fetch commands");return Wt.json()}).then(Wt=>{const Qn=f1(re,k,Wt);return ea(Qn?.payload||Wt,R),Qn}).catch(Wt=>(console.error("Error fetching slash commands:",Wt),ye?.payload||(it([]),Oe([])),ye)).finally(()=>{Po.current.delete(ot)});return Po.current.set(ot,bt),bt},[ea,S,e?.name,_t]),Yi=i.useCallback(()=>{const h=e?.fullPath||e?.path||_t;if(!h)return;const k=Tt(t?.__provider||S);hr(k,h,e?.name,{force:!0}).catch(()=>{})},[S,hr,e?.fullPath,e?.name,e?.path,_t,t?.__provider]),ta=i.useCallback(async(h,{force:k=!1}={})=>{if(!My.includes(h))return null;dr(R=>({...R,[h]:!0})),Tr(R=>({...R,[h]:null})),ke(R=>({...R,[h]:{status:Ty}}));try{const O=await Zt(`/api/cli/providers/${h}/installation-status${k?"?force=true":""}`),re=await O.json().catch(()=>({}));if(!O.ok||re?.success!==!0)throw new Error(re?.error||`Failed to check ${h} installation`);const ye=re.installed?Py:es;return ke(ot=>({...ot,[h]:{status:ye,command:re.command||null,resolvedPath:re.resolvedPath||null,reason:re.reason||null,installHint:re.installHint||null,checkedAt:re.checkedAt||null,cacheHit:!!re.cacheHit}})),ye}catch(R){return ke(O=>({...O,[h]:{status:Gr}})),Tr(O=>({...O,[h]:R.message})),Gr}finally{dr(R=>({...R,[h]:!1}))}},[Tr,dr,ke]),Vp=i.useCallback(h=>{if(!h)return;const k=Tt(h);U(k),localStorage.setItem("selected-provider",k),ta(k,{force:!0}),mr(k,_t),fr(k,_t),hr(k,_t,e?.name)},[ta,mr,hr,fr,e?.name,_t]);i.useEffect(()=>{const h=S||"claude",k=w1(h),R=k?ob(h,_t,k):Cr(h,_t);R&&jn(O=>({...O,[h]:to(O[h],R)})),Yl(R)&&mr(h,_t).catch(()=>{})},[S,mr,_t]),i.useEffect(()=>{if(!Vs)return;const h=Tt(t?.__provider||S||"claude");Lo(h,_t,Vs)},[Lo,S,_t,t?.__provider,Vs]),i.useEffect(()=>{const h=Do.map(k=>k.value);!To||h.includes(To)||(S==="claude"?ze(""):S==="codex"?Ue(""):S==="gemini"?Ct(""):S==="opencode"&&X(""),Fy(S))},[S,To,Do]),i.useEffect(()=>{const h=Fr.availableModes.map(R=>R.id).filter(Boolean);if(h.length===0){C&&w("");return}const k=h.includes(Fr.currentModeId)?Fr.currentModeId:h[0];h.includes(C)||w(k)},[C,Fr]),i.useEffect(()=>{if(!e)return;const h=e.fullPath||e.path;h&&fr(S,h).catch(()=>{})},[S,fr,e]),i.useEffect(()=>{Dr.current=an},[an]),i.useEffect(()=>{Cn.current=Ee},[Ee]);const ln=i.useCallback(h=>{const k=Array.isArray(h)?h:[];Cn.current=k,Le(k)},[]),xr=i.useCallback((h=ls)=>{const k=Number(h),R=Date.now()+(Number.isFinite(k)&&k>0?k:ls);Eo.current=Math.max(Eo.current,R)},[]),Xi=i.useRef(Nc);i.useEffect(()=>{if(Xi.current)return;const h=Wa(Se);h&&(be(h),Ao.current=!0,Xi.current=!0,Nc=!0)},[Se]),i.useEffect(()=>{Mr(Fn),A(Fn),ne(!1)},[Fn]);const bn=i.useCallback((h,k,R={})=>{!k||typeof se!="function"||se({type:h,requestId:k,payload:{...R,clientId:Ce||null}})},[Ce,se]),Oo=i.useCallback((h,k=null)=>{if(typeof h?.context!="object"||h.context==null||Array.isArray(h.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),bn("integration.error",k,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(hy(h.mode)===qa){const re=my(Dr.current,h.context);if(!re){console.warn("[DynamicContext] Ignored invalid append context payload."),bn("integration.error",k,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Mr(re),A(re),ne(!1),bn("integration.ack",k,{accepted:!0,applied:!0});return}const O=ql(h.context);if(!O){bn("integration.error",k,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Mr(O),A(O),ne(!1),bn("integration.ack",k,{accepted:!0,applied:!0})},[bn]),Fo=i.useCallback((h,k=null)=>{if(typeof h?.prompt!="string"){bn("integration.error",k,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const R=Wa(h.prompt);if(be(R),Ao.current=!0,h.autoSend===!0&&R&&n.current&&!l&&zt.current){const O={preventDefault:()=>{}};zt.current(O,R,{allowQueueGrace:!1})}bn("integration.ack",k,{accepted:!0,applied:!0})},[l,n,bn]),Zi=i.useCallback((h=null)=>{bn("integration.ack",h,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,bn]);i.useEffect(()=>{if(!Ae?.__messageSeq)return;const k=Ae?.type;if(k==="integration.context.update"){Oo(Ae.payload||{},Ae.requestId||null);return}if(k==="integration.prompt.update"){Fo(Ae.payload||{},Ae.requestId||null);return}k==="integration.ping"&&Zi(Ae.requestId||null)},[Oo,Fo,Ae,Zi]),i.useEffect(()=>{const h=k=>{if(k.source&&k.source!==window.parent&&k.source!==window.opener&&k.source!==window)return;const R=j1(k.data);R&&(R.type==="integration.context.update"&&Oo(R.payload||{},R.requestId||null),R.type==="integration.prompt.update"&&Fo(R.payload||{},R.requestId||null))};return window.addEventListener("message",h),()=>{window.removeEventListener("message",h)}},[Oo,Fo]);const Vn=i.useMemo(()=>G||!an||!cy(an)?null:an,[G,an]),Qp=i.useMemo(()=>Vn?.selectedElements?.slice(0,zl)||[],[Vn]),Jp=i.useMemo(()=>Vn?.selectedElements?.slice(zl)||[],[Vn]),Yp=i.useMemo(()=>Mi(Vn),[Vn]),Xp=i.useCallback(()=>{A(h=>!h||!Sn(h.systemContext)?h:{...h,systemContext:""})},[]),Zp=i.useCallback(()=>{A(h=>!h||!Sn(ar(h.currentFile))?h:{...h,currentFile:{path:"",displayName:""}})},[]),em=i.useCallback(h=>{A(k=>{if(!k||!Array.isArray(k.selectedElements)||k.selectedElements.length===0)return k;const R=k.selectedElements.findIndex(O=>O.tag===h.tag&&O.selector===h.selector&&O.label===h.label);return R<0?k:{...k,selectedElements:k.selectedElements.filter((O,re)=>re!==R)}})},[]),tm=i.useCallback(h=>{A(k=>k&&fy(k,h))},[]);i.useEffect(()=>{if(t?.id){const h=localStorage.getItem(`permissionMode-${t.id}`);h&&Mn.modes.includes(h)?ut(h):ut(Mn.defaultMode)}},[t?.id,Mn]),i.useEffect(()=>{Mn.modes.includes(we)||ut(Mn.defaultMode)},[we,Mn]),i.useEffect(()=>{if(!(ur.length>0)){if(!Gn.enabled){x!==Gn.defaultMode&&I(Gn.defaultMode);return}Gn.modes.includes(x)||I(Gn.defaultMode)}},[ur.length,Gn,x]),i.useEffect(()=>{if(ur.length===0){pr&&Js("");return}const h=ur.map(O=>O.value),k=typeof Vt.thought_level?.currentValue=="string"?Vt.thought_level.currentValue.trim():"",R=h.includes(k)?k:h[0]||"";h.includes(pr)||Js(R)},[Vt.thought_level,ur,pr]),i.useEffect(()=>{if(t&&t.__provider&&t.__provider!==S){const h=Tt(t.__provider);U(h),localStorage.setItem("selected-provider",h)}if(t?.id&&t?.__provider)try{const h=localStorage.getItem("session-provider-map"),k=h?JSON.parse(h):{};k[t.id]!==t.__provider&&(k[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify(k)))}catch{}},[S,t]),i.useEffect(()=>{Hi.current!==S&&(f([]),y?.([]),Hi.current=S)},[S,y,f]),i.useEffect(()=>{f(h=>h.filter(k=>!k.sessionId||k.sessionId===t?.id)),y?.(h=>h.filter(k=>!k.sessionId||k.sessionId===t?.id))},[t?.id,y,f]),i.useEffect(()=>{const h=ka(t),k=new Set(h.availableModes.map(R=>R.id));w(R=>h.currentModeId&&k.has(h.currentModeId)?h.currentModeId:R&&k.has(R)?R:"")},[t]),i.useEffect(()=>{$e(B1(t,Qs))},[Qs,t]),i.useEffect(()=>{if(!e)return;const h=e.fullPath||e.path;hr(S,h,e.name).catch(()=>{})},[S,hr,e]);const na=i.useMemo(()=>Dn.length?new Rr(Dn,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Dn]);i.useEffect(()=>{if(!Et){Re(Dn);return}if(!na){Re([]);return}const h=na.search(Et);Re(h.map(k=>k.item))},[Et,Dn,na]);const nm=i.useMemo(()=>{if(!e||Dn.length===0)return[];const h=`command_history_${e.name}`,k=kt.getItem(h);if(!k)return[];try{const R=JSON.parse(k);return Dn.map(O=>({...O,usageCount:R[O.name]||0})).filter(O=>O.usageCount>0).sort((O,re)=>re.usageCount-O.usageCount).slice(0,5)}catch(R){return console.error("Error parsing command history:",R),[]}},[Dn,e]),el=i.useCallback(h=>{const{action:k,data:R}=h;switch(k){case"clear":c([]),ve([]);break;case"help":c(O=>[...O,{role:"assistant",content:R.content,timestamp:Date.now()}]);break;case"model":{const O=Object.entries(R.available||{}).filter(([,ye])=>Array.isArray(ye)&&ye.length>0).map(([ye,ot])=>`**${ye.charAt(0).toUpperCase()+ye.slice(1)}**: ${ot.join(", ")}`).join(`
|
|
226
|
+
|
|
227
|
+
`),re=R.current.provider==="opencode"?R.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";c(ye=>[...ye,{role:"assistant",content:`**Current Model**: ${R.current.model}
|
|
228
|
+
|
|
229
|
+
**Available Models**:
|
|
230
|
+
|
|
231
|
+
${O}${re?`
|
|
232
|
+
|
|
233
|
+
${re}`:""}`,timestamp:Date.now()}]);break}case"cost":{const O=`**Token Usage**: ${R.tokenUsage.used.toLocaleString()} / ${R.tokenUsage.total.toLocaleString()} (${R.tokenUsage.percentage}%)
|
|
234
|
+
|
|
235
|
+
**Estimated Cost**:
|
|
236
|
+
- Input: $${R.cost.input}
|
|
237
|
+
- Output: $${R.cost.output}
|
|
238
|
+
- **Total**: $${R.cost.total}
|
|
239
|
+
|
|
240
|
+
**Model**: ${R.model}`;c(re=>[...re,{role:"assistant",content:O,timestamp:Date.now()}]);break}case"status":{const O=`**System Status**
|
|
241
|
+
|
|
242
|
+
- Version: ${R.version}
|
|
243
|
+
- Uptime: ${R.uptime}
|
|
244
|
+
- Model: ${R.model}
|
|
245
|
+
- Provider: ${R.provider}
|
|
246
|
+
- Node.js: ${R.nodeVersion}
|
|
247
|
+
- Platform: ${R.platform}`;c(re=>[...re,{role:"assistant",content:O,timestamp:Date.now()}]);break}case"memory":R.error?c(O=>[...O,{role:"assistant",content:`⚠️ ${R.message}`,timestamp:Date.now()}]):(c(O=>[...O,{role:"assistant",content:`📝 ${R.message}
|
|
248
|
+
|
|
249
|
+
Path: \`${R.path}\``,timestamp:Date.now()}]),R.exists&&D&&D(R.path));break;case"config":Y&&Y();break;case"rewind":R.error?c(O=>[...O,{role:"assistant",content:`⚠️ ${R.message}`,timestamp:Date.now()}]):(c(O=>O.slice(0,-R.steps*2)),c(O=>[...O,{role:"assistant",content:`⏪ ${R.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",k)}},[D,Y,c,ve]),tl=i.useCallback(async h=>{const{content:k,hasBashCommands:R}=h;if(R&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){c(re=>[...re,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}be(k),setTimeout(()=>{if(zt.current){const O={preventDefault:()=>{}};zt.current(O)}},50)},[c]),$o=i.useCallback(async h=>{if(!(!h||!e))try{const k=he.match(new RegExp(`${h.name}\\s*(.*)`)),R=k&&k[1]?k[1].trim().split(/\s+/):[],O={projectPath:e.path,projectName:e.name,sessionId:s,provider:S,...Nn?{model:Nn}:{},tokenUsage:ee},re=await Zt("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:h.name,commandPath:h.path,args:R,context:O})});if(!re.ok)throw new Error("Failed to execute command");const ye=await re.json();ye.type==="builtin"?el(ye):ye.type==="custom"&&await tl(ye,R),be(""),Ne(!1),te(-1),st(""),ae(-1)}catch(k){console.error("Error executing command:",k),c(R=>[...R,{role:"assistant",content:`Error executing command: ${k.message}`,timestamp:Date.now()}])}},[Nn,s,el,tl,he,S,e,c,ee]),rm=i.useCallback(h=>{const k=String(h||"").trim();if(!k||k===C)return;w(k);const R=t?.id||s;if(!R)return;const O=t?.__provider||S||"claude";v({type:"set-session-mode",provider:O,sessionId:R,modeId:k})},[C,s,S,t?.__provider,t?.id,v]),zo=i.useCallback(h=>{if(!h||!e?.name)return;const k=`command_history_${e.name}`,R=kt.getItem(k);let O={};try{O=R?JSON.parse(R):{}}catch(re){console.error("Error parsing command history:",re)}O[h.name]=(O[h.name]||0)+1,kt.setItem(k,JSON.stringify(O))},[e?.name]),om=i.useCallback((h,k,R)=>{if(!(!h||!e)){if(R){ae(k);return}if(zo(h),h?.source==="acp"||h?.source==="skill"){const O=String(h.name||"").trim(),re=O.startsWith("/")?`${O} `:`/${O} `;be(re),Ne(!1),te(-1),st(""),ae(-1);return}$o(h)}},[$o,zo,e,st,ae,Ne,te]),ra=i.useCallback(h=>{if(!h)return;const k=h?.source==="acp"||h?.source==="skill",R=String(h.name||"").trim(),O=k&&R&&!R.startsWith("/")?`/${R}`:R,re=he.slice(0,Ie),ye=he.slice(Ie),ot=ye.indexOf(" "),bt=ot!==-1?ye.slice(ot):"",Wt=`${re}${O} ${bt}`;be(Wt),Ne(!1),te(-1),st(""),ae(-1),Tn.current&&clearTimeout(Tn.current),zo(h),k||$o(h)},[$o,zo,he,Ie,st,ae,Ne,te]);i.useEffect(()=>{{Qe([]);return}},[xe,e]),i.useEffect(()=>{{Je(!1),g(-1),P([]),me(-1);return}},[Fe,_e,he,xe]);const $r=i.useMemo(()=>[],[Ke,he,xe]),zr=i.useMemo(()=>$r.length===0?[]:Array.from(new Set($r)).sort((h,k)=>k.length-h.length),[$r]),sm=i.useMemo(()=>zr.length===0?null:new RegExp(`(${zr.map(ey).join("|")})`,"g"),[zr]),am=i.useMemo(()=>new Set(zr),[zr]),im=i.useCallback(h=>h||"",[sm,am,xe]),Bo=i.useCallback(h=>{const k=h.filter(R=>{try{if(!R||typeof R!="object"||!R.type||!R.type.startsWith("image/"))return!1;if(!R.size||R.size>5242880){const O=R.name||"Unknown file";return ct(re=>{const ye=new Map(re);return ye.set(O,"File too large (max 5MB)"),ye}),!1}return!0}catch(O){return console.error("Error validating file:",O,R),!1}});k.length>0&&He(R=>[...R,...k].slice(0,5))},[]),lm=i.useCallback(h=>{const k=Array.from(h.clipboardData.items);for(const R of k)if(R.type.startsWith("image/")){const O=R.getAsFile();O&&Bo([O])}if(k.length===0&&h.clipboardData.files.length>0){const O=Array.from(h.clipboardData.files).filter(re=>re.type.startsWith("image/"));O.length>0&&Bo(O)}},[Bo]),{getRootProps:cm,getInputProps:dm,isDragActive:um,open:pm}=kp({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:Bo,noClick:!0,noKeyboard:!0}),nl=i.useCallback((h,k={})=>{const R=String(h||""),O=t?.__provider||S||"claude",re=k.clientRequestId||Ec(),ye=!G&&ly(an)?xy(an):null;return{id:re,clientRequestId:re,rawInput:R,provider:O,selectedProject:e,selectedSession:t,currentSessionId:s,activeFileMentions:$r,attachedImages:[...Ve],contextPayload:ye,dynamicContextSent:G,acpModeId:C,thoughtLevel:pr,thinkingMode:x,permissionMode:we,currentModel:Nn,createdAt:Date.now()}},[$r,C,Ve,Nn,s,G,an,we,S,e,t,pr,x]),Uo=i.useCallback(()=>{be(""),He([]),Pe(new Map),ct(new Map),M(!1),I("none"),Ne(!1),Je(!1),st(""),te(-1),ae(-1),me(-1),dt(null),e?.name&&ks(e.name),pt.current&&(pt.current.style.height="auto")},[e?.name]),rl=i.useCallback(h=>{xr();const k=Jw(Cn.current,h);return ln(k.queue),dt(k.accepted?null:pe("input.pendingQueue.full")),k.accepted&&Uo(),k.accepted},[xr,ln,Uo,pe]),gr=i.useCallback(async h=>{const k=String(h?.rawInput||""),R=h?.provider||t?.__provider||S||"claude",O=Gt[R]?.status||Gr,re=h?.selectedProject||e,ye=h?.selectedSession||t,ot=h?.currentSessionId||s,bt=h?.clientRequestId||Ec();if(O===es||!k.trim()||!re||!Pt.current.tryAcquire(bt))return!1;let Wt=!0;try{const Qn=h?.thinkingMode||"none",Bn=h?.thoughtLevel||"",vt=h?.permissionMode||we,cn=h?.currentModel||Nn,Br=h?.acpModeId||"";let Qt=k;const Wo=Cc(R),ll=!Bn&&Wo.enabled?Df.find(ht=>ht.id===Qn):null;Wo.strategy==="prompt-prefix"&&ll?.prefix&&(Qt=`${ll.prefix}: ${k}`);const aa=h?.contextPayload||null;aa&&(Qt=gy(aa,Qt)),u("queued"),m(od({phaseText:pe("activity.stage.generatingReply"),detailText:pe("activity.detail.preparingReply"),canAbort:!0}));let Ko=[];const cl=Array.isArray(h?.attachedImages)?h.attachedImages:[];if(cl.length>0){if(!E1(R))return u("idle"),d(!1),m(null),c(ht=>[...ht,{type:"error",content:`${R} 当前不支持图片输入`,timestamp:new Date}]),!1;try{Ko=await T1(cl)}catch(ht){return console.error("Image preparation failed:",ht),u("idle"),d(!1),m(null),c(wn=>[...wn,{type:"error",content:`图片处理失败:${ht.message}`,timestamp:new Date}]),!1}}const ia=D1(h?.activeFileMentions||[]),Pm=[...Ko.map(ht=>({type:"image",data:ht.data,mimeType:ht.mimeType,name:ht.name})),...ia],Jt=ot||ye?.id,dl={type:"user",content:k,provider:R,images:Ko,contentBlocks:ia,timestamp:new Date,clientRequestId:bt};c(ht=>[...ht,dl]),L(!1),setTimeout(()=>$(),100),Q(Jt||ye?.id||null),Jt&&oe(Lf({kind:"user_message",provider:R,sessionId:Jt,timestamp:dl.timestamp,payload:{text:k,contentBlocks:Pm},extensions:{clientRequestId:bt,optimistic:!0}}));const Tm=Jt||`new-session-${Date.now()}`;!Jt&&!ye?.id&&(b.current={sessionId:null,startedAt:Date.now()}),Z&&Z(Tm);const Mm=(()=>{try{const ht=R==="codex"?"codex-settings":"claude-settings",wn=kt.getItem(ht);if(wn)return JSON.parse(wn)}catch(ht){console.error("Error loading tools settings:",ht)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})(),Ho=c1(kt),ul=re.fullPath||re.path,Go={cwd:ul,projectPath:ul,sessionId:Jt,resume:!!Jt,images:Ko,resourceLinks:ia,agentCommandOverrides:L1(),...Br?{mode:Br,modeId:Br}:{},...Bn?{thoughtLevel:Bn,sessionConfigOptions:{thought_level:Bn}}:{}},Vo=async ht=>{const wn=await et.createRun({provider:R,clientRequestId:bt,command:Qt,sessionId:Jt,options:{...ht,clientRequestId:bt}});if(!wn.ok)throw new Error(`Run creation failed with ${wn.status}`);const Ur=await wn.json();if(!Ur?.runId)throw new Error("Run creation returned no runId");E.current={runId:Ur.runId,lastEventSeq:0,provider:R,sessionId:Jt||null,clientRequestId:bt},_?.({runId:Ur.runId,lastEventSeq:0,provider:R,sessionId:Jt||null,clientRequestId:bt}),(async()=>{for(let la=0;la<240;la+=1){await _1(la===0?750:1e3);const pl=E?.current?.runId||null;if(pl&&pl!==Ur.runId)return;const ml=await et.run(Ur.runId).catch(()=>null);if(!ml?.ok)continue;const ca=(await ml.json().catch(()=>null))?.run||null,da=R1(ca?.status);if(!da)continue;await N?.(ca);const qr=ca?.sessionId||Jt||ye?.id||ot||null;q?.(qr,da),z?.(qr),u(da),d(!1),m(null),qr&&(K?.(qr),V?.(qr));return}})()};if(R==="codex"){const ht=!Bn&&Wo.enabled&&Wo.strategy==="native-effort"?I1(Qn):void 0,wn={...Go,permissionMode:vt==="plan"?"default":vt,...cn?{model:cn}:{},...ht?{modelReasoningEffort:ht}:{}};Ho?await Vo(wn):v({type:"codex-command",clientRequestId:bt,command:Qt,sessionId:Jt,options:wn})}else if(R==="gemini"){const ht={...Go,permissionMode:vt==="plan"?"default":vt,...cn?{model:cn}:{}};Ho?await Vo(ht):v({type:"gemini-command",clientRequestId:bt,command:Qt,sessionId:Jt,options:ht})}else if(R==="opencode"){const ht={...Go,permissionMode:vt==="plan"?"default":vt,...cn?{model:cn}:{}};Ho?await Vo(ht):v({type:"opencode-command",clientRequestId:bt,command:Qt,sessionId:Jt,options:ht})}else{const ht={...Go,projectPath:re.path,cwd:re.fullPath,toolsSettings:Mm,permissionMode:vt,...cn?{model:cn}:{}};Ho?await Vo(ht):v({type:"claude-command",clientRequestId:bt,command:Qt,options:ht})}return Wt=!1,aa&&h?.dynamicContextSent===!1&&ne(!0),!0}finally{Wt&&Pt.current.release(bt)}},[E,oe,z,Nn,s,q,_,N,Z,K,V,b,we,S,Gt,$,e,t,v,d,c,m,L,u,Q,pe]),vr=i.useCallback(async(h,k=null,R={})=>{h.preventDefault();const O=typeof k=="string"?k:he,re=t?.__provider||S||"claude";if((Gt[re]?.status||Gr)===es||!O.trim()||!e)return;const ot=nl(O),bt=R?.allowQueueGrace!==!1;if(Yw({isLoading:l,activeRun:E?.current||null,pendingQueueLength:Cn.current.length,queueGraceUntilMs:bt?Io.current:0})){rl(ot);return}a1(Pt.current,{isLoading:l,activeRun:E?.current||null}),Io.current=Date.now()+oi,await gr(ot)&&Uo()},[E,nl,rl,he,l,S,Gt,Uo,e,t?.__provider,gr]),mm=i.useCallback(h=>{xr(),ln(e1(Cn.current,h)),dt(null)},[xr,ln]),ol=i.useCallback(async()=>{const h=E?.current||null,k=h?.sessionId||s||t?.id,R=h?.provider||t?.__provider||S;if(h?.runId){const O=await et.cancelRun(h.runId,{sessionId:k}).catch(()=>null),re=O?.ok?await O.json().catch(()=>null):null;re?.run&&await N?.(re.run),E.current=null,Pt.current.release();return}k&&a&&(v({type:"abort-session",sessionId:k,provider:R}),Pt.current.release())},[E,a,s,N,S,t?.__provider,t?.id,v]),fm=i.useCallback(async h=>{const k=Cn.current.find(R=>String(R?.id||"")===String(h||""));if(k?.snapshot){Lr.current=!0,No.current=!1,Or.current=Date.now()+ls,xr(),Mt(k.id),dt(null);try{await o1({queue:Cn.current,itemId:h,replaceQueue:ln,cancelActiveRun:ol,submitPromptSnapshot:gr})}finally{Mt(null)}}},[ol,xr,ln,gr]);i.useEffect(()=>{zt.current=vr},[vr]),i.useEffect(()=>{if(!(typeof window>"u")){if(window.sessionStorage?.getItem("axhub-chat-debug")!=="1"||window.__AXHUB_CHAT_DEBUG_MODE__!==!0){delete window.__AXHUB_SUBMIT_COMPOSER_PROMPT__;return}return window.__AXHUB_SUBMIT_COMPOSER_PROMPT__=async(h,k={})=>{const R=String(h||"");if(!R.trim())throw new Error("Cannot submit an empty composer prompt");if(!zt.current)throw new Error("Composer submit helper is not ready");const O={preventDefault:()=>{}},re=window.__AXHUB_CHAT_DEBUG__||null;return await zt.current(O,R,{allowQueueGrace:!1}),{submitted:!0,label:k.label||null,text:R,beforeDebugState:re,afterDebugState:window.__AXHUB_CHAT_DEBUG__||null,url:typeof window<"u"?window.location.href:null}},()=>{delete window.__AXHUB_SUBMIT_COMPOSER_PROMPT__}}},[zt]);const hm=i.useCallback(h=>!h||S!=="claude"?{success:!1}:Gy(h.entry),[S]),xm=i.useCallback((h,k)=>{const O=(Array.isArray(h)?h:[h]).filter(Boolean);O.length!==0&&(O.forEach(re=>{const ye=E?.current?.runId||null;if(ye){et.resolveRunPermission(ye,{requestId:re,optionId:k?.optionId,outcome:k?.outcome,cancelled:!!k?.cancelled,allow:!!k?.allow,updatedInput:k?.updatedInput,message:k?.message,rememberEntry:k?.rememberEntry});return}v({type:"permission-response",requestId:re,optionId:k?.optionId,outcome:k?.outcome,cancelled:!!k?.cancelled,allow:!!k?.allow,updatedInput:k?.updatedInput,message:k?.message,rememberEntry:k?.rememberEntry})}),f(re=>{const ye=re.filter(ot=>!O.includes(ot.requestId));return ye.length===0&&m(null),ye}))},[E,v,m,f]),gm=i.useCallback((h,k={})=>{const O=(Array.isArray(h)?h:[h]).filter(Boolean);O.length!==0&&(O.forEach(re=>{const ye={requestId:re,action:k?.action||"cancel",content:k?.content&&typeof k.content=="object"?k.content:{}},ot=E?.current?.runId||null;if(ot){et.resolveRunElicitation(ot,ye);return}v({type:"elicitation-response",...ye})}),y?.(re=>re.filter(ye=>!O.includes(ye.requestId))))},[E,v,y]),qo=i.useCallback(h=>{},[fe,he,xe]),vm=i.useCallback(h=>{const k=h.target.value,R=h.target.selectionStart;if(be(k),rt(R),!k.trim()){h.target.style.height="auto",M(!1),Ne(!1),te(-1),st("");return}const O=k.slice(0,R);if((O.match(/```/g)||[]).length%2===1){Ne(!1),te(-1),st("");return}const ye=O.match(/(^|\s)\/(\S*)$/);if(ye){const ot=ye.index+ye[1].length,bt=ye[2];te(ot),Ne(!0),ie||Yi(),ae(-1),Tn.current&&clearTimeout(Tn.current),Tn.current=setTimeout(()=>{st(bt)},150)}else Ne(!1),te(-1),st(""),Tn.current&&clearTimeout(Tn.current)},[Yi,ie]),oa=i.useCallback(h=>{!Dt.current||!h||(Dt.current.scrollTop=h.scrollTop,Dt.current.scrollLeft=h.scrollLeft)},[]),ym=i.useCallback(h=>{rt(h.target.selectionStart)},[]),bm=i.useCallback(h=>{h.target.style.height="auto",h.target.style.height=`${h.target.scrollHeight}px`,rt(h.target.selectionStart),oa(h.target);const k=parseInt(window.getComputedStyle(h.target).lineHeight,10),R=h.target.scrollHeight>k*2;M(R)},[oa]),wm=i.useCallback(h=>{if(ie&&ge.length>0){if(h.key==="ArrowDown"){h.preventDefault(),ae(k=>k<ge.length-1?k+1:0);return}if(h.key==="ArrowUp"){h.preventDefault(),ae(k=>k>0?k-1:ge.length-1);return}if(h.key==="Tab"||h.key==="Enter"){h.preventDefault(),H>=0?ra(ge[H]):ge.length>0&&ra(ge[0]);return}if(h.key==="Escape"){h.preventDefault(),Ne(!1),te(-1),st(""),ae(-1),Tn.current&&clearTimeout(Tn.current);return}}if(Te&&Xe.length>0){if(h.key==="ArrowDown"){h.preventDefault(),me(k=>k<Xe.length-1?k+1:0);return}if(h.key==="ArrowUp"){h.preventDefault(),me(k=>k>0?k-1:Xe.length-1);return}if(h.key==="Tab"||h.key==="Enter"){h.preventDefault(),B>=0?qo(Xe[B]):Xe.length>0&&qo(Xe[0]);return}if(h.key==="Escape"){h.preventDefault(),Je(!1);return}}if(h.key==="Tab"&&!Te&&!ie){h.preventDefault();const k=Mn.modes,O=(k.indexOf(we)+1)%k.length,re=k[O];ut(re),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,re);return}if(h.key==="Enter"){if(h.nativeEvent.isComposing)return;(h.ctrlKey||h.metaKey)&&!h.shiftKey?(h.preventDefault(),vr(h)):!h.shiftKey&&!h.ctrlKey&&!h.metaKey&&(J||(h.preventDefault(),vr(h)))}},[ge,Xe,vr,we,Mn.modes,ra,qo,H,B,t?.id,J,ie,Te]),yr=t?.__provider||S||"claude",sa=Gt[yr],sl=sa?.status||Gr,al=sl===es,km=sa?.reason||Ks[yr]||null,Sm=sa?.installHint||null,jm=!!Pr[yr],Cm=al,il=yr==="opencode"?"OpenCode":pe(`messageTypes.${yr}`),Nm=pe("input.providerNotInstalledWithName",{provider:il});i.useEffect(()=>{e&&Wy(e.name,he)},[he,e]),i.useEffect(()=>{if(e){if(Ao.current){Ao.current=!1;return}const h=Gl(e.name);h!==he&&be(h)}},[he,e?.name]),i.useEffect(()=>{T&&T(je)},[je,T]),i.useEffect(()=>{if(pt.current){pt.current.style.height="auto",pt.current.style.height=`${pt.current.scrollHeight}px`;const h=parseInt(window.getComputedStyle(pt.current).lineHeight,10);M(pt.current.scrollHeight>h*2)}},[]),i.useEffect(()=>{pt.current&&!he.trim()&&(pt.current.style.height="auto",M(!1))},[he]),i.useEffect(()=>{l||Pt.current.release()},[l]),i.useEffect(()=>{qi.current=l;const h=Wi.current;Io.current=Xw({isLoading:l,wasLoading:h,currentGraceUntilMs:Io.current}),l&&Lr.current&&(No.current=!0),Wi.current=l;const k=E?.current||null;k&&Lr.current&&(Or.current=Math.max(Or.current,Date.now()+ls));const R=Math.max(Or.current,Eo.current);if(!Zw({wasLoading:h,isLoading:l,activeRun:k,isAutoSending:Gs.current,immediateSendingId:$t,pendingQueueLength:Cn.current.length,holdForImmediateSend:Lr.current,hasObservedImmediateLoading:No.current,holdUntilMs:R})){if(!l&&Cn.current.length>0&&(k||R>Date.now())){const re=k?1e3:Math.max(0,R-Date.now());re>0&&!Pn.current&&(Pn.current=setTimeout(()=>{Pn.current=null,qi.current||yn(ye=>ye+1)},re))}return}Pn.current&&(clearTimeout(Pn.current),Pn.current=null),Lr.current=!1,No.current=!1,Or.current=0,Eo.current=0,Gs.current=!0,r1({queue:Cn.current,replaceQueue:ln,submitPromptSnapshot:gr}).finally(()=>{Gs.current=!1})},[jt,$t,l,ln,gr]),i.useEffect(()=>()=>{Pn.current&&(clearTimeout(Pn.current),Pn.current=null)},[]);const Em=i.useCallback(h=>{He(k=>k.filter((R,O)=>O!==h))},[]),Im=i.useCallback(h=>{S==="claude"?ze(h):S==="codex"?Ue(h):S==="gemini"?Ct(h):S==="opencode"&&X(h),Oy(S,h)},[S]),Am=i.useCallback(()=>{const h=`${S}:${_t||"global"}`;if(Gi.current.has(h))return;Gi.current.add(h),mr(S,_t,{force:S!=="gemini"}),fr(S,_t,{force:!0})},[S,mr,fr,_t]),_m=i.useCallback(()=>{const h=s||t?.id,k=t?.__provider||S;if(h&&a){const R=E?.current?.runId||null;if(R){et.cancelRun(R,{sessionId:h});return}v({type:"abort-session",sessionId:h,provider:k})}},[E,a,s,S,t?.__provider,t?.id,v]),Rm=i.useCallback(()=>{be(""),He([]),Pe(new Map),ct(new Map),M(!1),I("none"),Ne(!1),Je(!1),st(""),te(-1),ae(-1),me(-1),ln([]),dt(null),Mt(null),e?.name&&ks(e.name),typeof ue=="function"&&ue()},[ln,ue,e?.name]);return i.useEffect(()=>{const h=Ki.current,k={projectName:e?.name||null,sessionId:t?.id||null};Ki.current=k;const R=h.projectName!==k.projectName,O=h.sessionId&&h.sessionId!==k.sessionId;!R&&!O||(ln([]),dt(null),Mt(null))},[ln,e?.name,t?.id]),{input:he,setInput:be,provider:S,setProvider:U,handleProviderSelection:Vp,permissionMode:we,setPermissionMode:ut,acpModes:Fr.availableModes,acpModeId:C,handleAcpModeChange:rm,selectedPermissionShortLabel:Hp,permissionDropdownTitle:Gp,providerModeConfig:Mn,getPermissionModeLabel:Zs,providerThinkingConfig:Gn,thinkingMode:x,setThinkingMode:I,thoughtLevel:pr,setThoughtLevel:Js,thoughtLevelOptions:ur,currentModel:Nn,modelOptions:Do,selectedModelLabel:qp,isModelSelectionLocked:Wp,isOpencodeModelLoading:Kp,setProviderModel:Im,refreshModelAndThinkingOptions:Am,textareaRef:pt,inputContainerRef:Rn,inputHighlightRef:Dt,isFileMentionsEnabled:xe,hasSlashCommandsAvailable:Bp,modelSelectorRef:$n,permissionSelectorRef:zn,showFileDropdown:Te,filteredFiles:Xe,selectedFileIndex:B,selectFile:qo,showCommandMenu:ie,filteredCommands:ge,selectedCommandIndex:H,handleCommandSelect:om,commandQuery:Et,frequentCommands:nm,slashPosition:Ie,setShowCommandMenu:Ne,setSelectedCommandIndex:ae,setSlashPosition:te,setCommandQuery:st,getRootProps:cm,getInputProps:dm,isDragActive:um,openImagePicker:pm,attachedImages:Ve,uploadingImages:nt,imageErrors:lt,removeAttachedImage:Em,visibleDynamicContext:Vn,visibleSelectedElements:Qp,hiddenSelectedElements:Jp,visibleContextComments:Yp,handleDismissSystemContext:Xp,handleDismissCurrentFile:Zp,handleDismissSelectedElement:em,handleDismissContextComment:tm,renderInputWithMentions:im,handleInputChange:vm,handleTextareaClick:ym,handleKeyDown:wm,handlePaste:lm,syncInputOverlayScroll:oa,handleTextareaInput:bm,activeInputProvider:yr,activeInputProviderLabel:il,activeProviderInstallState:sl,isActiveProviderNotInstalled:al,unavailablePlaceholder:Nm,isInputDisabled:Cm,activeProviderInstallReason:km,activeProviderInstallHint:Sm,isCheckingProviderInstallation:jm,checkProviderInstallation:ta,providerCheckLoadingByName:Pr,isInputFocused:je,setIsInputFocused:Be,isTextareaExpanded:j,tokenBudget:ee,pendingMessageQueue:Ee,pendingQueueLimit:As,queueNotice:Ye,immediateSendingId:$t,handleRemovePendingMessage:mm,handleSendPendingMessageNow:fm,handleSubmit:vr,canAbortSession:a,handleAbortSession:_m,handleSubmitRef:zt,handleGrantToolPermission:hm,handlePermissionDecision:xm,handleElicitationDecision:gm,dynamicContext:Hs,pendingDynamicContext:an,setPendingDynamicContext:A,dynamicContextSent:G,setDynamicContextSent:ne,resetComposerForNewChat:Rm}}const ii=new Set(["succeeded","failed","canceled"]);function Lt(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.floor(t):0}function li(e){return String(e||"").trim().toLowerCase()}function Sa(e){if(!e||typeof e!="object")return!1;const t=li(e.event?.status||e.run?.status||e.status);return ii.has(t)?!0:Bi(e.type,e)}function ja(e){return si(e?.type,e)}function K1(e,t){const n=`/api/runs/${encodeURIComponent(e)}/events?after=${encodeURIComponent(String(Lt(t)))}`;return globalThis.fetch(n)}function H1({processMessage:e,onSessionResolved:t,subscribe:n=Cp,fetchReplay:o=K1,maxReconnectAttempts:s=3}={}){let a=null,l=[],c=!1,d=null,u=0,m=!1,p=null;const f=()=>({activeRunId:a?.runId||null,lastEventSeq:Lt(a?.lastEventSeq),provider:a?.provider||null,sessionId:a?.sessionId||null,clientRequestId:a?.clientRequestId||null}),y=()=>{const b=d;d=null,b?.()},v=b=>{if(!a&&b?.runId&&(a={runId:b.runId,lastEventSeq:0}),!a)return;const $=Lt(b?.runEventSeq||b?.seq);a={...a,provider:b?.provider||a.provider||null,sessionId:b?.sessionId||a.sessionId||null,clientRequestId:b?.clientRequestId||a.clientRequestId||null,lastEventSeq:Math.max(Lt(a.lastEventSeq),$)},a.sessionId&&a.sessionId!==p&&(p=a.sessionId,t?.(f()))},_=(b,{advanceLastEventSeq:$=!1}={})=>{!b||!a||a.runId!==b.runId||(a={...a,provider:b.provider||a.provider||null,sessionId:b.sessionId||a.sessionId||null,clientRequestId:b.clientRequestId||a.clientRequestId||null,lastEventSeq:$?Math.max(Lt(a.lastEventSeq),Lt(b.lastEventSeq)):Lt(a.lastEventSeq)},a.sessionId&&a.sessionId!==p&&(p=a.sessionId,t?.(f())))},N=()=>{a=a?{...a,runId:null}:null,l=[],y()},E=async(b,$)=>{const L=await o(b,$);return L?.ok?L.json():null},z=b=>{if(!b||typeof b!="object")return!1;const $=Lt(b?.runEventSeq||b?.seq);return $&&a?.runId===b?.runId&&$<=Lt(a.lastEventSeq)?!1:(v(b),e?.(b),Sa(b)&&N(),!0)},q=b=>{const $=f(),L=Lt(b?.runEventSeq||b?.seq),ee=$.lastEventSeq;return!!($.activeRunId&&b?.runId===$.activeRunId&&($.provider||$.sessionId||$.clientRequestId)&&L&&L>ee+1)},Z=async b=>{if(!q(b))return;const $=f(),L=Lt(b?.runEventSeq||b?.seq),ee=$.lastEventSeq;let le=null;try{le=await E($.activeRunId,ee)}catch{return}le&&(_(le.run,{advanceLastEventSeq:!1}),(Array.isArray(le?.events)?le.events:[]).forEach(ve=>{const ue=ja(ve),W=Lt(ue?.runEventSeq||ue?.seq);!ue||!W||W>=L||z(ue)}))},K=async()=>{if(!c){c=!0;try{for(;l.length>0;){const b=l.shift(),$=Lt(b?.runEventSeq||b?.seq);if(!($&&a?.runId===b?.runId&&$<=Lt(a.lastEventSeq))&&!(Sa(b)&&q(b)&&(await Z(b),$&&a?.runId===b?.runId&&$<=Lt(a.lastEventSeq)))&&(v(b),e?.(b),Sa(b))){N();break}}}finally{c=!1}}},V=b=>{!b||typeof b!="object"||(l.push(b),K())},T=async()=>{const b=f();if(!b.activeRunId)return;const $=await E(b.activeRunId,b.lastEventSeq);if(!$)return;_($.run,{advanceLastEventSeq:!1}),(Array.isArray($?.events)?$.events:[]).forEach(ee=>{const le=ja(ee);le&&V(le)}),_($.run,{advanceLastEventSeq:!0});const L=li($?.run?.status);$?.run&&ii.has(L)&&V({type:"run-state",runId:$.run.runId,runEventSeq:$.run.lastEventSeq,provider:$.run.provider,sessionId:$.run.sessionId,clientRequestId:$.run.clientRequestId,event:{status:L}})},Y=()=>{const b=f();m||!b.activeRunId||(y(),d=n({runId:b.activeRunId,after:b.lastEventSeq,onMessage:V,onDisconnect:async()=>{if(!(m||!f().activeRunId)){if(u>=s){await T();return}u+=1,await T(),f().activeRunId&&Y()}},onError:async()=>{if(!(m||!f().activeRunId)){if(u>=s){await T();return}u+=1,await T(),f().activeRunId&&Y()}},onEnd:()=>{a=null,y()}}))};return{startRun:({runId:b,provider:$=null,sessionId:L=null,clientRequestId:ee=null,lastEventSeq:le=0}={})=>{b&&(m=!1,u=0,a={runId:b,provider:$,sessionId:L,clientRequestId:ee,lastEventSeq:Lt(le)},p=L||null,l=[],Y())},replayRun:async({runId:b,provider:$=null,sessionId:L=null,clientRequestId:ee=null,lastEventSeq:le=0,replayAfter:ve=0}={})=>{if(!b)return f();const ue=Lt(ve);m=!1,u=0,l=[],y(),a={runId:b,provider:$,sessionId:L,clientRequestId:ee,lastEventSeq:ue},p=null,_({runId:b,provider:$,sessionId:L,clientRequestId:ee,lastEventSeq:le},{advanceLastEventSeq:!1});const W=await E(b,ue);if(!W)return _({runId:b,provider:$,sessionId:L,clientRequestId:ee,lastEventSeq:le},{advanceLastEventSeq:!0}),f();_(W.run,{advanceLastEventSeq:!1}),(Array.isArray(W?.events)?W.events:[]).forEach(Ce=>{const Ae=ja(Ce);Ae&&z(Ae)});const Se=li(W?.run?.status);return W?.run&&a?.runId===b&&ii.has(Se)&&!z({type:"run-state",runId:W.run.runId,runEventSeq:W.run.lastEventSeq,provider:W.run.provider,sessionId:W.run.sessionId,clientRequestId:W.run.clientRequestId,event:{status:Se}})&&a?.runId===b&&N(),a?.runId===b&&_(W.run,{advanceLastEventSeq:!0}),f()},enqueue:V,stop:()=>{m=!0,a=null,p=null,l=[],y()},getSnapshot:f}}const G1=new Set(["succeeded","failed","canceled"]);function V1(e){const t=String(e?.event?.status||e?.run?.status||e?.status||"").trim().toLowerCase();return G1.has(t)||Bi(e?.type,e)}function Q1({activeRunRef:e,processRealtimeMessage:t,onSessionResolved:n}={}){const o=i.useRef(null),s=i.useMemo(()=>H1({processMessage:a=>{const l=Number(a?.runEventSeq||a?.seq||0),c=e?.current||{};e.current={...c,runId:a?.runId||c.runId||null,lastEventSeq:Number.isFinite(l)&&l>0?Math.max(Number(c.lastEventSeq||0),l):Number(c.lastEventSeq||0),provider:a?.provider||c.provider||null,sessionId:a?.sessionId||c.sessionId||null,clientRequestId:a?.clientRequestId||c.clientRequestId||null},t?.(a),V1(a)&&(o.current=e.current,e.current=null)},onSessionResolved:n,subscribe:a=>Cp({...a,fetchImpl:Zt,onEnd:l=>{e.current=null,a.onEnd?.(l)}}),fetchReplay:(a,l)=>et.runEvents(a,l)}),[e,n,t]);return i.useEffect(()=>()=>s.stop(),[s]),i.useMemo(()=>({startRun(a){a?.runId&&(e.current={runId:a.runId,lastEventSeq:Number(a.lastEventSeq||0),provider:a.provider||null,sessionId:a.sessionId||null,clientRequestId:a.clientRequestId||null},s.startRun(a))},async replayRun(a){if(!a?.runId)return null;const l=Number(a.lastEventSeq||0),c=e.current?.runId===a.runId?e.current:o.current?.runId===a.runId?o.current:null,d=Number(c?.lastEventSeq||0);if(c&&l>0&&d>=l)return e.current=null,{activeRunId:null,lastEventSeq:d,provider:c.provider||a.provider||null,sessionId:c.sessionId||a.sessionId||null,clientRequestId:c.clientRequestId||a.clientRequestId||null};e.current={runId:a.runId,lastEventSeq:d,provider:a.provider||null,sessionId:a.sessionId||null,clientRequestId:a.clientRequestId||null};const u=await s.replayRun({...a,replayAfter:d});return e.current=u?.activeRunId?{runId:u.activeRunId,lastEventSeq:Number(u.lastEventSeq||0),provider:u.provider||null,sessionId:u.sessionId||null,clientRequestId:u.clientRequestId||null}:null,u?.activeRunId||(o.current={runId:a.runId,lastEventSeq:Number(u?.lastEventSeq||l||d||0),provider:u?.provider||a.provider||null,sessionId:u?.sessionId||a.sessionId||null,clientRequestId:u?.clientRequestId||a.clientRequestId||null}),u},enqueue(a){s.enqueue(a)},stop(){s.stop(),e.current=null},getSnapshot(){return s.getSnapshot()}}),[e,s])}function J1({selectedProject:e,selectedSession:t,initialProvider:n=null,ws:o,sendMessage:s,latestMessage:a,onFileOpen:l,onInputFocusChange:c,onSessionActive:d,onSessionInactive:u,onSessionProcessing:m,onSessionNotProcessing:p,processingSessions:f,onReplaceTemporarySession:y,onNavigateToSession:v,onShowSettings:_,autoExpandTools:N,showRawParameters:E,showThinking:z,autoScrollToBottom:q,sendByCtrlEnter:Z,externalMessageUpdate:K,urlContext:V,urlPrompt:T,integrationClientId:Y,latestIntegrationMessage:D,sendIntegrationMessage:oe,newSessionResetNonce:Q=0}){const{t:b}=Ot("chat"),$=i.useMemo(()=>typeof window<"u"&&e?.name?Ky(e.name,t?.id||null):[],[e?.name,t?.id]),[L,ee]=i.useReducer(_0,$,A0),[le,ve]=i.useState(t?.id||null),[ue,W]=i.useState(!1),[Se,Ce]=i.useState(null),[Ae,se]=i.useState(null),[J,pe]=i.useState([]),[xe,he]=i.useState(null),be=i.useRef(e),je=i.useRef(L.messages),Be=i.useRef(L.isLoading),Ve=i.useRef({sessionId:null,startedAt:0}),He=i.useRef({sessionId:null,phase:null,updatedAt:0}),nt=i.useRef(null),Pe=i.useRef(Q),lt=i.useRef(""),ct=i.useRef(null),Te=i.useRef(null),Je=i.useRef(null),_e=L.messages,Qe=L.phase,Ke=L.isLoading,mt=L.canAbortSession,Xe=L.pendingPermissionRequests,P=L.pendingElicitationRequests;i.useEffect(()=>{be.current=e},[e]),i.useEffect(()=>{je.current=_e},[_e]),i.useEffect(()=>{Be.current=Ke},[Ke]);const B=i.useCallback(te=>{ee({type:"replace_messages",value:te})},[]),me=i.useCallback(te=>{ee({type:"replace_permissions",value:te})},[]),Fe=i.useCallback(te=>{ee({type:"replace_elicitations",value:te})},[]),rt=i.useCallback(te=>{ee({type:"set_loading",value:te})},[]),fe=i.useCallback(te=>{ee({type:"set_can_abort",value:te})},[]),g=i.useCallback((te,we)=>{ee({type:"set_phase",phase:te,overrides:we})},[]),ie=i.useCallback((te,we)=>{!te||!oo(we)||(He.current={sessionId:te,phase:we,updatedAt:Date.now()})},[]),Ne=i.useCallback((te,we,ut={})=>{ee({type:"apply_conversation_event",event:te,provider:we,suppressPhase:!!ut.suppressPhase})},[]),de=i.useCallback(te=>{He.current={sessionId:null,phase:null,updatedAt:0},Ve.current={sessionId:te||null,startedAt:Date.now()}},[]),Oe=i.useCallback(te=>{!te||!Ve.current.startedAt||(Ve.current={...Ve.current,sessionId:te})},[]),Me=i.useCallback((te=null)=>{const we=Ve.current;we.startedAt&&(te&&we.sessionId&&we.sessionId!==te||(Ve.current={sessionId:null,startedAt:0}))},[]),$e=i.useCallback(()=>{ct.current&&(clearTimeout(ct.current),ct.current=null),lt.current=""},[]),De=i.useCallback((te,we=null)=>{if(we&&we!=="session-status")return!1;const ut=Ve.current;return!!(ut.startedAt&&te&&ut.sessionId===te&&Date.now()-ut.startedAt<15e3&&(Qe===F.CONNECTING||Qe===F.QUEUED||Qe===F.STREAMING||Qe===F.AWAITING_APPROVAL||Qe===F.AWAITING_INPUT||Qe===F.COMPLETED||Qe===F.ABORTED||Qe===F.ERRORED))},[Qe]),it=i.useCallback((te=null)=>{const we=be.current?.name||e?.name||"";we&&Qu(we,te,je.current)},[e?.name]),ge=Yy({selectedProject:e,selectedProjectRef:be,selectedSession:t,currentSessionId:le,setCurrentSessionId:ve,provider:t?.__provider||null,runtimePhase:Qe,isLoading:Ke,isLoadingRef:Be,processingSessions:f,autoScrollToBottom:q,externalMessageUpdate:K,ws:o,sendMessage:s,chatMessages:_e,setChatMessages:B,setIsLoading:rt,setCanAbortSession:fe,setRuntimePhase:g,setClaudeStatus:Ce,setPendingPermissionRequests:me,setPendingElicitationRequests:Fe,resetStreamingState:$e,clearLocalRunGuard:Me,localRunGuardRef:Ve,terminalRunStateRef:He,pendingViewSessionRef:nt,isSystemSessionChange:ue,setIsSystemSessionChange:W,onSessionInactive:u,onSessionNotProcessing:p,onSessionProcessing:m}),Re=i.useMemo(()=>Of(ge.sessionMessages),[ge.sessionMessages]);i.useEffect(()=>{se(Re.modeState||null),pe(Array.isArray(Re.availableCommands)?Re.availableCommands:[]),he(Re.capabilitySnapshot||null),ge.setTokenBudget(Re.tokenUsage||null)},[ge.setTokenBudget,Re.availableCommands,Re.capabilitySnapshot,Re.modeState,Re.tokenUsage]);const Et=i.useMemo(()=>{if(!t&&!le)return t;const te=t?{...t}:{};return!te.id&&le&&(te.id=le),te.acpModes=Ae,te.acpAvailableCommands=J,te.acpConfigOptions=Re.configOptions,te.acpCapabilitySnapshot=xe,te},[J,xe,Ae,le,Re.configOptions,t]),st=i.useCallback(te=>{Je.current?.(te)},[]),j=i.useCallback(te=>{const we=te?.sessionId||null;we&&(ve(we),nt.current={sessionId:we,startedAt:Date.now()},v?.(we,te.provider||t?.__provider||null,e?.fullPath||e?.path||null))},[v,nt,e?.fullPath,e?.path,t?.__provider,ve]),M=Q1({activeRunRef:Te,onSessionResolved:j,processRealtimeMessage:st}),H=W1({selectedProject:e,selectedSession:Et,selectedProjectRef:be,initialProvider:n,currentSessionId:le,canAbortSession:mt,isLoading:Ke,setChatMessages:B,setCanAbortSession:fe,setRuntimePhase:g,setClaudeStatus:Ce,pendingPermissionRequests:Xe,setPendingPermissionRequests:me,setPendingElicitationRequests:Fe,sendMessage:s,activeRunRef:Te,onRunCreated:M.startRun,onRunTerminalDiscovered:M.replayRun,clearLocalRunGuard:Me,markTerminalRunState:ie,onSessionActive:d,onSessionInactive:u,onSessionNotProcessing:p,onInputFocusChange:c,onShowSettings:_,onFileOpen:l,appendSessionConversationEvent:ge.appendSessionConversationEvent,startLocalRunGuard:de,pendingViewSessionRef:nt,scrollToBottom:ge.scrollToBottom,setIsUserScrolledUp:ge.setIsUserScrolledUp,tokenBudget:ge.tokenBudget,chatMessages:_e,setSessionMessages:ge.setSessionMessages,resetRuntimeForNewChat:ge.resetSessionHistoryForNewChat,urlContext:V,urlPrompt:T,integrationClientId:Y,latestIntegrationMessage:D,sendIntegrationMessage:oe,sendByCtrlEnter:Z});cb({latestMessage:a,provider:H.provider,claudeStatus:Se,selectedProject:e,selectedSession:t,currentSessionId:le,setCurrentSessionId:ve,isLoading:Ke,runtimePhase:Qe,sendMessage:s,persistCurrentChatCache:it,setIsSystemSessionChange:W,setPendingPermissionRequests:me,setIsLoading:rt,setCanAbortSession:fe,setClaudeStatus:Ce,setChatMessages:B,setTokenBudget:ge.setTokenBudget,setAcpSessionModeState:se,setAcpAvailableCommands:pe,setAcpCapabilitySnapshot:he,applyRealtimeConversationEvent:Ne,streamBufferRef:lt,streamTimerRef:ct,clearLocalRunGuard:Me,markTerminalRunState:ie,terminalRunStateRef:He,syncLocalRunGuardSession:Oe,shouldIgnoreStaleIdleSignal:De,pendingViewSessionRef:nt,appendSessionConversationEvent:ge.appendSessionConversationEvent,recoverAndSettleSessionRuntime:ge.recoverAndSettleSessionRuntime,recoverTerminalSessionPhase:ge.recoverTerminalSessionPhase,inferRuntimePhaseFromSessionEvents:ge.inferRuntimePhaseFromSessionEvents,inferTerminalPhaseFromSessionEvents:ge.inferTerminalPhaseFromSessionEvents,scheduleSessionStatusRecovery:ge.scheduleSessionStatusRecovery,sessionMessages:ge.sessionMessages,setSessionMessages:ge.setSessionMessages,loadSessionMessages:ge.loadSessionMessages,onSessionInactive:u,onSessionNotProcessing:p,onSessionProcessing:m,onReplaceTemporarySession:y,onNavigateToSession:v,onProcessRealtimeMessage:te=>{Je.current=te},t:b,setRuntimePhase:g}),i.useEffect(()=>{Pe.current!==Q&&(Pe.current=Q,!t&&($e(),Me(),H.resetComposerForNewChat()))},[Me,H.resetComposerForNewChat,Q,$e,t]);const ae=n0({status:Se,messages:_e,pendingPermissionRequests:Xe,t:b}),Ie=Ke&&!!ae;return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
250
|
+
details[open] .details-chevron {
|
|
251
|
+
transform: rotate(180deg);
|
|
252
|
+
}
|
|
253
|
+
`}),r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx(Z0,{selectedProject:e,selectedSession:t,currentSessionId:le,provider:H.provider,chatMessages:_e,threadMessages:ge.threadMessages,isLoading:Ke,statusPresentation:ae,shouldShowClaudeStatus:Ie,isLoadingSessionMessages:ge.isLoadingSessionMessages,isLoadingMoreMessages:ge.isLoadingMoreMessages,hasMoreMessages:ge.hasMoreMessages,totalMessages:ge.totalMessages,sessionMessages:ge.sessionMessages,hasLoadedSessionMessages:ge.hasLoadedSessionMessages,hasHydratedSessionMessages:ge.hasHydratedSessionMessages,visibleMessageCount:ge.visibleMessageCount,pendingPermissionRequests:Xe,pendingElicitationRequests:P,scrollContainerRef:ge.scrollContainerRef,messagesEndRef:ge.messagesEndRef,onScroll:ge.handleScroll,onLoadEarlierSessionMessages:()=>ge.loadOlderMessages(),onLoadEarlierMessages:ge.loadEarlierMessages,onProviderSelection:H.handleProviderSelection,onFileOpen:l,onShowSettings:_,onGrantToolPermission:H.handleGrantToolPermission,onPermissionDecision:H.handlePermissionDecision,onElicitationDecision:H.handleElicitationDecision,autoExpandTools:N,showThinking:z,showRawParameters:E}),r.jsx(jy,{composer:H,isLoading:Ke,chatMessages:_e,sendByCtrlEnter:Z})]})]})}const Y1=Rt.memo(J1);function X1({file:e,onClose:t}){const n=`${Wn(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 m=new AbortController;return(async()=>{try{d(!0),l(null),s(null);const f=await Zt(n,{signal:m.signal});if(!f.ok)throw new Error(`Request failed with status ${f.status}`);const y=await f.blob();u=URL.createObjectURL(y),s(u)}catch(f){if(f.name==="AbortError")return;console.error("Error loading image:",f),l("Unable to load image")}finally{d(!1)}})(),()=>{m.abort(),u&&URL.revokeObjectURL(u)}},[n]),r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:r.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:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:e.name}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0",children:r.jsx(on,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[c&&r.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:r.jsx("p",{children:"Loading image…"})}),!c&&o&&r.jsx("img",{src:o,alt:e.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!c&&!o&&r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("p",{children:a||"Unable to load image"}),r.jsx("p",{className:"text-sm mt-2 break-all",children:e.path})]})]}),r.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:e.path})})]})})}const Z1=new Set(["png","jpg","jpeg","gif","webp","bmp","svg","ico","avif"]);function ek(e){const t=String(e||""),n=t.lastIndexOf(".");return n<0?"":t.slice(n+1).toLowerCase()}function Ca(e){return typeof e!="string"?"":e}function tk({file:e,onClose:t}){const[n,o]=i.useState(()=>Ca(e?.diffInfo?.new_string)),[s,a]=i.useState(()=>!e?.diffInfo),[l,c]=i.useState(null),d=i.useMemo(()=>Z1.has(ek(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(Ca(e?.diffInfo?.new_string));return}let m=!1;return(async()=>{try{a(!0),c(null);const f=await et.readFile(e.projectName,e.path);if(!f.ok)throw new Error(`Request failed with status ${f.status}`);const y=await f.json();m||o(Ca(y.content))}catch(f){m||(console.error("Error loading file preview:",f),c("Unable to load file preview"),o(""))}finally{m||a(!1)}})(),()=>{m=!0}},[e,u,d]),i.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]),e?d?r.jsx(X1,{file:e,onClose:t}):r.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",onClick:t,children:r.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:m=>m.stopPropagation(),children:[r.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-border/60 px-5 py-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-foreground",children:[r.jsx(Xc,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:e.name})]}),r.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted-foreground",children:e.path}),u?r.jsx("div",{className:"mt-2 text-xs text-amber-600 dark:text-amber-300",children:"Showing the updated content from the chat action."}):null]}),r.jsx(Ge,{variant:"ghost",size:"icon",onClick:t,"aria-label":"Close file preview",children:r.jsx(on,{className:"h-5 w-5"})})]}),r.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/20",children:s?r.jsx("div",{className:"flex h-full min-h-[320px] items-center justify-center text-sm text-muted-foreground",children:"Loading file preview..."}):l?r.jsxs("div",{className:"flex h-full min-h-[320px] flex-col items-center justify-center gap-2 px-6 text-center",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:l}),r.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:e.path})]}):r.jsx("pre",{className:"min-h-full overflow-auto p-5 font-mono text-xs leading-6 text-foreground whitespace-pre-wrap break-words",children:n})})]})}):null}var nk=Hf(),rk=Gf(),ok=Vf(),Na={exports:{}},Ic;function sk(){return Ic||(Ic=1,function(e,t){(function(n,o){e.exports=o()})(self,()=>(()=>{var n={6:(l,c)=>{function d(m){try{const p=new URL(m),f=p.password&&p.username?`${p.protocol}//${p.username}:${p.password}@${p.host}`:p.username?`${p.protocol}//${p.username}@${p.host}`:`${p.protocol}//${p.host}`;return m.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(m,p,f,y={}){this._terminal=m,this._regex=p,this._handler=f,this._options=y}provideLinks(m,p){const f=u.computeLink(m,this._regex,this._terminal,this._handler);p(this._addCallbacks(f))}_addCallbacks(m){return m.map(p=>(p.leave=this._options.leave,p.hover=(f,y)=>{if(this._options.hover){const{range:v}=p;this._options.hover(f,y,v)}},p))}};class u{static computeLink(p,f,y,v){const _=new RegExp(f.source,(f.flags||"")+"g"),[N,E]=u._getWindowedLineStrings(p-1,y),z=N.join("");let q;const Z=[];for(;q=_.exec(z);){const K=q[0];if(!d(K))continue;const[V,T]=u._mapStrIdx(y,E,0,q.index),[Y,D]=u._mapStrIdx(y,V,T,K.length);if(V===-1||T===-1||Y===-1||D===-1)continue;const oe={start:{x:T+1,y:V+1},end:{x:D,y:Y+1}};Z.push({range:oe,text:K,activate:v})}return Z}static _getWindowedLineStrings(p,f){let y,v=p,_=p,N=0,E="";const z=[];if(y=f.buffer.active.getLine(p)){const q=y.translateToString(!0);if(y.isWrapped&&q[0]!==" "){for(N=0;(y=f.buffer.active.getLine(--v))&&N<2048&&(E=y.translateToString(!0),N+=E.length,z.push(E),y.isWrapped&&E.indexOf(" ")===-1););z.reverse()}for(z.push(q),N=0;(y=f.buffer.active.getLine(++_))&&y.isWrapped&&N<2048&&(E=y.translateToString(!0),N+=E.length,z.push(E),E.indexOf(" ")===-1););}return[z,v]}static _mapStrIdx(p,f,y,v){const _=p.buffer.active,N=_.getNullCell();let E=y;for(;v;){const z=_.getLine(f);if(!z)return[-1,-1];for(let q=E;q<z.length;++q){z.getCell(q,N);const Z=N.getChars();if(N.getWidth()&&(v-=Z.length||1,q===z.length-1&&Z==="")){const K=_.getLine(f+1);K&&K.isWrapped&&(K.getCell(0,N),N.getWidth()===2&&(v+=1))}if(v<0)return[f,q]}f++,E=0}return[f,E]}}c.LinkComputer=u}},o={};function s(l){var c=o[l];if(c!==void 0)return c.exports;var d=o[l]={exports:{}};return n[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(m,p){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=p}else console.warn("Opening link blocked as opener could not be cleared")}l.WebLinksAddon=class{constructor(m=u,p={}){this._handler=m,this._options=p}activate(m){this._terminal=m;const p=this._options,f=p.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,f,this._handler,p))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(Na)),Na.exports}var ak=sk();const ik=`
|
|
254
|
+
.xterm .xterm-screen {
|
|
255
|
+
outline: none !important;
|
|
256
|
+
}
|
|
257
|
+
.xterm:focus .xterm-screen {
|
|
258
|
+
outline: none !important;
|
|
259
|
+
}
|
|
260
|
+
.xterm-screen:focus {
|
|
261
|
+
outline: none !important;
|
|
262
|
+
}
|
|
263
|
+
`;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=ik,document.head.appendChild(e)}function lk({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:o=!1,onProcessComplete:s,minimal:a=!1,autoConnect:l=!1}){const{t:c}=Ot("chat"),d=i.useRef(null),u=i.useRef(null),m=i.useRef(null),p=i.useRef(null),[f,y]=i.useState(!1),[v,_]=i.useState(!1),[N,E]=i.useState(!1),[z,q]=i.useState(null),[Z,K]=i.useState(!1),V=i.useRef(e),T=i.useRef(t),Y=i.useRef(n),D=i.useRef(o),oe=i.useRef(s);i.useEffect(()=>{V.current=e,T.current=t,Y.current=n,D.current=o,oe.current=s});const Q=i.useCallback(async()=>{if(!(Z||f))try{let ue;if(!_v){const W=localStorage.getItem("auth-token");if(!W){console.error("No authentication token found for Shell WebSocket connection");return}ue=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(W)}`}p.current=new WebSocket(ue),p.current.onopen=()=>{y(!0),K(!1),setTimeout(()=>{m.current&&u.current&&(m.current.fit(),p.current.send(JSON.stringify({type:"init",projectPath:V.current.fullPath||V.current.path,sessionId:D.current?null:T.current?.id,hasSession:D.current?!1:!!T.current,provider:D.current?"plain-shell":T.current?.__provider||T.current?.provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:Y.current,isPlainShell:D.current})))},100)},p.current.onmessage=W=>{try{const Se=JSON.parse(W.data);if(Se.type==="output"){let Ce=Se.data;if(D.current&&oe.current){const Ae=Ce.replace(/\x1b\[[0-9;]*m/g,"");if(Ae.includes("Process exited with code 0"))oe.current(0);else if(Ae.match(/Process exited with code (\d+)/)){const se=parseInt(Ae.match(/Process exited with code (\d+)/)[1]);se!==0&&oe.current(se)}}u.current&&u.current.write(Ce)}else Se.type==="url_open"&&window.open(Se.url,"_blank")}catch(Se){console.error("[Shell] Error handling WebSocket message:",Se,W.data)}},p.current.onclose=W=>{y(!1),K(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},p.current.onerror=W=>{y(!1),K(!1)}}catch{y(!1),K(!1)}},[Z,f]),b=i.useCallback(()=>{!v||f||Z||(K(!0),Q())},[v,f,Z,Q]),$=i.useCallback(()=>{p.current&&(p.current.close(),p.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),y(!1),K(!1)},[]),L=i.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),ee=i.useMemo(()=>L?L.slice(0,30):null,[L]),le=i.useMemo(()=>L?L.slice(0,50):null,[L]),ve=()=>{E(!0),p.current&&(p.current.close(),p.current=null),u.current&&(u.current.dispose(),u.current=null,m.current=null),y(!1),_(!1),setTimeout(()=>{E(!1)},200)};return i.useEffect(()=>{const ue=t?.id||null;z!==null&&z!==ue&&v&&$(),q(ue)},[t?.id,v,$]),i.useEffect(()=>{if(!d.current||!e||N||u.current)return;u.current=new nk.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),m.current=new rk.FitAddon;const ue=new ok.WebglAddon,W=new ak.WebLinksAddon;u.current.loadAddon(m.current),u.current.loadAddon(W);try{u.current.loadAddon(ue)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler(Ce=>(Ce.ctrlKey||Ce.metaKey)&&Ce.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):(Ce.ctrlKey||Ce.metaKey)&&Ce.key==="v"?(navigator.clipboard.readText().then(Ae=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:Ae}))}).catch(()=>{}),!1):!0),setTimeout(()=>{m.current&&(m.current.fit(),u.current&&p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),_(!0),u.current.onData(Ce=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:Ce}))});const Se=new ResizeObserver(()=>{m.current&&u.current&&setTimeout(()=>{m.current.fit(),p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&Se.observe(d.current),()=>{Se.disconnect(),p.current&&(p.current.readyState===WebSocket.OPEN||p.current.readyState===WebSocket.CONNECTING)&&p.current.close(),p.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,N]),i.useEffect(()=>{!l||!v||Z||f||b()},[l,v,Z,f,b]),e?a?r.jsx("div",{className:"h-full w-full bg-gray-900",children:r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):r.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${f?"bg-green-500":"bg-red-500"}`}),t&&r.jsxs("span",{className:"text-xs text-primary/80",children:["(",ee,"...)"]}),!t&&r.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!v&&r.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),N&&r.jsx("span",{className:"text-xs text-primary",children:c("shell.status.restarting")})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[f&&r.jsxs("button",{onClick:$,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:c("shell.actions.disconnectTitle"),children:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),r.jsx("span",{children:c("shell.actions.disconnect")})]}),r.jsxs("button",{onClick:ve,disabled:N||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:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),r.jsx("span",{children:c("shell.actions.restart")})]})]})]})}),r.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!v&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:r.jsx("div",{className:"text-white",children:c("shell.loading")})}),v&&!f&&!Z&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("button",{onClick:b,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:c("shell.actions.connectTitle"),children:[r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),r.jsx("span",{children:c("shell.actions.connect")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:le}):c("shell.startSession")})]})}),Z&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[r.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),r.jsx("span",{className:"text-base font-medium",children:c("shell.connecting")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName})})]})})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:c("shell.selectProject.title")}),r.jsx("p",{children:c("shell.selectProject.description")})]})})}function Rp({project:e,session:t=null,command:n=null,isPlainShell:o=null,autoConnect:s=!0,onComplete:a=null,onClose:l=null,title:c=null,className:d="",showHeader:u=!0,compact:m=!1,minimal:p=!1}){const[f,y]=i.useState(!1),v=o!==null?o:n!==null,_=i.useCallback(N=>{y(!0),a&&a(N)},[a]);return e?r.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!p&&u&&c&&r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-200",children:c}),f&&r.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),l&&r.jsx("button",{onClick:l,className:"text-gray-400 hover:text-white",title:"Close",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),r.jsx("div",{className:"flex-1 w-full min-h-0",children:r.jsx(lk,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:v,onProcessComplete:_,minimal:p,autoConnect:p?!0:s})})]}):r.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),r.jsx("p",{children:"A project is required to open a shell"})]})})}class ck extends Rt.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,n){console.error("ErrorBoundary caught an error:",t,n),this.setState({error:t,errorInfo:n})}render(){return this.state.hasError?r.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:r.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[r.jsxs("div",{className:"flex items-center mb-4",children:[r.jsx("div",{className:"flex-shrink-0",children:r.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),r.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),r.jsxs("div",{className:"text-sm text-red-700",children:[r.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&r.jsxs("details",{className:"mt-4",children:[r.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),r.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),r.jsx("div",{className:"mt-4",children:r.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"Try Again"})})]})}):this.props.children}}function Pp(e){return e==="files"?"chat":e}function Ac({provider:e}){return e==="codex"?r.jsx(ko,{className:"w-4 h-4"}):e==="gemini"?r.jsx(So,{className:"w-4 h-4"}):e==="opencode"?r.jsx(jo,{className:"h-4 w-auto max-w-full"}):r.jsx(wo,{className:"w-4 h-4"})}function dk({selectedProject:e,selectedSession:t,routeProvider:n,activeTab:o,setActiveTab:s,ws:a,sendMessage:l,latestMessage:c,isMobile:d,isPWA:u,onMenuClick:m,isLoading:p,onInputFocusChange:f,onSessionActive:y,onSessionInactive:v,onSessionProcessing:_,onSessionNotProcessing:N,processingSessions:E,onReplaceTemporarySession:z,onNavigateToSession:q,onShowSettings:Z,autoExpandTools:K,showRawParameters:V,showThinking:T,autoScrollToBottom:Y,sendByCtrlEnter:D,externalMessageUpdate:oe,urlContext:Q,urlPrompt:b,integrationClientId:$,latestIntegrationMessage:L,sendIntegrationMessage:ee,onShowNewProject:le,newSessionResetNonce:ve}){const{t:ue}=Ot(),[W,Se]=i.useState(null),Ce=(Je,_e=null)=>{const Qe={name:Je.split("/").pop(),path:Je,projectName:e?.name,diffInfo:_e};Se(Qe)},Ae=()=>{Se(null)};i.useEffect(()=>{const Je=Pp(o);Je!==o&&s(Je)},[o,s]);const se="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",J="flex flex-shrink-0 items-center justify-center text-muted-foreground";if(p)return r.jsxs("div",{className:"h-full flex flex-col",children:[d&&r.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:r.jsx("button",{onClick:m,className:`pwa-menu-button ${se}`,children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:r.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),r.jsx("h2",{className:"text-xl font-semibold",children:ue("mainContent.loading")})]})})]});if(!e)return r.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[d&&r.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:r.jsx("button",{onClick:m,className:`pwa-menu-button ${se}`,children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),r.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[r.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),r.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:ue("mainContent.chooseProject")}),r.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:ue("mainContent.selectProjectDescription")}),r.jsx("div",{className:"mx-auto flex w-fit items-center",children:r.jsxs("button",{onClick:le,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:ue("sidebar:projects.newProject"),children:[r.jsx(Sr,{className:"w-5 h-5"}),r.jsx("span",{children:ue("sidebar:projects.newProject")})]})})]})})]});const pe=t?.__provider||t?.provider||"claude",xe=pe==="openai"?"codex":pe,he=o==="chat"&&!!t,be=!!t?.id,je=xe==="codex"&&typeof t?.id=="string"?t.id.trim():"",Be=je?`codex://threads/${encodeURIComponent(je)}`:"",Ve=Pi({basename:typeof window<"u"&&window.__ROUTER_BASENAME__||"",returnPath:typeof window<"u"?Ri(window.location):"",projectPath:e?.fullPath||e?.path}),He=o==="chat"&&d&&!t,nt=(()=>{if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}})(),Pe=async()=>{if(be)try{await et.openSessionInCli({provider:xe,sessionId:t.id,projectPath:e?.fullPath||e?.path})}catch(Je){console.error("[MainContent] Failed to open session in local CLI:",Je)}},lt=()=>{Be&&(window.location.href=Be)},ct=()=>{window.open(window.location.href,"_blank","noopener,noreferrer")},Te=()=>{window.location.href=Ve};return r.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[r.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:r.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[d&&r.jsx("button",{onClick:m,onTouchStart:Je=>{Je.preventDefault(),m()},className:`pwa-menu-button ${se}`,children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[he&&r.jsx("div",{className:`${J} hidden sm:flex`,children:r.jsx(Ac,{provider:xe})}),r.jsx("div",{className:"min-w-0 flex-1",children:he?r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:xe==="codex"?t.summary||t.name||"Codex Session":xe==="gemini"?t.summary||t.name||"Gemini Session":xe==="opencode"?t.summary||t.name||"OpenCode Session":t.summary||"New Session"}),r.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[r.jsx("span",{className:`${J} sm:hidden`,children:r.jsx(Ac,{provider:xe})}),r.jsx("span",{className:"truncate",children:e.displayName})]})]}):o==="chat"&&!t?r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:ue("mainContent.newSession")}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"Project"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[He&&r.jsx("button",{onClick:Te,className:se,title:ue("mainContent.openImagePlayground"),"aria-label":ue("mainContent.openImagePlayground"),children:r.jsx(xi,{className:"w-5 h-5"})}),o==="chat"&&nt&&r.jsx("button",{onClick:ct,className:se,title:ue("mainContent.openInNewWindow"),"aria-label":ue("mainContent.openInNewWindow"),children:r.jsx(zh,{className:"w-5 h-5"})}),o==="chat"&&xe==="codex"&&Be&&!d&&r.jsx("button",{onClick:lt,className:se,title:ue("mainContent.openInCodexClient"),"aria-label":ue("mainContent.openInCodexClient"),children:r.jsx(ms,{className:"w-5 h-5"})}),o==="chat"&&be&&r.jsx("button",{onClick:Pe,className:se,title:ue("mainContent.openInCli"),"aria-label":ue("mainContent.openInCli"),children:r.jsx(id,{className:"w-5 h-5"})})]})]})}),r.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:r.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[r.jsx("div",{className:`h-full ${o==="chat"?"block":"hidden"}`,children:r.jsx(ck,{showDetails:!0,children:r.jsx(Y1,{selectedProject:e,selectedSession:t,initialProvider:n,ws:a,sendMessage:l,latestMessage:c,onFileOpen:Ce,onInputFocusChange:f,onSessionActive:y,onSessionInactive:v,onSessionProcessing:_,onSessionNotProcessing:N,processingSessions:E,onReplaceTemporarySession:z,onNavigateToSession:q,onShowSettings:Z,autoExpandTools:K,showRawParameters:V,showThinking:T,autoScrollToBottom:Y,sendByCtrlEnter:D,externalMessageUpdate:oe,urlContext:Q,urlPrompt:b,integrationClientId:$,latestIntegrationMessage:L,sendIntegrationMessage:ee,newSessionResetNonce:ve},`${e?.name||"no-project"}:${t?.id||`new-${ve}`}`)})}),o==="shell"&&r.jsx("div",{className:"h-full w-full overflow-hidden",children:r.jsx(Rp,{project:e,session:t,showHeader:!1})}),r.jsx("div",{className:`h-full overflow-hidden ${o==="preview"?"block":"hidden"}`})]})}),W&&r.jsx(tk,{file:W,onClose:Ae})]})}const uk=Rt.memo(dk),cs="0.2.12";function Ea(e){return String(e||"").trim().replace(/^v/i,"")||null}function pk(e,t=null){const n=Ea(e?.latestVersion),o=Ea(e?.currentVersion)||Ea(t),s=!!(n&&o&&n===o);return n?{updateAvailable:!!e?.updateAvailable&&!s,latestVersion:n,currentVersion:o,releaseInfo:{title:e?.releaseInfo?.title||`v${n}`,body:e?.releaseInfo?.body||"",htmlUrl:e?.releaseInfo?.htmlUrl||`https://www.npmjs.com/package/${e?.packageName||"@axhub/genie"}`,publishedAt:e?.releaseInfo?.publishedAt||null}}:{updateAvailable:!1,latestVersion:null,currentVersion:o,releaseInfo:null}}const Tp=()=>{const[e,t]=i.useState(!1),[n,o]=i.useState(null),[s,a]=i.useState(cs),[l,c]=i.useState(null);return i.useEffect(()=>{(async()=>{try{const u=await Zt("/api/system/version");if(!u.ok)throw new Error(`Version API failed: ${u.status}`);const m=await u.json();if(!m?.success)throw new Error(m?.error||"Version API returned unsuccessful result");const p=pk(m,cs);a(p.currentVersion||cs),o(p.latestVersion),t(p.updateAvailable),c(p.releaseInfo)}catch(u){console.error("Version check failed:",u.message||u),t(!1),o(null),a(cs),c(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:s,releaseInfo:l}};function mk(){const{t:e}=Ot("settings"),[t,n]=i.useState([]),[o,s]=i.useState(!0),[a,l]=i.useState(!1),[c,d]=i.useState(""),[u,m]=i.useState(null),[p,f]=i.useState(null),{updateAvailable:y,latestVersion:v,currentVersion:_,releaseInfo:N}=Tp();i.useEffect(()=>{E()},[]);const E=async()=>{try{s(!0);const T=await(await Zt("/api/settings/api-keys")).json();n(T.apiKeys||[])}catch(V){console.error("Error fetching settings:",V)}finally{s(!1)}},z=async()=>{if(c.trim())try{const T=await(await Zt("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:c})})).json();T.success&&(f(T.apiKey),d(""),l(!1),E())}catch(V){console.error("Error creating API key:",V)}},q=async V=>{if(confirm(e("apiKeys.confirmDelete")))try{await Zt(`/api/settings/api-keys/${V}`,{method:"DELETE"}),E()}catch(T){console.error("Error deleting API key:",T)}},Z=async(V,T)=>{try{await Zt(`/api/settings/api-keys/${V}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!T})}),E()}catch(Y){console.error("Error toggling API key:",Y)}},K=(V,T)=>{navigator.clipboard.writeText(V),m(T),setTimeout(()=>m(null),2e3)};return o?r.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):r.jsxs("div",{className:"space-y-8",children:[p&&r.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[r.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:p.apiKey}),r.jsx(Ge,{size:"sm",variant:"outline",onClick:()=>K(p.apiKey,"new"),children:u==="new"?r.jsx(In,{className:"h-4 w-4"}):r.jsx(sd,{className:"h-4 w-4"})})]}),r.jsx(Ge,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>f(null),children:e("apiKeys.newKey.iveSavedIt")})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ad,{className:"h-5 w-5"}),r.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),r.jsxs(Ge,{size:"sm",onClick:()=>l(!a),children:[r.jsx(fo,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),r.jsxs("div",{className:"mb-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),r.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[e("apiKeys.apiDocsLink"),r.jsx(ms,{className:"h-3 w-3"})]})]}),a&&r.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[r.jsx(or,{placeholder:e("apiKeys.form.placeholder"),value:c,onChange:V=>d(V.target.value),className:"mb-2"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ge,{onClick:z,children:e("apiKeys.form.createButton")}),r.jsx(Ge,{variant:"outline",onClick:()=>l(!1),children:e("apiKeys.form.cancelButton")})]})]}),r.jsx("div",{className:"space-y-2",children:t.length===0?r.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(V=>r.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"font-medium",children:V.key_name}),r.jsx("code",{className:"text-xs text-muted-foreground",children:V.api_key}),r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(V.created_at).toLocaleDateString(),V.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(V.last_used).toLocaleDateString()}`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{size:"sm",variant:V.is_active?"outline":"secondary",onClick:()=>Z(V.id,V.is_active),children:V.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),r.jsx(Ge,{size:"sm",variant:"ghost",onClick:()=>q(V.id),children:r.jsx(qn,{className:"h-4 w-4"})})]})]},V.id))})]}),r.jsx("div",{className:"pt-6 border-t border-border/50",children:r.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[r.jsxs("a",{href:N?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",_]}),y&&v&&r.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:[r.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:v})}),r.jsx(ms,{className:"h-2.5 w-2.5"})]})]})})]})}function fk({compact:e=!1}){const{i18n:t,t:n}=Ot("settings"),o=s=>{const a=s.target.value;t.changeLanguage(a)};return e?r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(kh,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),r.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:fl.map(s=>r.jsx("option",{value:s.value,children:s.nativeName},s.value))})]}):r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:n("account.languageLabel")}),r.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("account.languageDescription")})]}),r.jsx("select",{value:t.language,onChange: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:fl.map(s=>r.jsx("option",{value:s.value,children:s.nativeName},s.value))})]})})}function hk({isOpen:e,onClose:t,provider:n="claude",project:o,onComplete:s,customCommand:a,isAuthenticated:l=!1}){if(!e)return null;const c=()=>{if(a)return a;switch(n){case"claude":return l?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions";case"codex":return"codex login";case"gemini":return"npx -y @google/gemini-cli";case"opencode":return"npx -y opencode-ai@latest login";default:return l?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions"}},d=()=>{switch(n){case"claude":return"Claude CLI Login";case"codex":return"Codex CLI Login";case"gemini":return"Gemini CLI Login";case"opencode":return"OpenCode CLI Login";default:return"CLI Login"}},u=m=>{s?.(m),m===0&&t()};return r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),r.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:r.jsx(on,{className:"w-6 h-6"})})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Rp,{project:o,command:c(),onComplete:u,minimal:!0})})]})})}const Ia=["appearance","api"],xk={allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"},gk={permissionMode:"default"},vk=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],ci=[{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 _c(e,t){try{const n=localStorage.getItem(e);if(!n)return t;const o=JSON.parse(n);return o&&typeof o=="object"?{...t,...o}:t}catch{return t}}function yk(){return ci.reduce((e,t)=>(e[t.key]={authenticated:!1,email:null,loading:!0,error:null},e),{})}function Rc(){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 Pc({title:e,description:t,checked:n,onToggle:o}){return r.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:e}),t?r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:t}):null]}),r.jsx("button",{type:"button",onClick:o,className:`relative h-7 w-12 rounded-full transition ${n?"bg-primary":"bg-muted"}`,"aria-checked":n,role:"switch",children:r.jsx("span",{className:`absolute top-1 h-5 w-5 rounded-full bg-background shadow transition ${n?"left-6":"left-1"}`})})]})}function Tc({items:e,onRemove:t,emptyLabel:n}){return e.length?r.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(o=>r.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:[r.jsx("span",{className:"font-mono",children:o}),r.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:r.jsx(on,{className:"h-3.5 w-3.5"})})]},o))}):r.jsx("div",{className:"text-xs text-muted-foreground",children:n})}function bk({provider:e,status:t,onLogin:n}){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 r.jsxs("div",{className:`rounded-2xl border px-4 py-4 ${a}`,children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold text-foreground",children:e.label}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:s?"Checking local authentication...":o?t.email||"Authenticated locally":t?.error||"Not authenticated"})]}),r.jsx(zf,{variant:o?"default":"secondary",children:s?"Checking":o?"Ready":"Needs login"})]}),r.jsx("div",{className:"mt-4 flex items-center gap-2",children:r.jsxs(Ge,{size:"sm",variant:o?"outline":"default",onClick:()=>n(e.key),children:[r.jsx(Bf,{className:"mr-2 h-4 w-4"}),o?"Re-authenticate":"Open login"]})})]})}function wk({isOpen:e,onClose:t,projects:n=[],initialTab:o="appearance"}){const{isDarkMode:s,toggleDarkMode:a}=ui(),[l,c]=i.useState(Ia.includes(o)?o:"appearance"),[d,u]=i.useState([]),[m,p]=i.useState([]),[f,y]=i.useState(""),[v,_]=i.useState(""),[N,E]=i.useState(!1),[z,q]=i.useState("name"),[Z,K]=i.useState("default"),[V,T]=i.useState(!1),[Y,D]=i.useState(null),[oe,Q]=i.useState(yk),[b,$]=i.useState(!1),[L,ee]=i.useState("claude"),[le,ve]=i.useState(null);i.useEffect(()=>{c(Ia.includes(o)?o:"appearance")},[o]),i.useEffect(()=>{if(!e)return;const J=_c("claude-settings",xk),pe=_c("codex-settings",gk);u(Array.isArray(J.allowedTools)?J.allowedTools:[]),p(Array.isArray(J.disallowedTools)?J.disallowedTools:[]),E(!!J.skipPermissions),q(J.projectSortOrder==="date"?"date":"name"),K(pe.permissionMode||"default"),D(null),W()},[e]);const ue=i.useMemo(()=>le||n?.[0]||Rc(),[n,le]);async function W(){const J=await Promise.all(ci.map(async pe=>{try{const xe=await Zt(pe.endpoint),he=xe.ok?await xe.json():null;return[pe.key,{authenticated:!!he?.authenticated,email:he?.email||null,loading:!1,error:he?.error||(xe.ok?null:"Failed to check authentication status")}]}catch(xe){return[pe.key,{authenticated:!1,email:null,loading:!1,error:xe.message}]}}));Q(Object.fromEntries(J))}function Se(){T(!0),D(null);try{localStorage.setItem("claude-settings",JSON.stringify({allowedTools:d,disallowedTools:m,skipPermissions:N,projectSortOrder:z,lastUpdated:new Date().toISOString()})),localStorage.setItem("codex-settings",JSON.stringify({permissionMode:Z,lastUpdated:new Date().toISOString()})),D("success"),window.dispatchEvent(new StorageEvent("storage",{key:"claude-settings"})),window.dispatchEvent(new StorageEvent("storage",{key:"codex-settings"}))}catch(J){console.error("Error saving local settings:",J),D("error")}finally{T(!1)}}function Ce(J){ee(J),ve(n?.[0]||Rc()),$(!0)}function Ae(J){J===0&&(D("success"),W())}function se(J,pe,xe,he){const be=J.trim();!be||xe.includes(be)||(he([...xe,be]),pe(""))}return e?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",onClick:t}),r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:r.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:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 px-6 py-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:r.jsx(Dh,{className:"h-5 w-5"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-lg font-semibold text-foreground",children:"Settings"}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"Local preferences, provider auth, and API access."})]})]}),r.jsx(Ge,{variant:"ghost",size:"icon",onClick:t,"aria-label":"Close settings",children:r.jsx(on,{className:"h-5 w-5"})})]}),r.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[r.jsx("div",{className:"w-52 border-r border-border/60 bg-muted/20 p-4",children:r.jsx("div",{className:"space-y-2",children:Ia.map(J=>r.jsxs("button",{type:"button",onClick:()=>c(J),className:`flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition ${l===J?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:bg-muted/70 hover:text-foreground"}`,children:[J==="appearance"?r.jsx(Ff,{className:"h-4 w-4"}):r.jsx(ad,{className:"h-4 w-4"}),r.jsx("span",{children:J==="appearance"?"Appearance":"API & Auth"})]},J))})}),r.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5",children:l==="appearance"?r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Application"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Adjust the shell around the editor and sidebar."})]}),r.jsx(Pc,{title:"Dark mode",description:"Switch the overall application theme.",checked:s,onToggle:a}),r.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[r.jsx($f,{className:"h-4 w-4"}),"Interface language"]}),r.jsx(fk,{})]}),r.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[r.jsx("div",{className:"mb-2 text-sm font-medium text-foreground",children:"Project list sorting"}),r.jsxs("select",{value:z,onChange:J=>q(J.target.value==="date"?"date":"name"),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm",children:[r.jsx("option",{value:"name",children:"Name"}),r.jsx("option",{value:"date",children:"Last activity"})]})]})]}),r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Claude / Codex local behavior"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"These options stay in local storage and are used by the chat runtime."})]}),r.jsx(Pc,{title:"Skip Claude permission prompts",description:"Bypass interactive approvals when the runtime supports it.",checked:N,onToggle:()=>E(J=>!J)}),r.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-3",children:[r.jsx("div",{className:"mb-2 text-sm font-medium text-foreground",children:"Codex permission mode"}),r.jsxs("select",{value:Z,onChange:J=>K(J.target.value||"default"),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm",children:[r.jsx("option",{value:"default",children:"Default"}),r.jsx("option",{value:"acceptEdits",children:"Accept edits"}),r.jsx("option",{value:"bypassPermissions",children:"Bypass permissions"}),r.jsx("option",{value:"plan",children:"Plan"})]})]}),r.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-4",children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[r.jsx(Fh,{className:"h-4 w-4"}),"Allowed tool patterns"]}),r.jsx("div",{className:"flex flex-wrap gap-2 pb-3",children:vk.map(J=>r.jsx("button",{type:"button",onClick:()=>se(J,y,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:J},J))}),r.jsxs("div",{className:"flex gap-2 pb-3",children:[r.jsx(or,{value:f,onChange:J=>y(J.target.value),placeholder:"Add custom allow rule"}),r.jsx(Ge,{onClick:()=>se(f,y,d,u),children:"Add"})]}),r.jsx(Tc,{items:d,onRemove:J=>u(d.filter(pe=>pe!==J)),emptyLabel:"No allow-list entries."})]}),r.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card/70 px-4 py-4",children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-medium text-foreground",children:[r.jsx(ro,{className:"h-4 w-4"}),"Disallowed tool patterns"]}),r.jsxs("div",{className:"flex gap-2 pb-3",children:[r.jsx(or,{value:v,onChange:J=>_(J.target.value),placeholder:"Add custom deny rule"}),r.jsx(Ge,{variant:"outline",onClick:()=>se(v,_,m,p),children:"Add"})]}),r.jsx(Tc,{items:m,onRemove:J=>p(m.filter(pe=>pe!==J)),emptyLabel:"No deny-list entries."})]})]})]}):r.jsxs("div",{className:"space-y-6",children:[r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Provider authentication"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open a local terminal flow to sign the CLI back in when needed."})]}),r.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:ci.map(J=>r.jsx(bk,{provider:J,status:oe[J.key],onLogin:Ce},J.key))})]}),r.jsxs("section",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-base font-semibold text-foreground",children:"API keys"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage the local keys used to call protected Genie endpoints."})]}),r.jsx(mk,{})]})]})})]}),r.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-6 py-4",children:[r.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:Y==="success"?r.jsxs(r.Fragment,{children:[r.jsx(In,{className:"h-4 w-4 text-emerald-500"}),r.jsx("span",{children:"Saved locally."})]}):Y==="error"?r.jsxs(r.Fragment,{children:[r.jsx(ro,{className:"h-4 w-4 text-amber-500"}),r.jsx("span",{children:"Could not save local settings."})]}):r.jsx("span",{children:"Changes only affect this local workspace profile."})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{variant:"outline",onClick:t,children:"Close"}),r.jsx(Ge,{onClick:Se,disabled:V,children:V?"Saving...":"Save settings"})]})]})]})}),r.jsx(hk,{isOpen:b,onClose:()=>$(!1),provider:L,project:ue,onComplete:Ae,isAuthenticated:!!oe[L]?.authenticated})]}):null}var kk=["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","className","spin"];function Mc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,o)}return n}function Dc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Mc(Object(n),!0).forEach(function(o){Sk(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mc(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Sk(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jk(e,t){if(e==null)return{};var n=Ck(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)&&(n[o]=e[o])}return n}function Ck(e,t){if(e==null)return{};var n={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Nk={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 Ek(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function Ik(e,t,n){var o=typeof t.fill=="string"?[t.fill]:t.fill||[],s=[],a=t.theme||n.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]:n.colors.twoTone.twoTone),s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:n.colors.twoTone.twoTone);break;case"multi-color":s.push(typeof o[0]=="string"?o[0]:"currentColor"),s.push(typeof o[1]=="string"?o[1]:n.colors.multiColor.outFillColor),s.push(typeof o[2]=="string"?o[2]:n.colors.multiColor.innerStrokeColor),s.push(typeof o[3]=="string"?o[3]:n.colors.multiColor.innerFillColor);break}return{size:t.size||n.size,strokeWidth:t.strokeWidth||n.strokeWidth,strokeLinecap:t.strokeLinecap||n.strokeLinecap,strokeLinejoin:t.strokeLinejoin||n.strokeLinejoin,colors:s,id:e}}var Mp=i.createContext(Nk);Mp.Provider;function Dp(e,t,n){return function(o){var s=o.size,a=o.strokeWidth,l=o.strokeLinecap,c=o.strokeLinejoin,d=o.theme,u=o.fill,m=o.className,p=o.spin,f=jk(o,kk),y=i.useContext(Mp),v=i.useMemo(Ek,[]),_=Ik(v,{size:s,strokeWidth:a,strokeLinecap:l,strokeLinejoin:c,theme:d,fill:u},y),N=[y.prefix+"-icon"];return N.push(y.prefix+"-icon-"+e),y.rtl&&N.push(y.prefix+"-icon-rtl"),p&&N.push(y.prefix+"-icon-spin"),m&&N.push(m),Rt.createElement("span",Dc(Dc({},f),{},{className:N.join(" ")}),n(_))}}const Ak=Dp("new-lark",!0,function(e){return Rt.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},Rt.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}),Rt.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]}),Rt.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}))}),_k=Dp("wechat",!0,function(e){return Rt.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},Rt.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]}),Rt.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}),Rt.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]}),Rt.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]}),Rt.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]}),Rt.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}),Rt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M42.0024 35.9728L43 42L38.7618 39.9293",fill:e.colors[1]}),Rt.createElement("path",{d:"M42.0024 35.9728L43 42L38.7618 39.9293",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),Rt.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]}),Rt.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]}))}),Rk=2e3,Zn="lan",Lc="lan-access-password",Pk={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode"};function Tk({provider:e,className:t="h-4 w-4"}){return e==="codex"?r.jsx(ko,{className:t}):e==="gemini"?r.jsx(So,{className:t}):e==="opencode"?r.jsx(jo,{className:"h-4 w-auto"}):r.jsx(wo,{className:t})}function ds({platform:e,size:t=20}){return e==="weixin"?r.jsx(_k,{size:t,theme:"filled",fill:"#07C160"}):r.jsx(Ak,{size:t,theme:"filled",fill:"#3370FF"})}function Mk(e){return Pk[e]||e}function Dk(e){if(!e)return"0:00";const t=e-Date.now();if(t<=0)return"0:00";const n=Math.ceil(t/1e3),o=Math.floor(n/60),s=n%60;return`${o}:${String(s).padStart(2,"0")}`}function di(e){return e?.fullPath||e?.path||""}function Aa(e){const t=di(e),n=typeof e?.displayName=="string"?e.displayName.trim():"",o=typeof e?.name=="string"?e.name.trim():"";if(n)return n;if(o)return o;if(!t)return"";const a=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return a[a.length-1]||t}function Oc(e){return e&&(e.title||e.label||e.value)||""}function Lk({open:e,onOpenChange:t,selectedProject:n,projects:o=[],onConnectionChange:s}){const{t:a}=Ot("sidebar"),[l,c]=i.useState(null),[d,u]=i.useState(!1),[m,p]=i.useState(null),[f,y]=i.useState(null),[v,_]=i.useState(null),[N,E]=i.useState(""),[z,q]=i.useState({}),[Z,K]=i.useState(null),[V,T]=i.useState(""),[Y,D]=i.useState(""),[oe,Q]=i.useState(!1),[b,$]=i.useState(""),[L,ee]=i.useState({}),[le,ve]=i.useState({}),ue=i.useRef(null),W=i.useRef(null),Se=di(n),Ce=l?.ccConnect?.installed===!0,Ae=i.useMemo(()=>m===Zn?v?{id:Zn,connected:!!v.hasPassword,addresses:v.addresses||[]}:null:l?.platforms?.find(j=>j.id===m)||null,[m,v,l]),se=f&&f.platform===m?f:null,J=i.useMemo(()=>(l?.providers||[]).filter(j=>j.installed).map(j=>j.id),[l]),pe=i.useMemo(()=>{const j=new Map,M=(H,ae)=>{const Ie=String(H||"").trim();!Ie||j.has(Ie)||j.set(Ie,{value:Ie,title:String(ae||Ie).trim()||Ie,subtitle:Ie})};for(const H of o){const ae=di(H);M(ae,Aa(H))}Se&&M(Se,Aa(n));for(const H of l?.platforms||[])H?.projectPath&&M(H.projectPath,Aa({path:H.projectPath}));return Array.from(j.values())},[o,n,Se,l]),xe=i.useMemo(()=>new Map(pe.map(j=>[j.value,j])),[pe]),he=i.useMemo(()=>{const j=l?.platforms||[],M=v?[{id:Zn,connected:!!v.hasPassword,projectPath:v.addresses?.length?v.addresses.join(" / "):null,configuredProviders:[],activeProvider:null,addresses:v.addresses||[]}]:[];return[...j,...M]},[v,l]),be=()=>{ue.current&&(clearInterval(ue.current),ue.current=null)},je=async({silent:j=!1}={})=>{j||u(!0);try{const M=await et.ccConnect.platforms(),H=await M.json();if(!M.ok)throw new Error(H?.error||"Failed to load connection summary.");return c(H),s?.(H),H}catch(M){return T(M.message),null}finally{j||u(!1)}},Be=async()=>{try{const j=await et.lanAccess.summary(),M=await j.json();if(!j.ok)throw new Error(M?.error||"Failed to load LAN access summary.");if(_(M),M?.hasPassword){const H=localStorage.getItem(Lc);H&&E(H)}return M}catch(j){return T(j.message),null}},Ve=async(j,{focusQr:M=!1}={})=>{const H=await et.lanAccess.createToken(j),ae=await H.json();if(!H.ok)throw new Error(ae?.error||"Failed to generate LAN access link.");return q(Ie=>({...Ie,[j]:ae})),M&&K(j),ae},He=async(j=[])=>{const M={};for(const H of j)try{const ae=await Ve(H);M[H]=ae}catch(ae){T(ae.message)}return M},nt=async()=>{const j=W.current;if(be(),!(!j?.sessionId||!j?.platform||new Set(["confirmed","error","expired"]).has(j.status)))try{await et.ccConnect.cleanupSession(j.platform,j.sessionId)}catch{}};i.useEffect(()=>{W.current=f},[f]),i.useEffect(()=>{if(!e){nt(),c(null),p(null),y(null),_(null),E(""),q({}),K(null),T(""),D(""),$(""),ee({}),ve({});return}return Promise.all([je(),Be()]).then(([,j])=>{j?.hasPassword&&j.addresses?.length&&He(j.addresses)}),()=>{be()}},[e]),i.useEffect(()=>{if(!se?.sessionId){be();return}const j=async()=>{try{const M=await et.ccConnect.sessionStatus(se.platform,se.sessionId),H=await M.json();if(!M.ok)throw new Error(H?.error||"Failed to read setup status.");y(H),H.status==="confirmed"?(be(),D(H.message||a("ccConnect.messages.connected")),$(""),y(null),await je({silent:!0})):(H.status==="error"||H.status==="expired")&&(be(),$(""))}catch(M){be(),$(""),T(M.message)}};return j(),ue.current=setInterval(()=>{j()},Rk),()=>be()},[se?.platform,se?.sessionId,a]),i.useEffect(()=>{e&&ee(j=>{const M={...j};let H=!1;const ae=l?.platforms||[];for(const Ie of ae){if(typeof j[Ie.id]=="string"?j[Ie.id].trim():"")continue;const we=Ie.projectPath||Se||pe[0]?.value||"";we&&(M[Ie.id]=we,H=!0)}return H?M:j})},[e,pe,Se,l]),i.useEffect(()=>{e&&ve(j=>{const M={...j};let H=!1;for(const ae of l?.platforms||[]){const Ie=Array.isArray(ae.configuredProviders)&&ae.configuredProviders.length>0?ae.configuredProviders:J,te=typeof j[ae.id]=="string"?j[ae.id].trim():"";if(te&&Ie.includes(te))continue;const we=Ie.includes(ae.activeProvider)?ae.activeProvider:Ie[0]||"";we&&(M[ae.id]=we,H=!0)}return H?M:j})},[J,e,l]);const Pe=j=>{const M=typeof L[j]=="string"?L[j].trim():"";return M||l?.platforms?.find(ae=>ae.id===j)?.projectPath||Se||pe[0]?.value||""},lt=j=>Array.isArray(j?.configuredProviders)&&j.configuredProviders.length>0?j.configuredProviders:J,ct=j=>{const M=lt(j),H=typeof le[j?.id]=="string"?le[j.id].trim():"";return H&&M.includes(H)?H:j?.activeProvider&&M.includes(j.activeProvider)?j.activeProvider:M[0]||null},Te=async(j,M)=>{if(ee(H=>({...H,[j.id]:M})),T(""),D(""),j.connected&&M&&M!==j.projectPath)try{await B(j.id,M)}catch{}},Je=async(j,M,{persist:H=!1}={})=>{ve(ae=>({...ae,[j.id]:M})),H&&(T(""),D(""),await rt(j.id,M))},_e=()=>{t(!1)},Qe=async()=>{$("lan:password"),T(""),D("");try{const j=await et.lanAccess.updatePassword(N),M=await j.json();if(!j.ok)throw new Error(M?.error||"Failed to update LAN access password.");D(M.message||a("ccConnect.messages.lanPasswordUpdated")),localStorage.setItem(Lc,N);const H=await Be();H?.addresses?.length&&(q({}),await He(H.addresses))}catch(j){T(j.message)}finally{$("")}},Ke=async j=>{try{const M=z[j]||await Ve(j);await navigator.clipboard.writeText(M.accessUrl),D(a("ccConnect.messages.lanCopied"))}catch(M){T(M.message||a("ccConnect.messages.lanCopyFailed"))}},mt=async j=>{try{const M=z[j]||await Ve(j);window.open(M.accessUrl,"_blank","noopener,noreferrer")}catch(M){T(M.message)}},Xe=async j=>{try{if(!z[j]){await Ve(j,{focusQr:!0});return}K(j)}catch(M){T(M.message)}},P=async(j,M)=>{const H=Pe(j);if(!H){T(a("ccConnect.messages.selectProjectFirst"));return}T(""),D(""),$(`setup:${j}:${M}`);const ae={projectPath:H,mode:M},Ie=ct(l?.platforms?.find(te=>te.id===j));Ie&&(ae.provider=Ie);try{const te=await et.ccConnect.setup(j,ae),we=await te.json();if(!te.ok)throw new Error(we?.error||a("ccConnect.messages.setupFailed"));y(we),$(""),p(j)}catch(te){$(""),T(te.message)}},B=async(j,M=null)=>{const H=M||Pe(j);if(!H){T(a("ccConnect.messages.selectProjectFirst"));return}T(""),D(""),$(`project:${j}`);try{const ae=await et.ccConnect.updateProject(j,{projectPath:H}),Ie=await ae.json();if(!ae.ok)throw new Error(Ie?.error||a("ccConnect.messages.projectUpdateFailed"));D(Ie.message||a("ccConnect.messages.projectUpdateSuccess")),await je({silent:!0})}catch(ae){throw T(ae.message),ae}finally{$("")}},me=async()=>{if(!(!se?.platform||!se?.sessionId)){T(""),$(`refresh:${se.platform}`);try{const j=await et.ccConnect.refresh(se.platform,se.sessionId),M=await j.json();if(!j.ok)throw new Error(M?.error||a("ccConnect.messages.refreshFailed"));y(M),$("")}catch(j){$(""),T(j.message)}}},Fe=async()=>{T(""),D(""),Q(!0);try{const j=await et.ccConnect.install(),M=await j.json();if(!j.ok)throw new Error(M?.error||a("ccConnect.messages.installFailed"));D(M.message||a("ccConnect.messages.installSuccess")),await je({silent:!0})}catch(j){T(j.message)}finally{Q(!1)}},rt=async(j,M)=>{T(""),D(""),$(`switch:${j}:${M}`);try{const H=await et.ccConnect.switchProvider(j,M),ae=await H.json();if(!H.ok)throw new Error(ae?.error||a("ccConnect.messages.switchFailed"));D(ae.message||a("ccConnect.messages.switchSuccess")),await je({silent:!0})}catch(H){T(H.message)}finally{$("")}},fe=async j=>{T(""),D(""),$(`unbind:${j}`);try{const M=await et.ccConnect.unbind(j),H=await M.json();if(!M.ok)throw new Error(H?.error||a("ccConnect.messages.unbindFailed"));D(H.message||a("ccConnect.messages.unbindSuccess")),await je({silent:!0}),y(null)}catch(M){T(M.message)}finally{$("")}},g=async()=>{se?.sessionId&&(await nt(),y(null)),T(""),D(""),p(null),K(null)};if(!e)return null;const ie=(j,M)=>{if(!M)return null;const H=j==="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 r.jsx("div",{className:`rounded-xl border px-3 py-2 text-sm ${H}`,children:M})},Ne=()=>r.jsxs("div",{className:"space-y-4 rounded-2xl border border-dashed border-border bg-muted/20 p-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.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:r.jsx(ua,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.install.title")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.install.description")})]})]}),r.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@latest"}),r.jsxs(Ge,{onClick:Fe,disabled:oe,children:[oe?r.jsx(Bt,{className:"h-4 w-4 animate-spin"}):r.jsx(ua,{className:"h-4 w-4"}),a(oe?"ccConnect.install.installing":"ccConnect.install.action")]})]}),de=j=>{const M=Pe(j.id),H=b===`project:${j.id}`,ae=xe.get(M)||null,Ie=pe.length>0;return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.project.label")}),H&&r.jsx(Bt,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),r.jsxs(Zc,{value:M||void 0,onValueChange:te=>{Te(j,te)},disabled:!Ie||!!b||!!se,children:[r.jsx(ed,{className:"h-auto min-h-12 w-full items-start py-3",children:ae?r.jsxs("div",{className:"min-w-0 text-left",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Oc(ae)}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:ae.subtitle})]}):r.jsx("div",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.placeholder")})}),r.jsx(td,{children:pe.map(te=>r.jsx(nd,{value:te.value,children:r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate font-medium text-foreground",children:Oc(te)}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:te.subtitle})]})},te.value))})]}),!M&&r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.empty")})]})},Oe=({platform:j,providers:M,selectedProvider:H,onSelect:ae,disabled:Ie=!1,disableSelected:te=!1,busyActionForProvider:we=null})=>M?.length?r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("ccConnect.labels.providerSwitcher")}),r.jsx("div",{className:"flex flex-wrap gap-2",children:M.map(ut=>{const gt=ut===H,C=typeof we=="function"?we(ut):!1;return r.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 ${gt?"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:Ie||te&>&&!C,onClick:()=>{ae(ut)},children:[r.jsx(Tk,{provider:ut,className:"h-3.5 w-3.5"}),r.jsx("span",{children:Mk(ut)}),C?r.jsx(Bt,{className:"h-3.5 w-3.5 animate-spin"}):gt?r.jsx(gl,{className:"h-3.5 w-3.5"}):null]},`${j.id}:${ut}`)})})]}):null,Me=()=>r.jsxs("div",{className:"space-y-4",children:[ie("success",Y),ie("error",V),r.jsx("div",{className:"grid gap-3",children:he.map(j=>r.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-card",children:[r.jsx("button",{className:"w-full px-4 py-4 text-left transition-colors hover:bg-muted/20",onClick:()=>{p(j.id),T(""),D("")},children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:j.id===Zn?r.jsx(Ma,{className:"h-5 w-5"}):r.jsx(ds,{platform:j.id,size:20})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a(`ccConnect.platforms.${j.id}.title`)}),j.connected&&r.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")})]}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a(`ccConnect.platforms.${j.id}.description`)}),j.projectPath?r.jsx("p",{className:"mt-3 break-all text-xs text-muted-foreground",children:j.projectPath}):r.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:a("ccConnect.status.notConnected")})]})]})}),j.connected&&j.configuredProviders?.length>0&&r.jsx("div",{className:"border-t border-border/60 bg-muted/10 px-4 py-3",children:Oe({platform:j,providers:j.configuredProviders,selectedProvider:j.activeProvider,disabled:!!b,disableSelected:!0,busyActionForProvider:M=>b===`switch:${j.id}:${M}`,onSelect:async M=>{await Je(j,M,{persist:!0})}})})]},j.id))})]}),$e=j=>Oe({platform:j,providers:lt(j),selectedProvider:j.activeProvider,disabled:!!b,disableSelected:!0,busyActionForProvider:M=>b===`switch:${j.id}:${M}`,onSelect:async M=>{await Je(j,M,{persist:!0})}}),De=j=>r.jsxs("div",{className:"space-y-4",children:[r.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:r.jsxs("div",{className:"flex items-start gap-3",children:[r.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:r.jsx(Jh,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-semibold text-green-700 dark:text-green-300",children:a("ccConnect.labels.connectedTitle",{platform:a(`ccConnect.platforms.${j.id}.title`)})}),r.jsx("p",{className:"mt-1 text-sm text-green-700/80 dark:text-green-300/80",children:a("ccConnect.labels.connectedHint")})]})]})}),de(j),$e(j),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs(Ge,{variant:"outline",onClick:()=>{fe(j.id)},disabled:!!b,className:"text-red-600 hover:text-red-600",children:[b===`unbind:${j.id}`?r.jsx(Bt,{className:"h-4 w-4 animate-spin"}):r.jsx(Vh,{className:"h-4 w-4"}),a("ccConnect.actions.unbind")]}),r.jsx(Ge,{variant:"ghost",onClick:g,children:a("ccConnect.actions.back")})]})]}),it=()=>{if(!se)return null;const j=se.mode==="qr",M=se.status==="pending"&&(se.qrImageBase64||se.qrUrl);return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/20 p-4",children:r.jsxs("div",{className:"flex min-h-[220px] flex-col items-center justify-center gap-3",children:[(se.status==="starting"||b.startsWith("setup:"))&&r.jsxs(r.Fragment,{children:[r.jsx(Bt,{className:"h-8 w-8 animate-spin text-primary"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.starting")})]}),M&&r.jsxs(r.Fragment,{children:[se.qrImageBase64?r.jsx("img",{src:`data:image/png;base64,${se.qrImageBase64}`,alt:a("ccConnect.labels.qrAlt"),className:"h-48 w-48 rounded-xl border border-border bg-white object-contain p-2"}):r.jsx("img",{src:se.qrUrl,alt:a("ccConnect.labels.qrAlt"),className:"h-48 w-48 rounded-xl border border-border bg-white object-contain p-2"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.status.awaitingScan")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.labels.countdown",{time:Dk(se.expiresAt)})})]}),se.status==="scanned"&&r.jsxs(r.Fragment,{children:[r.jsx(gl,{className:"h-10 w-10 text-primary"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:a("ccConnect.status.scanned")}),r.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.status.confirmOnDevice")})]}),se.status==="error"&&r.jsxs(r.Fragment,{children:[r.jsx(ua,{className:"h-8 w-8 text-red-500"}),r.jsx("p",{className:"text-sm font-medium text-red-600 dark:text-red-300",children:se.message})]}),se.status==="expired"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{className:"h-8 w-8 text-muted-foreground"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.expired")})]})]})}),j&&(se.status==="pending"||se.status==="error"||se.status==="expired")&&r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(Ge,{variant:"outline",onClick:()=>{me()},disabled:!!b,children:[b.startsWith("refresh:")?r.jsx(Bt,{className:"h-4 w-4 animate-spin"}):r.jsx(Ta,{className:"h-4 w-4"}),a("ccConnect.actions.refreshQr")]}),r.jsx(Ge,{variant:"ghost",onClick:g,children:a("ccConnect.actions.cancel")})]})]})},ge=j=>r.jsxs("div",{className:"space-y-4",children:[de(j),Oe({platform:j,providers:lt(j),selectedProvider:ct(j),disabled:!!se||!!b,onSelect:async M=>{await Je(j,M)}}),r.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:r.jsx(Yo,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.weixin.qrTitle")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.weixin.qrDescription")})]})]}),!se&&r.jsxs(Ge,{className:"mt-4",onClick:()=>{P(j.id,"qr")},disabled:!Pe(j.id)||!ct(j)||!!b,children:[b==="setup:weixin:qr"?r.jsx(Bt,{className:"h-4 w-4 animate-spin"}):r.jsx(ds,{platform:j.id,size:16}),a("ccConnect.actions.connectWeixin")]})]}),it(),!se&&r.jsx(Ge,{variant:"ghost",onClick:g,children:a("ccConnect.actions.back")})]}),Re=j=>r.jsxs("div",{className:"space-y-4",children:[de(j),Oe({platform:j,providers:lt(j),selectedProvider:ct(j),disabled:!!se||!!b,onSelect:async M=>{await Je(j,M)}}),!se&&r.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:r.jsx(Yo,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.feishu.qrTitle")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.feishu.qrDescription")})]})]}),r.jsxs(Ge,{className:"mt-4",onClick:()=>{P(j.id,"qr")},disabled:!Pe(j.id)||!ct(j)||!!b,children:[b==="setup:feishu:qr"?r.jsx(Bt,{className:"h-4 w-4 animate-spin"}):r.jsx(ds,{platform:j.id,size:16}),a("ccConnect.actions.startQrSetup")]})]}),it(),!se&&r.jsx(Ge,{variant:"ghost",onClick:g,children:a("ccConnect.actions.back")})]}),Et=()=>{const j=v?.addresses||[],M=Z?z[Z]:null;return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:r.jsx(vl,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.passwordTitle")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.lan.passwordDescription")})]})]}),r.jsxs("div",{className:"mt-4 flex flex-col gap-3 sm:flex-row",children:[r.jsx("input",{type:"password",value:N,onChange:H=>E(H.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"}),r.jsxs(Ge,{className:"h-11 rounded-2xl px-4",onClick:()=>{Qe()},disabled:!N.trim()||b==="lan:password",children:[b==="lan:password"?r.jsx(Bt,{className:"h-4 w-4 animate-spin"}):r.jsx(vl,{className:"h-4 w-4"}),a("ccConnect.actions.saveLanPassword")]})]})]}),r.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[r.jsxs("div",{className:"mb-3",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.linksTitle")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a("ccConnect.platforms.lan.linksDescription")})]}),r.jsx("div",{className:"space-y-3",children:j.length?j.map(H=>(z[H],r.jsx("div",{className:"rounded-2xl border border-border/70 bg-muted/10 px-3 py-2.5",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:H})}),r.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[r.jsx(un,{content:a("ccConnect.actions.copyLink"),delay:150,children:r.jsx("span",{children:r.jsx(Ge,{variant:"outline",size:"icon",className:"h-9 w-9 rounded-xl",disabled:!v?.hasPassword,onClick:()=>{Ke(H)},"aria-label":a("ccConnect.actions.copyLink"),title:a("ccConnect.actions.copyLink"),children:r.jsx(sd,{className:"h-4 w-4"})})})}),r.jsx(un,{content:a("ccConnect.actions.openLink"),delay:150,children:r.jsx("span",{children:r.jsx(Ge,{variant:"outline",size:"icon",className:"h-9 w-9 rounded-xl",disabled:!v?.hasPassword,onClick:()=>{mt(H)},"aria-label":a("ccConnect.actions.openLink"),title:a("ccConnect.actions.openLink"),children:r.jsx(ms,{className:"h-4 w-4"})})})}),r.jsx(un,{content:a("ccConnect.actions.showLanQr"),delay:150,children:r.jsx("span",{children:r.jsx(Ge,{size:"icon",className:"h-9 w-9 rounded-xl",disabled:!v?.hasPassword,onClick:()=>{Xe(H)},"aria-label":a("ccConnect.actions.showLanQr"),title:a("ccConnect.actions.showLanQr"),children:r.jsx(Yo,{className:"h-4 w-4"})})})})]})]})},H))):r.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&&r.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:r.jsx(Yo,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-semibold text-foreground",children:a("ccConnect.platforms.lan.qrTitle")}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:Z})]})]}),r.jsxs("div",{className:"mt-4 flex flex-col items-center gap-3",children:[r.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"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:a("ccConnect.platforms.lan.qrHint")})]})]})]})},st=j=>j?r.jsxs("div",{className:"space-y-4",children:[ie("success",Y),ie("error",V),j.id!==Zn&&!Ce&&!j.connected?r.jsxs("div",{className:"space-y-4",children:[Ne(),r.jsx(Ge,{variant:"ghost",onClick:g,children:a("ccConnect.actions.back")})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.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:()=>{g()},children:[r.jsx(Jf,{className:"h-4 w-4"}),a("ccConnect.actions.back")]}),r.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:[j.id===Zn?r.jsx(Ma,{className:"h-4 w-4"}):r.jsx(ds,{platform:j.id,size:16}),a(`ccConnect.platforms.${j.id}.title`)]})]}),j.id===Zn?Et():j.connected&&!se?De(j):j.id==="weixin"?ge(j):Re(j)]})]}):null;return us.createPortal(r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:r.jsxs("div",{className:"w-full max-w-2xl overflow-hidden rounded-[28px] border border-border/70 bg-background shadow-2xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border/60 px-6 py-4",children:[r.jsx("div",{className:"min-w-0",children:r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:a("ccConnect.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.subtitle")})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[d&&r.jsx(Bt,{className:"h-4 w-4 animate-spin text-muted-foreground"}),r.jsx(Ge,{variant:"ghost",size:"icon",onClick:_e,"aria-label":a("actions.cancel"),children:r.jsx(on,{className:"h-4 w-4"})})]})]}),r.jsx("div",{className:"max-h-[80vh] overflow-y-auto px-6 py-5",children:l||v?Ae?st(Ae):Me():r.jsxs("div",{className:"flex min-h-[240px] flex-col items-center justify-center gap-3",children:[r.jsx(Bt,{className:"h-8 w-8 animate-spin text-primary"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.loading")})]})})]})}),document.body)}async function Ok(e){if(!String(e.headers.get("content-type")||"").toLowerCase().includes("application/json"))return null;const n=await e.text();if(!n.trim())return null;try{return JSON.parse(n)}catch{return null}}function Fk(e=window.location.hostname){return e==="localhost"||e==="127.0.0.1"||e==="::1"}const Lp=i.createContext({user:null,token:null,authenticateLanAccess:()=>{},logout:()=>{},isLoading:!0,error:null}),Ui=()=>{const e=i.useContext(Lp);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},$k=({children:e})=>{const[t,n]=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),n(null)},m=(_,N)=>{_&&(localStorage.setItem("auth-token",_),s(_)),n(N||null)},p=async()=>{const _=await et.auth.bootstrap(),N=await _.json();if(!_.ok){if(_.status===403)return!1;throw new Error(N?.error||"Failed to initialize local access")}return m(N.token,N.user),!0},f=async()=>{try{l(!0),d(null);const _=localStorage.getItem("auth-token");if(_)try{const N=await et.auth.user();if(N.ok){const E=await N.json();s(_),n(E.user);return}u()}catch(N){console.error("Token verification failed:",N),u()}Fk()&&await p()}catch(_){console.error("[AuthContext] Authentication bootstrap failed:",_),d(_.message||"Failed to initialize access")}finally{l(!1)}};i.useEffect(()=>{f()},[]);const y=async _=>{try{d(null);const N=await et.lanAccess.login(_),E=await Ok(N);if(N.ok)return m(E.token,E.user),{success:!0};const z=E?.error||(N.status>=500?"服务暂时不可用,请确认本机后端服务已启动。":"Access denied");return d(z),{success:!1,error:z}}catch(N){console.error("LAN access login error:",N);const E="Network error. Please try again.";return d(E),{success:!1,error:E}}},v=()=>{u(),o&&et.auth.logout().catch(_=>{console.error("Logout endpoint error:",_)})};return r.jsx(Lp.Provider,{value:{user:t,token:o,authenticateLanAccess:y,logout:v,isLoading:a,error:c},children:e})},zk=new Set(["presence:ping"]),Bk=3,Uk=3e3,qk=3e4;function Wk(e){return!e||typeof e!="object"?!1:zk.has(String(e.type||""))}function Kk(e,{baseDelayMs:t=Uk,maxDelayMs:n=qk}={}){const o=Math.max(1,Number(e)||1),s=t*2**(o-1);return Math.min(s,n)}function Hk(e,{maxAttempts:t=Bk}={}){return(Number(e)||0)<t}const Op=i.createContext(null),Gk=()=>{const e=i.useContext(Op);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},Vk=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},Qk=()=>{const e=i.useRef(null),t=i.useRef(!1),[n,o]=i.useState(null),[s,a]=i.useState(!1),[l,c]=i.useState("idle"),d=i.useRef(null),u=i.useRef(0),m=i.useRef(!1),p=i.useRef(!1),f=i.useRef([]),y=i.useRef([]),v=i.useRef(null),_=i.useRef(0),{token:N}=Ui(),E=i.useCallback(()=>{if(v.current||t.current)return;const Q=()=>{if(v.current=null,t.current){y.current=[];return}const b=y.current.shift();b&&(_.current+=1,o({...b,__messageSeq:_.current}),y.current.length>0&&(v.current=setTimeout(Q,0)))};v.current=setTimeout(Q,0)},[]),z=i.useCallback(Q=>{y.current.push(Q),E()},[E]),q=i.useCallback((Q,b)=>{z({type:"connection-error",error:b,provider:Q?.provider||(typeof Q?.type=="string"?Q.type.replace(/-command$/,""):"claude"),sessionId:Q?.sessionId||Q?.options?.sessionId||null,clientRequestId:Q?.clientRequestId||null})},[z]),Z=i.useCallback(Q=>{Q.timeoutId&&(clearTimeout(Q.timeoutId),Q.timeoutId=null)},[]),K=i.useCallback(Q=>{f.current.splice(0,f.current.length).forEach($=>{Z($),q($.payload,Q)})},[Z,q]),V=i.useCallback(Q=>{if(Q.readyState!==WebSocket.OPEN)return;f.current.splice(0,f.current.length).forEach($=>{Z($),Q.send(JSON.stringify($.payload))})},[Z]),T=i.useCallback(Q=>{if(!Q||typeof Q!="object"||Q.clientRequestId)return Q;const b=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...Q,clientRequestId:b}},[]),Y=i.useCallback(()=>{if(t.current||m.current)return;const Q=e.current;if(!(Q&&(Q.readyState===WebSocket.OPEN||Q.readyState===WebSocket.CONNECTING)))try{const b=Vk(N);if(!b){f.current.splice(0,f.current.length).forEach(ee=>{Z(ee),q(ee.payload,"No authentication token found for WebSocket connection")});return}m.current=!0,c("connecting");const $=new WebSocket(b);e.current=$,$.onopen=()=>{m.current=!1,u.current=0,a(!0),c("connected"),e.current=$,z({type:"ws-connection-state",state:"connected",reconnectedAt:new Date().toISOString()}),V($)},$.onmessage=L=>{try{const ee=JSON.parse(L.data);z(ee)}catch(ee){console.error("Error parsing WebSocket message:",ee)}},$.onclose=()=>{const L=e.current===$;if(!L&&e.current){p.current&&(p.current=!1);return}if(m.current=!1,a(!1),c("disconnected"),L&&(e.current=null),z({type:"ws-connection-state",state:"disconnected"}),p.current){p.current=!1;return}if(!Hk(u.current)){c("failed"),z({type:"ws-connection-state",state:"failed"}),K("Unable to reach the chat server. Reconnect attempts stopped.");return}u.current+=1;const ee=Kk(u.current);d.current=setTimeout(()=>{t.current||Y()},ee)},$.onerror=L=>{console.error("WebSocket error:",L)}}catch(b){m.current=!1,c("failed"),console.error("Error creating WebSocket connection:",b)}},[Z,q,K,V,N]);i.useEffect(()=>(t.current=!1,Y(),()=>{m.current=!1,d.current&&clearTimeout(d.current),v.current&&(clearTimeout(v.current),v.current=null),y.current=[],e.current&&(p.current=!0,e.current.close(),e.current=null)}),[Y,N]),i.useEffect(()=>()=>{t.current=!0,m.current=!1,d.current&&clearTimeout(d.current),v.current&&(clearTimeout(v.current),v.current=null),y.current=[],f.current.splice(0,f.current.length).forEach(b=>Z(b)),e.current&&(p.current=!0,e.current.close(),e.current=null)},[Z]);const D=i.useCallback(Q=>{const b=T(Q),$=e.current;if($&&$.readyState===WebSocket.OPEN){try{$.send(JSON.stringify(b))}catch(ee){throw ee}return}if(z({type:"ws-connection-state",state:"connecting",sessionId:b?.sessionId||b?.options?.sessionId||null,clientRequestId:b?.clientRequestId||null}),!Wk(b)){q(b,"Unable to reach the chat server. Message was not sent."),Y();return}const L={payload:b,timeoutId:setTimeout(()=>{f.current=f.current.filter(ee=>ee!==L),q(b,"Unable to reach the chat server. Message was not sent.")},1e4)};f.current.push(L),Y()},[Y,q,z,T]);return i.useMemo(()=>({ws:e.current,sendMessage:D,latestMessage:n,isConnected:s,connectionState:l}),[D,n,s,l])},Jk=({children:e})=>{const t=Qk();return r.jsx(Op.Provider,{value:t,children:e})};function Yk(){const{t:e}=Ot("common"),{authenticateLanAccess:t,error:n}=Ui(),[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 r.jsxs("div",{className:"relative h-dvh overflow-hidden bg-background text-foreground",children:[r.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%)]"}),r.jsx("div",{className:"relative flex h-full items-center justify-center overflow-hidden p-4 sm:p-5",children:r.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:[r.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[r.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:r.jsx(Ma,{className:"h-6 w-6"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-xl font-semibold",children:e("lanAccess.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:e("lanAccess.subtitle")})]})]}),r.jsxs("form",{className:"space-y-4",onSubmit:c,children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-sm font-medium text-foreground",htmlFor:"lan-access-password",children:e("lanAccess.placeholder")}),r.jsxs("div",{className:"relative",children:[r.jsx(Ch,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx(or,{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"})]})]}),n?r.jsx("div",{className:"rounded-2xl border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:n}):r.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")}),r.jsx(Ge,{className:"h-12 w-full rounded-2xl text-base font-medium",disabled:a,children:e(a?"lanAccess.submitting":"lanAccess.submit")})]})]})})]})}const Xk=()=>r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("img",{src:"/logo-128.png",alt:"Logo",className:"w-16 h-16 rounded-lg shadow-sm"})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Axhub Genie"}),r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),r.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),Zk=({children:e})=>{const{user:t,isLoading:n}=Ui();return n?r.jsx(Xk,{}):t?e:r.jsx(Yk,{})};function Vr(e,t){const[n,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[n,a=>{if(!(typeof window>"u"))try{const l=a instanceof Function?a(n):a;window.localStorage.setItem(e,JSON.stringify(l)),o(l)}catch(l){console.log(l)}}]}const eS=3e3,tS=Object.freeze(["context.update","context.comments","prompt.update","presence.report"]);function Qr(e){return typeof e=="string"&&e.trim().length>0}function nS(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function rS(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function oS(){return[...tS]}function sS({enabled:e,channel:t,clientId:n,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(Qr(o)?o.trim():null),[m,p]=i.useState(null),[f,y]=i.useState(!1),v=i.useMemo(()=>e===!0&&Qr(t)&&Qr(n),[e,t,n]);i.useEffect(()=>{u.current=Qr(o)?o.trim():null},[o]);const _=i.useCallback(K=>{d.current+=1,p({...K,__messageSeq:d.current})},[]),N=i.useCallback(()=>{const K=s.current;K&&(K.close(),s.current=null),y(!1),l.current=!1},[]),E=i.useCallback((K,V=s.current)=>!K||!V||V.readyState!==WebSocket.OPEN?!1:(V.send(JSON.stringify({type:"integration.ack",requestId:K,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),z=i.useCallback((K=s.current)=>{!v||!K||K.readyState!==WebSocket.OPEN||K.send(JSON.stringify({type:"integration.connect",requestId:nS("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:n.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:Qr(o)?o.trim():null,capabilities:oS()}}))},[t,n,v,o]),q=i.useCallback(()=>{if(!v||c.current||l.current)return;const K=s.current;if(K&&(K.readyState===WebSocket.OPEN||K.readyState===WebSocket.CONNECTING))return;const V=rS();if(!V)return;l.current=!0;const T=new WebSocket(V);s.current=T,T.onopen=()=>{l.current=!1,s.current=T,y(!0),z(T)},T.onmessage=Y=>{try{const D=JSON.parse(Y.data);D&&typeof D.type=="string"&&D.type.startsWith("integration.")&&(D.type==="integration.ping"&&E(D.requestId||null,T),_(D))}catch(D){console.error("Error parsing integration WebSocket message:",D)}},T.onclose=()=>{s.current===T&&(s.current=null),l.current=!1,y(!1),!c.current&&v&&(a.current=setTimeout(()=>{a.current=null,q()},eS))},T.onerror=Y=>{console.error("Integration WebSocket error:",Y)}},[z,_,v,E]);i.useEffect(()=>{if(c.current=!1,!v){a.current&&(clearTimeout(a.current),a.current=null),N();return}return q(),()=>{a.current&&(clearTimeout(a.current),a.current=null),N()}},[N,q,v]),i.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),N()},[N]),i.useEffect(()=>{v&&z()},[z,v,o]);const Z=i.useCallback(K=>{const V=s.current;return!V||V.readyState!==WebSocket.OPEN?!1:(V.send(JSON.stringify(K)),!0)},[]);return{integrationWs:s.current,latestIntegrationMessage:m,sendIntegrationMessage:Z,isIntegrationConnected:f,isIntegrationEnabled:v}}const aS=["cwd","workdir","project","context","prompt","model","integrationWs"];function iS(e){return e instanceof URLSearchParams?e:typeof e=="string"?new URLSearchParams(e):new URLSearchParams}function Ws(e,t,n={},o={}){const s=typeof e=="string"&&e?e:"/",a=iS(t),l=new URLSearchParams,c=Array.isArray(o?.persistedKeys)&&o.persistedKeys.length>0?o.persistedKeys:aS;for(const u of c){const m=a.get(u);m&&l.set(u,m)}for(const[u,m]of Object.entries(n||{})){if(m==null||m===""){l.delete(u);continue}l.set(u,String(m))}const d=l.toString();return d?`${s}?${d}`:s}const lS="axhub",Fc="axhub-genie.integrationClientId";function Fp(e){return typeof e=="string"&&e.trim().length>0}function $c(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`frontend-${crypto.randomUUID()}`:`frontend-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function cS(e,t){return e!=="1"?null:Fp(t)?t.trim():lS}function dS(e,t=null){if(e!=="1")return null;const n=t&&typeof t.getItem=="function"&&typeof t.setItem=="function"?t:null;if(!n)return $c();const o=n.getItem(Fc);if(Fp(o))return o.trim();const s=$c();return n.setItem(Fc,s),s}function uS(){if(typeof window>"u")return null;try{return window.sessionStorage}catch{return null}}const pS=new Set(["claude","codex","gemini","opencode"]);function _s(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();if(!t)return null;const n=t==="openai"?"codex":t;return pS.has(n)?n:null}function $p({provider:e,sessionId:t}){const n=_s(e),o=typeof t=="string"&&t.trim()?t.trim():"";return!n||!o?null:`/session/${n}/${encodeURIComponent(o)}`}function mS(e){return Ws("/",e,{},{persistedKeys:["context","prompt","model","integrationWs"]})}function fS(e){return Ws("/",e,{},{persistedKeys:["integrationWs"]})}function zc(e,t){const n=$p(e);if(!n)return null;const o=e?.includeProjectContext!==!1,s=o&&(e?.projectPath||e?.cwd||e?.project)||null;return Ws(n,t,s?{cwd:s,project:s}:{},o?{}:{persistedKeys:["context","prompt","model","integrationWs"]})}function hS({isMobile:e,currentProjectName:t,sessionProjectName:n}){return e?n!==t:!1}const xS=3e4;function gS(e){return e instanceof Error&&e.message?e.message:String(e||"").trim()||"Failed to load project details"}function vS(e,t,n,o=Date.now()){return t?{...e||{},[t]:{message:gS(n),failedAt:o}}:e||{}}function Bc(e,t){if(!e?.[t])return e||{};const n={...e};return delete n[t],n}function yS(e,t){return e?.[t]||null}function Uc({project:e,loading:t,errors:n,now:o=Date.now(),retryCooldownMs:s=xS}){if(!e?.name||e.detailsLoaded||t?.[e.name])return!1;const a=yS(n,e.name);return a?.failedAt?o-a.failedAt>=s:!0}function bS(){const e=new Map;return{run(t,n){if(!t)return Promise.resolve(null);if(!e.has(t)){const o=Promise.resolve().then(n).finally(()=>{e.delete(t)});e.set(t,o)}return e.get(t)}}}function wS({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-[20rem]":"w-[4.25rem]"].filter(Boolean).join(" ")}function kS({sidebarVisible:e=!0}={}){return["h-full",e?"overflow-hidden":"overflow-visible"].join(" ")}function SS({isLoadingProjects:e,hasSelectedProject:t,hasSessionRoute:n,sessionRouteStatus:o,isBackendDisconnected:s=!1}){return t||s?!1:e?!0:!!(n&&o!=="missing"&&o!=="error")}function jS({requestToken:e,activeRequestToken:t,pathname:n,provider:o,sessionId:s}){if(!e||!t||e!==t||typeof n!="string"||typeof s!="string"||!s)return!1;const a=$p({provider:_s(o),sessionId:s});return!!(a&&n===a)}function CS({activeResolution:e,sessionId:t,resolutionKey:n}){return!e||typeof e!="object"?!0:!(e.sessionId===t&&e.status==="resolving"&&e.resolutionKey===n)}const NS=["axhubMidsceneBootstrap","axhubAuthToken","axhubProvider","axhubProviderModel","axhubAgentCommandOverrides","axhubRunSse"];function ES(){return typeof window>"u"?null:window}function IS(e){return String(e||"").trim().toLowerCase()}function AS(e){const t=new URL(e.toString());for(const n of NS)t.searchParams.delete(n);return t}function Un(e,t,n,o){!e||typeof e[t]!="function"||(arguments.length>=4?e[t](n,o):e[t](n))}function _S(e={}){const t=e.window||ES(),n=e.href||t?.location?.href||"";if(!n)return{applied:!1};let o;try{o=new URL(n)}catch{return{applied:!1}}const s=o.searchParams;if(s.get("axhubMidsceneBootstrap")!=="1")return{applied:!1};const a=e.localStorage||t?.localStorage,l=e.sessionStorage||t?.sessionStorage,c=e.history||t?.history,d=IS(s.get("axhubProvider")),u=s.get("axhubAuthToken")||"",m=s.get("axhubProviderModel")||"",p=s.get("axhubAgentCommandOverrides")||"",f=s.get("axhubRunSse")||"";u&&Un(a,"setItem","auth-token",u),d&&Un(a,"setItem","selected-provider",d),d&&m&&(Un(a,"setItem",`${d}-model`,m),Un(a,"setItem",`${d}-model-selection-source`,"manual")),p&&Un(a,"setItem","agent-command-overrides",p),f&&Un(a,"setItem","chat-run-sse-enabled",f==="0"||f==="false"?"false":"true"),Un(a,"removeItem","lastSelectedSession"),l&&typeof l.clear=="function"&&l.clear(),Un(l,"setItem","axhub-chat-debug","1"),t&&(t.__AXHUB_CHAT_DEBUG_MODE__=!0);const y=AS(o);return c&&typeof c.replaceState=="function"&&c.replaceState(null,"",`${y.pathname}${y.search}${y.hash}`),{applied:!0,provider:d,url:o.toString(),cleanedUrl:y.toString()}}const qc="lastSelectedProject",Wc="lastSelectedSession",RS=Rt.lazy(()=>Lm(()=>import("./ImagePlaygroundPage-DqhMSbM8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));_S();function PS(){return r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background text-foreground",children:r.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading image playground..."})})}function TS(e){return!e||typeof e!="object"?[]:[...e.sessions||[],...e.codexSessions||[],...e.geminiSessions||[],...e.opencodeSessions||[]]}function zp(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 Kc(e,t=null){const n=!!t?.detailsLoaded;return{...e,detailsLoaded:n,sessions:n?t?.sessions||[]:[],codexSessions:n?t?.codexSessions||[]:[],geminiSessions:n?t?.geminiSessions||[]:[],opencodeSessions:n?t?.opencodeSessions||[]:[],sessionMeta:n?t?.sessionMeta||{hasMore:!1,total:0}:null}}function Hc(e,t){const n=new Map(e.map(a=>[a.name,a])),o=t.map(a=>{const l=n.get(a.name);return l?zp(l,a)?Kc(a,l):l:Kc(a)});return o.length!==e.length||o.some((a,l)=>a!==e[l])?o:e}function MS(e,t){let n=!1;const o=e.map(s=>s.name!==t.name?s:(n=!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 n?o:e}function DS(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 LS(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 Gc(){const e=zm(),t=Bm(),{provider:n,sessionId:o}=Um(),[s]=qm(),{t:a}=Ot("common"),{isDarkMode:l}=ui();i.useRef(0);const{updateAvailable:c,latestVersion:d,currentVersion:u,releaseInfo:m}=Tp(),[p,f]=i.useState(!1),[y,v]=i.useState([]),[_,N]=i.useState(null),[E,z]=i.useState(null),[q,Z]=i.useState({}),[K,V]=i.useState({}),[T,Y]=i.useState(0),[D,oe]=i.useState("chat"),[Q,b]=i.useState(!1),$=Q&&!1,[L,ee]=i.useState(!1),[le,ve]=i.useState(!0),[ue,W]=i.useState(null),[Se,Ce]=i.useState(!1),[Ae,se]=i.useState(!1),[J,pe]=i.useState("appearance"),[xe,he]=i.useState(!1),[be]=Vr("autoExpandTools",!1),[je]=Vr("showRawParameters",!1),[Be]=Vr("showThinking",!0),Ve=!1,[He]=Vr("sendByCtrlEnter",!1),[nt,Pe]=Vr("sidebarVisible",!0),[lt,ct]=i.useState(!1),[Te,Je]=i.useState(new Set),[_e,Qe]=i.useState(new Set),Ke=i.useRef({sessionId:null,status:"idle"}),mt=i.useRef(0),[Xe,P]=i.useState("idle"),B=i.useRef(bS()),me=i.useCallback((A,G="claude")=>{if(!A)return G;try{const ne=localStorage.getItem("session-provider-map");if(!ne)return G;const Le=JSON.parse(ne)?.[A];return typeof Le=="string"&&Le?Le:G}catch{return G}},[]),[Fe,rt]=i.useState(0),fe=i.useRef({selectionKey:null}),g=i.useRef({attemptedKeys:new Set}),ie=i.useRef(y),Ne=i.useRef(_),de=i.useRef(E),Oe=s.get("cwd")||s.get("workdir"),Me=!!(s.get("cwd")||s.get("workdir")||s.get("project")||s.get("projectName")),$e=i.useMemo(()=>rr(Oe),[Oe]),De=s.get("project")||s.get("projectName"),it=s.get("provider"),ge=Pi({basename:typeof window<"u"&&window.__ROUTER_BASENAME__||"",returnPath:typeof window<"u"?Ri(window.location):"",projectPath:_?.fullPath||_?.path||Oe||De}),Re=i.useMemo(()=>_s(n),[n]),Et=Re||_s(it);s.get("model");const st=s.get("context"),j=s.get("prompt"),M=s.get("integrationWs"),H=i.useMemo(()=>uS(),[]),ae=i.useMemo(()=>dS(M,H),[H,M]),Ie=i.useMemo(()=>cS(M,Oe),[Oe,M]),te=s.toString(),ut=y.find(A=>!!(so(A,$e)||De&&(A.fullPath===De||A.path===De)))?.name||null,gt=i.useMemo(()=>qv({updateAvailable:c}),[c]),C=(A,G)=>!A||!G?A!==G:zp(A,G)||!!A.detailsLoaded!=!!G.detailsLoaded,w=A=>{if(!A)return!1;if(o===A)return!0;const G=Ke.current;return G?.sessionId===A&&G?.status!=="missing"&&G?.status!=="error"?!0:Te.has(A)||_e.has(A)},x=i.useCallback(A=>{if(!A?.name)return;const G=Ne.current,ne=de.current;if(G?.name===A.name&&G!==A&&(C(G,A)||!G.detailsLoaded&&A.detailsLoaded)&&N(A),!ne||ne.__projectName!==A.name||!A.detailsLoaded)return;const Ee=TS(A).find(Ye=>Ye.id===ne.id);if(!Ee){w(ne.id)||z(null);return}const Le={...Ee,__provider:ne.__provider||me(Ee.id,"claude"),__projectName:A.name};(Le.title!==ne.title||Le.summary!==ne.summary||Le.updated_at!==ne.updated_at||Le.lastActivity!==ne.lastActivity||Le.__provider!==ne.__provider||Le.__projectName!==ne.__projectName)&&z(Le)},[me,w]),I=i.useCallback(async(A,G={})=>{const{background:ne=!1,force:Ee=!1}=G;return A?B.current.run(A,async()=>{const Le=ie.current.find(Ye=>Ye.name===A);if(!Ee&&Le?.detailsLoaded)return Le;Z(Ye=>Ye[A]?Ye:{...Ye,[A]:!0}),V(Ye=>Bc(Ye,A));try{const Ye=await et.projectDetails(A);if(!Ye.ok){if(Ye.status===404)return v(Mt=>Mt.filter(jt=>jt.name!==A)),null;throw new Error(`Failed to load project details: ${Ye.status}`)}const dt=await Ye.json();v(Mt=>MS(Mt,dt)),V(Mt=>Bc(Mt,A));const $t={...Le,...dt,detailsLoaded:!0};return x($t),$t}catch(Ye){return console.error(`Error loading details for project ${A}:`,Ye),V(dt=>vS(dt,A,Ye)),null}finally{Z(Ye=>{if(!Ye[A])return Ye;const dt={...Ye};return delete dt[A],dt})}}):null},[x]),S=i.useCallback(async(A={})=>{const{background:G=!1,force:ne=!1}=A;try{G||ve(!0);const Le=await(await et.projectsList({force:ne})).json();v(Ye=>Hc(Ye,Le))}catch(Ee){console.error("Error fetching projects:",Ee)}finally{G||ve(!1)}},[]),U=i.useCallback((A,G)=>{const ne=Ws(A,s);t(ne,G)},[t,s]),ce=i.useCallback(A=>{const G=mS(s);t(G,A)},[t,s]),ze=i.useCallback((A,G)=>{const ne=zc(A,s);return ne?(t(ne,G),!0):(console.warn("Skipping session navigation because provider or session id is missing.",A),!1)},[t,s]),ft=i.useCallback(()=>{mt.current+=1,Ke.current={sessionId:null,status:"idle"},P("idle")},[]),{ws:Ue,sendMessage:St,latestMessage:Ct,connectionState:Kt}=Gk(),{latestIntegrationMessage:X,sendIntegrationMessage:Ht}=sS({enabled:M==="1",clientId:ae,channel:Ie,sessionId:E?.id||o||null}),jn=i.useCallback(A=>eo(A),[]),Ft=i.useRef(null),[en,gn]=i.useState(!1);i.useEffect(()=>{const A=Pp(D);A!==D&&oe(A)},[D]),i.useEffect(()=>{const A=()=>{const G=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");gn(G),document.addEventListener("touchstart",{}),G?(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 A(),window.matchMedia("(display-mode: standalone)").addEventListener("change",A),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",A)}},[]),i.useEffect(()=>{const A=()=>{b(window.innerWidth<768)};return A(),window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]),i.useEffect(()=>{S({force:!0})},[S]),i.useEffect(()=>{o||ft()},[ft,o]),i.useEffect(()=>{ie.current=y},[y]),i.useEffect(()=>{Ne.current=_},[_]),i.useEffect(()=>{de.current=E},[E]),i.useEffect(()=>{try{const A=DS(_);A?localStorage.setItem(qc,JSON.stringify(A)):localStorage.removeItem(qc);const G=LS(E);G?localStorage.setItem(Wc,JSON.stringify(G)):localStorage.removeItem(Wc)}catch(A){console.warn("Failed to persist last selected project/session:",A)}},[_,E]),i.useEffect(()=>{if(!$e&&!De||y.length===0)return;const A=`${$e||""}::${De||""}`;if(fe.current.selectionKey===A)return;if(E){fe.current.selectionKey=A;return}let G=null;if($e&&(G=y.find(ne=>so(ne,$e))),!G&&De){const ne=De.trim().toLowerCase();G=y.find(Ee=>[Ee.name,Ee.displayName,Ee.path,Ee.fullPath].some(Ye=>typeof Ye=="string"&&Ye.toLowerCase()===ne))}G&&N(G),fe.current.selectionKey=A},[$e,De,y,E]),i.useEffect(()=>{if(!_?.name||y.length===0)return;const A=y.find(G=>G.name===_.name);if(!A){!o&&!$e&&!De&&(N(null),E?.__projectName===_.name&&z(null));return}A!==_&&C(_,A)&&N(A),Uc({project:A,loading:q,errors:K})&&I(A.name,{background:!0})},[I,$e,K,q,y,De,_,E?.__projectName,o]),i.useEffect(()=>{if(!$e||le||E||ie.current.some(Le=>so(Le,$e)))return;const G=`cwd:${$e}`;if(g.current.attemptedKeys.has(G))return;g.current.attemptedKeys.add(G);let ne=!1;return(async()=>{try{const Le=await et.createProject($e),Ye=await Le.json().catch(()=>({}));if(!Le.ok){const dt=Ye?.error||"Unknown error";if(dt.includes("Project already configured")){await S({force:!0});return}console.warn(`[URL] Failed to auto-create project for cwd "${$e}": ${dt}`);return}if(ne)return;Ye?.project&&N(Ye.project),await S({force:!0})}catch(Le){console.error(`[URL] Error auto-creating project for cwd "${$e}":`,Le)}})(),()=>{ne=!0}},[$e,le,E]),i.useEffect(()=>{if(Ct){if(Ct.type==="loading_progress"){Ft.current&&(clearTimeout(Ft.current),Ft.current=null),W(Ct),Ct.phase==="complete"&&(Ft.current=setTimeout(()=>{W(null),Ft.current=null},500));return}if(Ct.type==="projects_updated"){if(Ct.changedFile&&E&&_){const yn=Ct.changedFile.replace(/\\/g,"/").split("/"),pt=yn[yn.length-1]||"",Rn=pt.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]||pt.replace(".jsonl","");(Ct.changedSessionId||Rn)===E.id&&(Te.has(E.id)||rt(zn=>zn+1))}const A=Array.isArray(Ct.projects)?Ct.projects:[];v(jt=>Hc(jt,A));const G=Ne.current,ne=de.current,Ee=G?A.find(jt=>jt.name===G.name):null;if(G&&!Ee&&!w(ne?.id)){N(null),z(null);return}const Le=ne&&Te.has(ne.id)||Te.size>0&&Array.from(Te).some(jt=>eo(jt)),Ye=Ct.affectedProjectName||null;if(!!!((Ye?ie.current.find(jt=>jt.name===Ye&&jt.detailsLoaded):null)&&Ct.requiresDetailsRefresh))return;const Mt=G?.name===Ye;if(Le&&Mt)return;I(Ye,{background:!0,force:!0})}}return()=>{Ft.current&&(clearTimeout(Ft.current),Ft.current=null)}},[Te,Ct,I,_e,_,E,o,w]),window.refreshProjects=(A={})=>S({background:!0,force:!0,...A}),window.openSettings=i.useCallback((A="appearance")=>{pe(A),se(!0)},[]),i.useEffect(()=>{if(!o)return;const A=E?.id||null,G=A!==o;if(!Re){Ke.current={sessionId:o,status:"error"},P("error");return}const ne=`${o}::${te}`,Ee=jn(o),Le=Uu({projects:y,queryProject:De,queryCwd:$e}),Ye=(pt,Rn,Dt)=>{if(!pt||!Rn)return!1;const $n=y.find(Pt=>Pt.name===pt.name)||pt,zt={...Rn,__provider:Dt||Re,__projectName:$n.name};return N(Pt=>Pt?.name===$n.name?Pt:$n),z(Pt=>Pt?.id===zt.id&&Pt?.__provider===zt.__provider&&Pt?.__projectName===zt.__projectName?Pt:zt),I($n.name,{background:!0}),G&&oe("chat"),Ke.current={sessionId:o,status:"resolved",resolutionKey:ne},P("resolved"),!0};if(A===o&&_?.name&&(!E?.__provider||E.__provider===Re)){Ke.current={sessionId:o,status:"resolved",resolutionKey:ne},P("resolved"),G&&oe("chat");return}const dt=Cy(y,o,{provider:Re,projectPath:De||$e||null});if(dt){Ye(dt.project,dt.session,dt.provider);return}if(Ny({projects:y,queryProject:De,queryCwd:$e})){Uc({project:Le,loading:q,errors:K})&&I(Le.name,{background:!0}),Ke.current={sessionId:o,status:"awaiting-project-details",resolutionKey:ne},P("awaiting-project-details");return}const $t=Le;if($t?(N(pt=>pt?.name===$t.name?pt:$t),z({id:o,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:Re,__projectName:$t.name}),G&&oe("chat"),Ke.current={sessionId:o,status:"placeholder",resolutionKey:ne},P("placeholder")):(N(null),z(null)),Ee||Ke.current.sessionId===o&&Ke.current.status==="resolving"&&Ke.current.resolutionKey===ne)return;const Mt=mt.current+1;mt.current=Mt,Ke.current={sessionId:o,status:"resolving",resolutionKey:ne},P("resolving");let jt=!1;return(async()=>{try{const pt=$t?.fullPath||$t?.path||De||$e||null,Rn=await et.resolveSession(Re,o,pt),Dt=await Rn.json().catch(()=>({}));if(jt||!jS({requestToken:Mt,activeRequestToken:mt.current,pathname:e.pathname,provider:Re,sessionId:o}))return;if(!Rn.ok||!Dt?.found||!Dt?.project||!Dt?.session){Ke.current={sessionId:o,status:"missing",resolutionKey:ne},P("missing");return}if(Dt?.provider)try{const Pt=localStorage.getItem("session-provider-map"),Dr=Pt?JSON.parse(Pt):{};Dr[o]=Dt.provider,localStorage.setItem("session-provider-map",JSON.stringify(Dr))}catch{}if(!Ye(Dt.project,Dt.session,Dt.provider||Re))return;const zn=zc({provider:Dt.provider||Re,sessionId:o},s),zt=`${window.location.pathname}${window.location.search}`;zn&&zn!==zt&&t(zn,{replace:!0})}catch(pt){jt||(console.error("Error resolving session route:",pt),Ke.current={sessionId:o,status:"error",resolutionKey:ne},P("error"))}})(),()=>{CS({activeResolution:Ke.current,sessionId:o,resolutionKey:ne})&&(jt=!0)}},[jn,I,e.pathname,t,$e,K,q,y,De,Re,s,te,E?.id,o]);const vn=A=>{ft(),N(A),z(null),I(A.name,{background:!0}),t(fS(s))},tn=A=>{ft();let G=null;A.__projectName&&(G=ie.current.find(ne=>ne.name===A.__projectName)||null,G&&N(G)),z(A),D!=="preview"&&oe("chat"),hS({isMobile:Q,sessionProjectName:A.__projectName,currentProjectName:_?.name})&&ee(!1),ze({provider:A.__provider||A.provider||null,sessionId:A.id})},Ze=A=>{if(ft(),A?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${A.name}`),localStorage.removeItem(`draft_input_${A.name}`)}catch(G){console.warn("Failed to clear local chat cache for new session:",G)}N(A),z(null),Y(G=>G+1),oe("chat"),ce(),Q&&ee(!1)},Gt=A=>{E?.id===A&&(ft(),z(null),U("/")),v(G=>G.map(ne=>({...ne,sessions:ne.sessions?.filter(Ee=>Ee.id!==A)||[],codexSessions:ne.codexSessions?.filter(Ee=>Ee.id!==A)||[],geminiSessions:ne.geminiSessions?.filter(Ee=>Ee.id!==A)||[],opencodeSessions:ne.opencodeSessions?.filter(Ee=>Ee.id!==A)||[],sessionMeta:ne.sessionMeta?{...ne.sessionMeta,total:Math.max(0,(ne.sessionMeta?.total||0)-1)}:ne.sessionMeta})))},ke=async()=>{try{await S({background:!0,force:!0});const A=Array.from(new Set([...ie.current.filter(G=>G.detailsLoaded).map(G=>G.name),Ne.current?.name||null].filter(Boolean)));await Promise.all(A.map(G=>I(G,{background:!0,force:!0})))}catch(A){console.error("Error refreshing sidebar:",A)}},Pr=A=>{_?.name===A&&(ft(),N(null),z(null),U("/")),v(G=>G.filter(ne=>ne.name!==A))},dr=i.useCallback((A,G)=>{v(ne=>ne.map(Ee=>Ee.name===A?{...Ee,displayName:G,isCustomName:!0}:Ee)),N(ne=>!ne||ne.name!==A?ne:{...ne,displayName:G,isCustomName:!0})},[]),Ks=i.useCallback(A=>{A&&Je(G=>new Set([...G,A]))},[]),Tr=i.useCallback(A=>{A&&Je(G=>{const ne=new Set(G);return ne.delete(A),ne})},[]),Fn=i.useCallback(A=>{A&&Qe(G=>new Set([...G,A]))},[]),Hs=i.useCallback(A=>{A&&Qe(G=>{const ne=new Set(G);return ne.delete(A),ne})},[]),Mr=i.useCallback((A,G=null)=>{A&&(Je(ne=>{const Ee=new Set;for(const Le of ne)G&&Le===G||eo(Le)||Ee.add(Le);return Ee.add(A),Ee}),Qe(ne=>{const Ee=new Set;for(const Le of ne)G&&Le===G||eo(Le)||Ee.add(Le);return Ee.add(A),Ee}))},[]),an=()=>{const{t:A}=Ot("common"),[G,ne]=i.useState(!1),[Ee,Le]=i.useState(""),[Ye,dt]=i.useState("");if(!p)return null;const $t=jt=>jt?jt.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,`
|
|
264
|
+
|
|
265
|
+
`).trim():"",Mt=async()=>{ne(!0),Le(`Starting update...
|
|
266
|
+
`),dt("");try{const jt=await Zt("/api/system/update",{method:"POST"}),yn=await jt.json();jt.ok?(Le(pt=>pt+yn.output+`
|
|
267
|
+
`),Le(pt=>pt+`
|
|
268
|
+
✅ Update completed successfully!
|
|
269
|
+
`),Le(pt=>pt+`Please restart the server to apply changes.
|
|
270
|
+
`)):(dt(yn.error||"Update failed"),Le(pt=>pt+`
|
|
271
|
+
❌ Update failed: `+(yn.error||"Unknown error")+`
|
|
272
|
+
`))}catch(jt){dt(jt.message),Le(yn=>yn+`
|
|
273
|
+
❌ Update failed: `+jt.message+`
|
|
274
|
+
`)}finally{ne(!1)}};return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>f(!1),"aria-label":A("versionUpdate.ariaLabels.closeModal")}),r.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-2xl mx-4 p-6 space-y-4 max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-primary/15 dark:bg-primary/25 rounded-lg flex items-center justify-center",children:r.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:A("versionUpdate.title")}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:m?.title||A("versionUpdate.newVersionReady")})]})]}),r.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:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:A("versionUpdate.currentVersion")}),r.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:u})]}),r.jsxs("div",{className:"flex justify-between items-center p-3 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/50",children:[r.jsx("span",{className:"text-sm font-medium text-primary",children:A("versionUpdate.latestVersion")}),r.jsx("span",{className:"text-sm text-primary font-mono",children:d})]})]}),m?.body&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:A("versionUpdate.whatsNew")}),m?.htmlUrl&&r.jsxs("a",{href:m.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:text-primary hover:underline flex items-center gap-1",children:[A("versionUpdate.viewFullRelease"),r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 border border-gray-200 dark:border-gray-600 max-h-64 overflow-y-auto",children:r.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap prose prose-sm dark:prose-invert max-w-none",children:$t(m.body)})})]}),Ee&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:A("versionUpdate.updateProgress")}),r.jsx("div",{className:"bg-gray-900 dark:bg-gray-950 rounded-lg p-4 border border-gray-700 max-h-48 overflow-y-auto",children:r.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap",children:Ee})})]}),!G&&!Ee&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:A("versionUpdate.manualUpgrade")}),r.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:r.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"npm install -g @axhub/genie@latest"})}),r.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:A("versionUpdate.manualUpgradeHint")})]}),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.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:A(Ee?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!Ee&&r.jsxs(r.Fragment,{children:[r.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:A("versionUpdate.buttons.copyCommand")}),r.jsx("button",{onClick:Mt,disabled:G,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:G?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),A("versionUpdate.buttons.updating")]}):A("versionUpdate.buttons.updateNow")})]})]})]})]})};return r.jsxs("div",{className:"chat-app-shell fixed inset-0 flex overflow-hidden bg-background",style:{"--mobile-nav-total":"0px"},children:[!Q&&r.jsx("div",{className:wS({sidebarVisible:nt}),children:r.jsx("div",{className:kS({sidebarVisible:nt}),children:nt?r.jsx(Rl,{projects:y,selectedProject:_,selectedSession:E,onProjectSelect:vn,onProjectRename:dr,onSessionSelect:tn,onNewSession:Ze,onSessionDelete:Gt,onProjectDelete:Pr,isLoading:le,projectDetailsLoading:q,projectDetailsErrors:K,loadingProgress:ue,onProjectExpand:I,onRefresh:ke,onShowSettings:()=>se(!0),updateAvailable:c,latestVersion:d,currentVersion:u,releaseInfo:m,onShowVersionModal:()=>f(!0),isPWA:en,isMobile:Q,onToggleSidebar:()=>Pe(!1),lockedProjectName:ut,showNewProject:lt,setShowNewProject:ct,onOpenCcConnectDialog:()=>he(!0)}):r.jsx("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:gt.map(A=>{const G=_||y[0]||null,ne="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(A===xt.SHOW_SIDEBAR)return r.jsx("button",{onClick:()=>Pe(!0),className:ne,"aria-label":a("versionUpdate.ariaLabels.showSidebar"),title:a("versionUpdate.ariaLabels.showSidebar"),children:r.jsx(hi,{className:"w-4 h-4"})},A);if(A===xt.NEW_SESSION)return r.jsx(un,{content:a("sidebar:sessions.newSession"),position:"right",delay:150,children:r.jsx("button",{onClick:()=>G&&Ze(G),className:ne,"aria-label":a("sidebar:sessions.newSession"),title:a("sidebar:sessions.newSession"),disabled:!G||le,children:r.jsx(fo,{className:"w-4 h-4"})})},A);if(A===xt.REMOTE_ACCESS)return r.jsx(un,{content:a("sidebar:ccConnect.actions.open"),position:"right",delay:150,children:r.jsx("button",{onClick:()=>he(!0),className:ne,"aria-label":a("sidebar:ccConnect.actions.open"),title:a("sidebar:ccConnect.actions.open"),children:r.jsx(gi,{className:"w-4 h-4"})})},A);if(A===xt.IMAGE_PLAYGROUND)return r.jsx(un,{content:a("sidebar:imagePlayground.open"),position:"right",delay:150,children:r.jsx("a",{href:ge,className:ne,"aria-label":a("sidebar:imagePlayground.open"),title:a("sidebar:imagePlayground.open"),children:r.jsx(xi,{className:"w-4 h-4"})})},A);if(A===xt.THEME_TOGGLE){const Ee=a(l?"common.lightMode":"common.darkMode");return r.jsx(un,{content:Ee,position:"right",delay:150,children:r.jsx(_a,{variant:"icon",className:ne,title:Ee})},A)}return A===xt.UPDATE_AVAILABLE?r.jsxs("button",{onClick:()=>f(!0),className:ne,"aria-label":a("versionUpdate.ariaLabels.updateAvailable"),title:a("versionUpdate.ariaLabels.updateAvailable"),children:[r.jsx(Kf,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-primary animate-pulse"})]},A):null})})})}),Q&&r.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${L?"opacity-100 visible":"opacity-0 invisible"}`,children:[r.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:A=>{A.stopPropagation(),ee(!1)},onTouchStart:A=>{A.preventDefault(),A.stopPropagation(),ee(!1)},"aria-label":a("versionUpdate.ariaLabels.closeSidebar")}),r.jsx("div",{className:`chat-sidebar relative h-full w-[85vw] max-w-sm bg-white shadow-xl transform dark:bg-background sm:w-80 ${L?"translate-x-0":"-translate-x-full"}`,onClick:A=>A.stopPropagation(),onTouchStart:A=>A.stopPropagation(),children:r.jsx(Rl,{projects:y,selectedProject:_,selectedSession:E,onProjectSelect:vn,onProjectRename:dr,onSessionSelect:tn,onNewSession:Ze,onSessionDelete:Gt,onProjectDelete:Pr,isLoading:le,projectDetailsLoading:q,projectDetailsErrors:K,loadingProgress:ue,onProjectExpand:I,onRefresh:ke,onShowSettings:()=>se(!0),updateAvailable:c,latestVersion:d,currentVersion:u,releaseInfo:m,onShowVersionModal:()=>f(!0),isPWA:en,isMobile:Q,onToggleSidebar:()=>Pe(!1),lockedProjectName:ut,showNewProject:lt,setShowNewProject:ct,onOpenCcConnectDialog:()=>he(!0)})})]}),r.jsx(Lk,{open:xe,onOpenChange:he,selectedProject:_,projects:y}),r.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:r.jsx(uk,{selectedProject:_,selectedSession:E,routeProvider:Et,activeTab:D,setActiveTab:oe,ws:Ue,sendMessage:St,latestMessage:Ct,isMobile:Q,isPWA:en,onMenuClick:()=>ee(!0),isLoading:SS({isLoadingProjects:le,hasSelectedProject:!!_,hasSessionRoute:!!o,sessionRouteStatus:Xe,isBackendDisconnected:Kt==="failed"}),onInputFocusChange:Ce,onSessionActive:Ks,onSessionInactive:Tr,onSessionProcessing:Fn,onSessionNotProcessing:Hs,processingSessions:_e,onReplaceTemporarySession:Mr,onNavigateToSession:(A,G=null,ne=null)=>{const Ee=G||de.current?.__provider||localStorage.getItem("selected-provider")||"claude",Le=ne||_?.fullPath||_?.path||null,Ye=_?.name||null;z(dt=>dt?.id===A&&dt?.__provider===Ee&&dt?.__projectName===Ye?dt:{id:A,title:dt?.title||"New Session",created_at:dt?.created_at||new Date().toISOString(),updated_at:new Date().toISOString(),__provider:Ee,__projectName:Ye,projectPath:Le}),ze({provider:Ee,sessionId:A,projectPath:Le,includeProjectContext:Me})},onShowSettings:()=>se(!0),autoExpandTools:be,showRawParameters:je,showThinking:Be,autoScrollToBottom:Ve,sendByCtrlEnter:He,externalMessageUpdate:Fe,urlContext:st,urlPrompt:j,integrationClientId:ae,latestIntegrationMessage:X,sendIntegrationMessage:Ht,onShowNewProject:()=>ct(!0),onNewSession:Ze,newSessionResetNonce:T})}),$,r.jsx(wk,{isOpen:Ae,onClose:()=>se(!1),projects:y,initialTab:J}),r.jsx(an,{})]})}function OS(){return r.jsx(Uf,{i18n:Dm,children:r.jsx(qf,{children:r.jsx($k,{children:r.jsx(Jk,{children:r.jsx(Zk,{children:r.jsx(Fm,{basename:window.__ROUTER_BASENAME__||"",children:r.jsxs($m,{children:[r.jsx(Qo,{path:"/",element:r.jsx(Gc,{})}),r.jsx(Qo,{path:"/session/:provider/:sessionId",element:r.jsx(Gc,{})}),r.jsx(Qo,{path:"/review",element:r.jsx(Wf,{})}),r.jsx(Qo,{path:"/image-playground",element:r.jsx(i.Suspense,{fallback:r.jsx(PS,{}),children:r.jsx(RS,{})})})]})})})})})})})}const QS=Object.freeze(Object.defineProperty({__proto__:null,default:OS},Symbol.toStringTag,{value:"Module"}));export{QS as A,Vv as a,VS as g};
|