@axhub/genie 0.2.7 → 0.2.8
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-CTKZtqB1.js +460 -0
- package/dist/assets/App-qxJ8_QYu.css +32 -0
- package/dist/assets/ReviewApp-DM6BNAzR.js +1 -0
- package/dist/assets/{_basePickBy-C19AekOu.js → _basePickBy-CqJbRZ9y.js} +1 -1
- package/dist/assets/{_baseUniq-JsnevLw_.js → _baseUniq-BS8YH8jO.js} +1 -1
- package/dist/assets/{arc-BLpcuBlf.js → arc-BBmKEN-S.js} +1 -1
- package/dist/assets/architectureDiagram-2XIMDMQ5-N5lcb82R.js +36 -0
- package/dist/assets/{blockDiagram-WCTKOSBZ-DQBLwsUS.js → blockDiagram-WCTKOSBZ-DTMwHuLn.js} +3 -3
- package/dist/assets/c4Diagram-IC4MRINW-BTKlkXI9.js +10 -0
- package/dist/assets/channel-1oJBvF-0.js +1 -0
- package/dist/assets/{chunk-4BX2VUAB-De63kbgc.js → chunk-4BX2VUAB-DUdoTxAc.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-DtTDDdM9.js → chunk-55IACEB6-Bm_92xe4.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-DHuwd8tw.js → chunk-FMBD7UC4-CGW0g62g.js} +1 -1
- package/dist/assets/{chunk-JSJVCQXG-BgytFtmO.js → chunk-JSJVCQXG-DYkTH3w1.js} +1 -1
- package/dist/assets/{chunk-KX2RTZJC-nZdp86aN.js → chunk-KX2RTZJC-C9oTlISU.js} +1 -1
- package/dist/assets/chunk-NQ4KR5QH-CM50ygWP.js +220 -0
- package/dist/assets/{chunk-QZHKN3VN-DvUQ3mnO.js → chunk-QZHKN3VN-7dzpYeNJ.js} +1 -1
- package/dist/assets/chunk-WL4C6EOR-Cm9nQrsr.js +189 -0
- package/dist/assets/classDiagram-VBA2DB6C-d5TeKFM4.js +1 -0
- package/dist/assets/classDiagram-v2-RAHNMMFH-d5TeKFM4.js +1 -0
- package/dist/assets/clone-CinxIlEu.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-Ccp_p0JZ.js +1 -0
- package/dist/assets/cytoscape.esm-2ZfV8NB5.js +331 -0
- package/dist/assets/{dagre-KLK3FWXG-CHYIvW47.js → dagre-KLK3FWXG-fBwTLUp9.js} +1 -1
- package/dist/assets/diagram-E7M64L7V-CeNVmFUp.js +24 -0
- package/dist/assets/{diagram-IFDJBPK2-Dzsiln_C.js → diagram-IFDJBPK2-CtavyLGa.js} +1 -1
- package/dist/assets/{diagram-P4PSJMXO-DKnGbUpE.js → diagram-P4PSJMXO-CpQTjQwc.js} +1 -1
- package/dist/assets/erDiagram-INFDFZHY-B8R5vwhd.js +70 -0
- package/dist/assets/{flowDiagram-PKNHOUZH-BAZ2-jKp.js → flowDiagram-PKNHOUZH-BvkVVwIQ.js} +4 -4
- package/dist/assets/ganttDiagram-A5KZAMGK-DOu3hSNa.js +292 -0
- package/dist/assets/{gitGraphDiagram-K3NZZRJ6-BflpyjGy.js → gitGraphDiagram-K3NZZRJ6-C7zT67YE.js} +1 -1
- package/dist/assets/{graph-suelaXFh.js → graph-D11wiwHo.js} +1 -1
- package/dist/assets/highlighted-body-TPN3WLV5-Babpthg-.js +1 -0
- package/dist/assets/index-DFxzgWoO.js +2 -0
- package/dist/assets/index-YCFGDVKw.css +1 -0
- package/dist/assets/{infoDiagram-LFFYTUFH-pfD1FA3p.js → infoDiagram-LFFYTUFH-BmA7IpQG.js} +1 -1
- package/dist/assets/ishikawaDiagram-PHBUUO56-BEquZd3E.js +70 -0
- package/dist/assets/journeyDiagram-4ABVD52K-BfemGz7f.js +139 -0
- package/dist/assets/{kanban-definition-K7BYSVSG-FWinmur1.js → kanban-definition-K7BYSVSG-CWja3mln.js} +5 -5
- package/dist/assets/{layout-vcz43XvZ.js → layout-BLUNf-PJ.js} +1 -1
- package/dist/assets/{linear-le4gc0vx.js → linear-DukIV_Xv.js} +1 -1
- package/dist/assets/mermaid-O7DHMXV3-SgtM28qI.js +1038 -0
- package/dist/assets/mindmap-definition-YRQLILUH-4UjqXITU.js +68 -0
- package/dist/assets/{pieDiagram-SKSYHLDU-C7PKDh3b.js → pieDiagram-SKSYHLDU-8AxqJd0M.js} +2 -2
- package/dist/assets/quadrantDiagram-337W2JSQ-D60m8V8r.js +7 -0
- package/dist/assets/requirementDiagram-Z7DCOOCP-zqh9jBVf.js +73 -0
- package/dist/assets/{sankeyDiagram-WA2Y5GQK-4gulcOP4.js → sankeyDiagram-WA2Y5GQK-CDZILTLI.js} +3 -3
- package/dist/assets/sequenceDiagram-2WXFIKYE-7BReFd0L.js +145 -0
- package/dist/assets/{stateDiagram-RAJIS63D-CB4Vl7qM.js → stateDiagram-RAJIS63D-HPTVdIG4.js} +1 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-DTUf5_gC.js +1 -0
- package/dist/assets/timeline-definition-YZTLITO2-CTVllFgr.js +61 -0
- package/dist/assets/{treemap-KZPCXAKY-DZSEE6Hz.js → treemap-KZPCXAKY-BtyxboJZ.js} +58 -58
- package/dist/assets/vendor-codemirror-Dz7_EqNA.js +39 -0
- package/dist/assets/vendor-react-Cpt6D04s.js +59 -0
- package/dist/assets/vendor-xterm-DfaPXD3y.js +66 -0
- package/dist/assets/{vennDiagram-LZ73GAT5-8E_G06fI.js → vennDiagram-LZ73GAT5-D96ZI6Mg.js} +4 -4
- package/dist/assets/xychartDiagram-JWTSCODW-eRk-39YO.js +7 -0
- package/dist/index.html +4 -4
- package/package.json +34 -33
- package/server/acp-runtime/client.js +82 -15
- package/server/acp-runtime/index.js +5 -16
- package/server/channels/runtime/AgentRuntimeAdapter.js +1 -10
- package/server/claude-sdk.js +1 -3
- package/server/cli.js +136 -0
- package/server/gemini-cli.js +1 -3
- package/server/index.js +86 -14
- package/server/openai-codex.js +1 -3
- package/server/opencode-cli.js +1 -3
- package/server/projects.js +128 -85
- package/server/routes/cc-connect.js +1131 -0
- package/server/routes/cli-auth.js +1 -73
- package/server/routes/commands.js +4 -9
- package/server/routes/projects.js +45 -24
- package/server/session-core/providerDiscovery.js +8 -3
- package/server/utils/ccConnectManager.js +390 -0
- package/server/utils/ccConnectState.js +575 -0
- package/server/utils/resolveCommandPath.js +71 -0
- package/server/utils/workspaceRoots.js +154 -0
- package/dist/assets/App-BWSqiXAT.js +0 -220
- package/dist/assets/App-DrlLKa8f.css +0 -1
- package/dist/assets/ReviewApp-nz3mbArg.js +0 -1
- package/dist/assets/architectureDiagram-2XIMDMQ5-CarjBOOv.js +0 -36
- package/dist/assets/c4Diagram-IC4MRINW-CGobwBIj.js +0 -10
- package/dist/assets/channel-DkFNxV_H.js +0 -1
- package/dist/assets/chunk-NQ4KR5QH-CMH6EDP2.js +0 -220
- package/dist/assets/chunk-WL4C6EOR-Dn7db_6t.js +0 -189
- package/dist/assets/classDiagram-VBA2DB6C-DtwCEe8S.js +0 -1
- package/dist/assets/classDiagram-v2-RAHNMMFH-DtwCEe8S.js +0 -1
- package/dist/assets/clone-C0lCEIEO.js +0 -1
- package/dist/assets/cose-bilkent-S5V4N54A-DD_nzqsz.js +0 -1
- package/dist/assets/cytoscape.esm-5J0xJHOV.js +0 -321
- package/dist/assets/diagram-E7M64L7V-TVdvHtGc.js +0 -24
- package/dist/assets/erDiagram-INFDFZHY-5Kw0bByo.js +0 -70
- package/dist/assets/ganttDiagram-A5KZAMGK-CsADFkcq.js +0 -292
- package/dist/assets/highlighted-body-OFNGDK62-CZrBMazC.js +0 -1
- package/dist/assets/index-B01NxbUv.css +0 -1
- package/dist/assets/index-DW5pGgQ_.js +0 -2
- package/dist/assets/ishikawaDiagram-PHBUUO56-ndm9snwO.js +0 -70
- package/dist/assets/journeyDiagram-4ABVD52K-HgF2t7z5.js +0 -139
- package/dist/assets/mermaid-GHXKKRXX-CK8m3lad.js +0 -870
- package/dist/assets/mindmap-definition-YRQLILUH-CNq9SKj4.js +0 -68
- package/dist/assets/quadrantDiagram-337W2JSQ-B7FnztNO.js +0 -7
- package/dist/assets/requirementDiagram-Z7DCOOCP-Bl_BM2Th.js +0 -73
- package/dist/assets/sequenceDiagram-2WXFIKYE-VEuJDwyJ.js +0 -145
- package/dist/assets/stateDiagram-v2-FVOUBMTO-C85ucl39.js +0 -1
- package/dist/assets/timeline-definition-YZTLITO2-BPGKhi7f.js +0 -61
- package/dist/assets/vendor-codemirror-CyOKkaQZ.js +0 -31
- package/dist/assets/vendor-react-CP4yFTs7.js +0 -8
- package/dist/assets/vendor-xterm-DfcmCpbH.js +0 -66
- package/dist/assets/xychartDiagram-JWTSCODW-CbBk50-O.js +0 -7
- package/server/acp-runtime/client.test.js +0 -688
- package/server/acp-runtime/session-store.test.js +0 -89
- package/server/cli.test.js +0 -76
- package/server/external-agent/service.test.js +0 -53
- package/server/external-agent/ws.test.js +0 -289
- package/shared/conversationEvents.test.js +0 -403
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import{j as r,S as gn,F as ms,T as Zi,P as el,E as tr,V as fs,a as $o,g as xu,D as yr,R as ts,G as Bo,W as zo,l as tl,h as oo,b as rl,C as yu,c as vu,d as bu,e as Vr,f as wu,i as ku,u as ju,k as Aa,s as Su,m as Nu,n as Cu,o as Eu,p as Au,q as _u,r as Iu,t as Tu,v as Mu,w as Du,x as Pu,y as Ru}from"./vendor-codemirror-Dz7_EqNA.js";import{a as l,c as Lu,R as Ct,d as Qn,g as nl,B as Ou,e as Fu,f as Ls,u as $u,h as Bu,i as zu}from"./vendor-react-Cpt6D04s.js";import{bJ as Ue,bK as Lr,bL as rs,bM as sl,bN as tt,bO as Yt,bP as hs,bQ as Wo,bR as or,bS as ol,bT as Wu,bU as Uu,bV as vr,bW as Hu,bX as qu,bY as Ku,bZ as Vu,b_ as Gu,b$ as Ju,c0 as Yu,c1 as Xu,c2 as Qu,c3 as Zu,c4 as yt,c5 as Uo,c6 as Et,c7 as ir,c8 as ep,c9 as Ge,ca as Ot,cb as Os,cc as ao,cd as io,ce as lo,cf as Zn,cg as co,ch as jr,ci as al,cj as Ho,ck as tp,cl as rp,cm as np,cn as sp,co as op,cp as ap,cq as ip,cr as lp,cs as cp,ct as dp,cu as up,cv as pp,cw as mp,cx as fp,cy as hp,cz as gp,cA as xp,cB as yp,cC as Or,cD as vp,cE as il,cF as qo,cG as bp,cH as _a,cI as wp,I as kp,T as jp,U as Sp}from"./mermaid-O7DHMXV3-SgtM28qI.js";import{r as Np,a as Cp,b as Ep}from"./vendor-xterm-DfaPXD3y.js";import{l as Ia,i as Ap}from"./index-DFxzgWoO.js";/**
|
|
2
|
+
* @license lucide-react v0.515.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const _p=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ip=Ue("arrow-down",_p);/**
|
|
7
|
+
* @license lucide-react v0.515.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Tp=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Mp=Ue("arrow-left",Tp);/**
|
|
12
|
+
* @license lucide-react v0.515.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Dp=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ll=Ue("chevron-left",Dp);/**
|
|
17
|
+
* @license lucide-react v0.515.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Pp=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],qr=Ue("chevron-right",Pp);/**
|
|
22
|
+
* @license lucide-react v0.515.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Rp=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ta=Ue("circle-check-big",Rp);/**
|
|
27
|
+
* @license lucide-react v0.515.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Lp=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],uo=Ue("download",Lp);/**
|
|
32
|
+
* @license lucide-react v0.515.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Op=[["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"}]],Mn=Ue("ellipsis",Op);/**
|
|
37
|
+
* @license lucide-react v0.515.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const Fp=[["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"}]],po=Ue("external-link",Fp);/**
|
|
42
|
+
* @license lucide-react v0.515.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const $p=[["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"}]],cl=Ue("eye",$p);/**
|
|
47
|
+
* @license lucide-react v0.515.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const Bp=[["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"}]],zp=Ue("eye-off",Bp);/**
|
|
52
|
+
* @license lucide-react v0.515.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const Wp=[["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"}]],Up=Ue("file-pen-line",Wp);/**
|
|
57
|
+
* @license lucide-react v0.515.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const Hp=[["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"}]],qp=Ue("file-plus-2",Hp);/**
|
|
62
|
+
* @license lucide-react v0.515.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const Kp=[["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"}]],Vp=Ue("file-search",Kp);/**
|
|
67
|
+
* @license lucide-react v0.515.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const Gp=[["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"}]],Mr=Ue("folder-open",Gp);/**
|
|
72
|
+
* @license lucide-react v0.515.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const Jp=[["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"}]],Ir=Ue("folder-plus",Jp);/**
|
|
77
|
+
* @license lucide-react v0.515.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const Yp=[["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"}]],Fs=Ue("folder",Yp);/**
|
|
82
|
+
* @license lucide-react v0.515.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const Xp=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],$s=Ue("git-branch",Xp);/**
|
|
87
|
+
* @license lucide-react v0.515.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const Qp=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Bs=Ue("git-commit-horizontal",Qp);/**
|
|
92
|
+
* @license lucide-react v0.515.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const Zp=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],em=Ue("grip-vertical",Zp);/**
|
|
97
|
+
* @license lucide-react v0.515.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const tm=[["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"}]],rm=Ue("hard-drive",tm);/**
|
|
102
|
+
* @license lucide-react v0.515.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const nm=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Ma=Ue("history",nm);/**
|
|
107
|
+
* @license lucide-react v0.515.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const sm=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],om=Ue("info",sm);/**
|
|
112
|
+
* @license lucide-react v0.515.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const am=[["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"}]],dl=Ue("key",am);/**
|
|
117
|
+
* @license lucide-react v0.515.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/const im=[["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"}]],ul=Ue("languages",im);/**
|
|
122
|
+
* @license lucide-react v0.515.0 - ISC
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the ISC license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/const lm=[["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"}]],Da=Ue("list-todo",lm);/**
|
|
127
|
+
* @license lucide-react v0.515.0 - ISC
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the ISC license.
|
|
130
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
+
*/const cm=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],pl=Ue("maximize-2",cm);/**
|
|
132
|
+
* @license lucide-react v0.515.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const dm=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]],um=Ue("message-square-plus",dm);/**
|
|
137
|
+
* @license lucide-react v0.515.0 - ISC
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the ISC license.
|
|
140
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/const pm=[["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"}]],mo=Ue("message-square",pm);/**
|
|
142
|
+
* @license lucide-react v0.515.0 - ISC
|
|
143
|
+
*
|
|
144
|
+
* This source code is licensed under the ISC license.
|
|
145
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
+
*/const mm=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],es=Ue("mic",mm);/**
|
|
147
|
+
* @license lucide-react v0.515.0 - ISC
|
|
148
|
+
*
|
|
149
|
+
* This source code is licensed under the ISC license.
|
|
150
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
+
*/const fm=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],hm=Ue("minimize-2",fm);/**
|
|
152
|
+
* @license lucide-react v0.515.0 - ISC
|
|
153
|
+
*
|
|
154
|
+
* This source code is licensed under the ISC license.
|
|
155
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
+
*/const gm=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],fo=Ue("moon",gm);/**
|
|
157
|
+
* @license lucide-react v0.515.0 - ISC
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the ISC license.
|
|
160
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
+
*/const xm=[["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"}]],Pa=Ue("pen-line",xm);/**
|
|
162
|
+
* @license lucide-react v0.515.0 - ISC
|
|
163
|
+
*
|
|
164
|
+
* This source code is licensed under the ISC license.
|
|
165
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
+
*/const ym=[["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"}]],Ra=Ue("pen",ym);/**
|
|
167
|
+
* @license lucide-react v0.515.0 - ISC
|
|
168
|
+
*
|
|
169
|
+
* This source code is licensed under the ISC license.
|
|
170
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
+
*/const vm=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Gr=Ue("plus",vm);/**
|
|
172
|
+
* @license lucide-react v0.515.0 - ISC
|
|
173
|
+
*
|
|
174
|
+
* This source code is licensed under the ISC license.
|
|
175
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
+
*/const bm=[["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"}]],La=Ue("qr-code",bm);/**
|
|
177
|
+
* @license lucide-react v0.515.0 - ISC
|
|
178
|
+
*
|
|
179
|
+
* This source code is licensed under the ISC license.
|
|
180
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
+
*/const wm=[["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"}]],Zt=Ue("refresh-cw",wm);/**
|
|
182
|
+
* @license lucide-react v0.515.0 - ISC
|
|
183
|
+
*
|
|
184
|
+
* This source code is licensed under the ISC license.
|
|
185
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
+
*/const km=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],jm=Ue("save",km);/**
|
|
187
|
+
* @license lucide-react v0.515.0 - ISC
|
|
188
|
+
*
|
|
189
|
+
* This source code is licensed under the ISC license.
|
|
190
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
+
*/const Sm=[["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"}]],Nm=Ue("settings",Sm);/**
|
|
192
|
+
* @license lucide-react v0.515.0 - ISC
|
|
193
|
+
*
|
|
194
|
+
* This source code is licensed under the ISC license.
|
|
195
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
+
*/const Cm=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Em=Ue("settings-2",Cm);/**
|
|
197
|
+
* @license lucide-react v0.515.0 - ISC
|
|
198
|
+
*
|
|
199
|
+
* This source code is licensed under the ISC license.
|
|
200
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
+
*/const Am=[["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"}]],_m=Ue("square-terminal",Am);/**
|
|
202
|
+
* @license lucide-react v0.515.0 - ISC
|
|
203
|
+
*
|
|
204
|
+
* This source code is licensed under the ISC license.
|
|
205
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
+
*/const Im=[["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"}]],Oa=Ue("star",Im);/**
|
|
207
|
+
* @license lucide-react v0.515.0 - ISC
|
|
208
|
+
*
|
|
209
|
+
* This source code is licensed under the ISC license.
|
|
210
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
+
*/const Tm=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ho=Ue("sun",Tm);/**
|
|
212
|
+
* @license lucide-react v0.515.0 - ISC
|
|
213
|
+
*
|
|
214
|
+
* This source code is licensed under the ISC license.
|
|
215
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
+
*/const Mm=[["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"}]],er=Ue("trash-2",Mm);/**
|
|
217
|
+
* @license lucide-react v0.515.0 - ISC
|
|
218
|
+
*
|
|
219
|
+
* This source code is licensed under the ISC license.
|
|
220
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
221
|
+
*/const Dm=[["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"}]],go=Ue("triangle-alert",Dm);/**
|
|
222
|
+
* @license lucide-react v0.515.0 - ISC
|
|
223
|
+
*
|
|
224
|
+
* This source code is licensed under the ISC license.
|
|
225
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
226
|
+
*/const Pm=[["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"}]],Rm=Ue("unlink",Pm);/**
|
|
227
|
+
* @license lucide-react v0.515.0 - ISC
|
|
228
|
+
*
|
|
229
|
+
* This source code is licensed under the ISC license.
|
|
230
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
231
|
+
*/const Lm=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Dn=Ue("upload",Lm);/**
|
|
232
|
+
* @license lucide-react v0.515.0 - ISC
|
|
233
|
+
*
|
|
234
|
+
* This source code is licensed under the ISC license.
|
|
235
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
236
|
+
*/const Om=[["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"}]],Fm=Ue("wifi",Om);/**
|
|
237
|
+
* @license lucide-react v0.515.0 - ISC
|
|
238
|
+
*
|
|
239
|
+
* This source code is licensed under the ISC license.
|
|
240
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
241
|
+
*/const $m=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ut=Ue("x",$m);function Bm(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:f,children:h,...g}=m,b=f?.[e]?.[d]||c,v=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:v,children:h})};u.displayName=a+"Provider";function p(m,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,zm(o,...t)]}function zm(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function ml(e){const t=Wm(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Hm);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Wm(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Km(o),c=qm(a,o.props);return o.type!==l.Fragment&&(c.ref=s?Lr(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Um=Symbol("radix.slottable");function Hm(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Um}function qm(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Km(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 Vm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xn=Vm.reduce((e,t)=>{const n=ml(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Gm(e,t){e&&Lu.flushSync(()=>e.dispatchEvent(t))}function Jm(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:f,children:h,...g}=m,b=f?.[e]?.[d]||c,v=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:v,children:h})};u.displayName=a+"Provider";function p(m,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,Ym(o,...t)]}function Ym(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Xm(e){const t=Qm(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(ef);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Qm(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=rf(o),c=tf(a,o.props);return o.type!==l.Fragment&&(c.ref=s?Lr(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Zm=Symbol("radix.slottable");function ef(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Zm}function tf(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function rf(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 nf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],fl=nf.reduce((e,t)=>{const n=Xm(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),zs="rovingFocusGroup.onEntryFocus",sf={bubbles:!1,cancelable:!0},yn="RovingFocusGroup",[xo,hl,of]=sl(yn),[af,gs]=Jm(yn,[of]),[lf,cf]=af(yn),gl=l.forwardRef((e,t)=>r.jsx(xo.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(xo.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(df,{...e,ref:t})})}));gl.displayName=yn;var df=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...m}=e,f=l.useRef(null),h=Yt(t,f),g=hs(a),[b,v]=Wo({prop:i,defaultProp:c??null,onChange:d,caller:yn}),[j,O]=l.useState(!1),C=or(u),L=hl(n),_=l.useRef(!1),[R,I]=l.useState(0);return l.useEffect(()=>{const k=f.current;if(k)return k.addEventListener(zs,C),()=>k.removeEventListener(zs,C)},[C]),r.jsx(lf,{scope:n,orientation:s,dir:g,loop:o,currentTabStopId:b,onItemFocus:l.useCallback(k=>v(k),[v]),onItemShiftTab:l.useCallback(()=>O(!0),[]),onFocusableItemAdd:l.useCallback(()=>I(k=>k+1),[]),onFocusableItemRemove:l.useCallback(()=>I(k=>k-1),[]),children:r.jsx(fl.div,{tabIndex:j||R===0?-1:0,"data-orientation":s,...m,ref:h,style:{outline:"none",...e.style},onMouseDown:tt(e.onMouseDown,()=>{_.current=!0}),onFocus:tt(e.onFocus,k=>{const q=!_.current;if(k.target===k.currentTarget&&q&&!j){const G=new CustomEvent(zs,sf);if(k.currentTarget.dispatchEvent(G),!G.defaultPrevented){const re=L().filter(de=>de.focusable),le=re.find(de=>de.active),K=re.find(de=>de.id===b),U=[le,K,...re].filter(Boolean).map(de=>de.ref.current);vl(U,p)}}_.current=!1}),onBlur:tt(e.onBlur,()=>O(!1))})})}),xl="RovingFocusGroupItem",yl=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:i,...c}=e,d=rs(),u=a||d,p=cf(xl,n),m=p.currentTabStopId===u,f=hl(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:b}=p;return l.useEffect(()=>{if(s)return h(),()=>g()},[s,h,g]),r.jsx(xo.ItemSlot,{scope:n,id:u,focusable:s,active:o,children:r.jsx(fl.span,{tabIndex:m?0:-1,"data-orientation":p.orientation,...c,ref:t,onMouseDown:tt(e.onMouseDown,v=>{s?p.onItemFocus(u):v.preventDefault()}),onFocus:tt(e.onFocus,()=>p.onItemFocus(u)),onKeyDown:tt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){p.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const j=mf(v,p.orientation,p.dir);if(j!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let C=f().filter(L=>L.focusable).map(L=>L.ref.current);if(j==="last")C.reverse();else if(j==="prev"||j==="next"){j==="prev"&&C.reverse();const L=C.indexOf(v.currentTarget);C=p.loop?ff(C,L+1):C.slice(L+1)}setTimeout(()=>vl(C))}}),children:typeof i=="function"?i({isCurrentTabStop:m,hasTabStop:b!=null}):i})})});yl.displayName=xl;var uf={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function pf(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function mf(e,t,n){const s=pf(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return uf[s]}function vl(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function ff(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var bl=gl,wl=yl,yo=["Enter"," "],hf=["ArrowDown","PageUp","Home"],kl=["ArrowUp","PageDown","End"],gf=[...hf,...kl],xf={ltr:[...yo,"ArrowRight"],rtl:[...yo,"ArrowLeft"]},yf={ltr:["ArrowLeft"],rtl:["ArrowRight"]},vn="Menu",[mn,vf,bf]=sl(vn),[Fr,jl]=Bm(vn,[bf,ol,gs]),xs=ol(),Sl=gs(),[wf,$r]=Fr(vn),[kf,bn]=Fr(vn),Nl=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:o,onOpenChange:a,modal:i=!0}=e,c=xs(t),[d,u]=l.useState(null),p=l.useRef(!1),m=or(a),f=hs(o);return l.useEffect(()=>{const h=()=>{p.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>p.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),r.jsx(Wu,{...c,children:r.jsx(wf,{scope:t,open:n,onOpenChange:m,content:d,onContentChange:u,children:r.jsx(kf,{scope:t,onClose:l.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:p,dir:f,modal:i,children:s})})})};Nl.displayName=vn;var jf="MenuAnchor",Ko=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=xs(n);return r.jsx(Uu,{...o,...s,ref:t})});Ko.displayName=jf;var Vo="MenuPortal",[Sf,Cl]=Fr(Vo,{forceMount:void 0}),El=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:o}=e,a=$r(Vo,t);return r.jsx(Sf,{scope:t,forceMount:n,children:r.jsx(vr,{present:n||a.open,children:r.jsx(Hu,{asChild:!0,container:o,children:s})})})};El.displayName=Vo;var Gt="MenuContent",[Nf,Go]=Fr(Gt),Al=l.forwardRef((e,t)=>{const n=Cl(Gt,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=$r(Gt,e.__scopeMenu),i=bn(Gt,e.__scopeMenu);return r.jsx(mn.Provider,{scope:e.__scopeMenu,children:r.jsx(vr,{present:s||a.open,children:r.jsx(mn.Slot,{scope:e.__scopeMenu,children:i.modal?r.jsx(Cf,{...o,ref:t}):r.jsx(Ef,{...o,ref:t})})})})}),Cf=l.forwardRef((e,t)=>{const n=$r(Gt,e.__scopeMenu),s=l.useRef(null),o=Yt(t,s);return l.useEffect(()=>{const a=s.current;if(a)return qu(a)},[]),r.jsx(Jo,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:tt(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ef=l.forwardRef((e,t)=>{const n=$r(Gt,e.__scopeMenu);return r.jsx(Jo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Af=ml("MenuContent.ScrollLock"),Jo=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:f,onDismiss:h,disableOutsideScroll:g,...b}=e,v=$r(Gt,n),j=bn(Gt,n),O=xs(n),C=Sl(n),L=vf(n),[_,R]=l.useState(null),I=l.useRef(null),k=Yt(t,I,v.onContentChange),q=l.useRef(0),G=l.useRef(""),re=l.useRef(0),le=l.useRef(null),K=l.useRef("right"),Z=l.useRef(0),U=g?Vu:l.Fragment,de=g?{as:Af,allowPinchZoom:!0}:void 0,ue=J=>{const _e=G.current+J,F=L().filter(te=>!te.disabled),ee=document.activeElement,ne=F.find(te=>te.ref.current===ee)?.textValue,xe=F.map(te=>te.textValue),fe=Bf(xe,_e,ne),be=F.find(te=>te.textValue===fe)?.ref.current;(function te(Se){G.current=Se,window.clearTimeout(q.current),Se!==""&&(q.current=window.setTimeout(()=>te(""),1e3))})(_e),be&&setTimeout(()=>be.focus())};l.useEffect(()=>()=>window.clearTimeout(q.current),[]),Ku();const ce=l.useCallback(J=>K.current===le.current?.side&&Wf(J,le.current?.area),[]);return r.jsx(Nf,{scope:n,searchRef:G,onItemEnter:l.useCallback(J=>{ce(J)&&J.preventDefault()},[ce]),onItemLeave:l.useCallback(J=>{ce(J)||(I.current?.focus(),R(null))},[ce]),onTriggerLeave:l.useCallback(J=>{ce(J)&&J.preventDefault()},[ce]),pointerGraceTimerRef:re,onPointerGraceIntentChange:l.useCallback(J=>{le.current=J},[]),children:r.jsx(U,{...de,children:r.jsx(Gu,{asChild:!0,trapped:o,onMountAutoFocus:tt(a,J=>{J.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:r.jsx(Ju,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:f,onDismiss:h,children:r.jsx(bl,{asChild:!0,...C,dir:j.dir,orientation:"vertical",loop:s,currentTabStopId:_,onCurrentTabStopIdChange:R,onEntryFocus:tt(d,J=>{j.isUsingKeyboardRef.current||J.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(Yu,{role:"menu","aria-orientation":"vertical","data-state":Hl(v.open),"data-radix-menu-content":"",dir:j.dir,...O,...b,ref:k,style:{outline:"none",...b.style},onKeyDown:tt(b.onKeyDown,J=>{const F=J.target.closest("[data-radix-menu-content]")===J.currentTarget,ee=J.ctrlKey||J.altKey||J.metaKey,ne=J.key.length===1;F&&(J.key==="Tab"&&J.preventDefault(),!ee&&ne&&ue(J.key));const xe=I.current;if(J.target!==xe||!gf.includes(J.key))return;J.preventDefault();const be=L().filter(te=>!te.disabled).map(te=>te.ref.current);kl.includes(J.key)&&be.reverse(),Ff(be)}),onBlur:tt(e.onBlur,J=>{J.currentTarget.contains(J.target)||(window.clearTimeout(q.current),G.current="")}),onPointerMove:tt(e.onPointerMove,fn(J=>{const _e=J.target,F=Z.current!==J.clientX;if(J.currentTarget.contains(_e)&&F){const ee=J.clientX>Z.current?"right":"left";K.current=ee,Z.current=J.clientX}}))})})})})})})});Al.displayName=Gt;var _f="MenuGroup",Yo=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(xn.div,{role:"group",...s,ref:t})});Yo.displayName=_f;var If="MenuLabel",_l=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(xn.div,{...s,ref:t})});_l.displayName=If;var ns="MenuItem",Fa="menu.itemSelect",ys=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...o}=e,a=l.useRef(null),i=bn(ns,e.__scopeMenu),c=Go(ns,e.__scopeMenu),d=Yt(t,a),u=l.useRef(!1),p=()=>{const m=a.current;if(!n&&m){const f=new CustomEvent(Fa,{bubbles:!0,cancelable:!0});m.addEventListener(Fa,h=>s?.(h),{once:!0}),Gm(m,f),f.defaultPrevented?u.current=!1:i.onClose()}};return r.jsx(Il,{...o,ref:d,disabled:n,onClick:tt(e.onClick,p),onPointerDown:m=>{e.onPointerDown?.(m),u.current=!0},onPointerUp:tt(e.onPointerUp,m=>{u.current||m.currentTarget?.click()}),onKeyDown:tt(e.onKeyDown,m=>{const f=c.searchRef.current!=="";n||f&&m.key===" "||yo.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});ys.displayName=ns;var Il=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:o,...a}=e,i=Go(ns,n),c=Sl(n),d=l.useRef(null),u=Yt(t,d),[p,m]=l.useState(!1),[f,h]=l.useState("");return l.useEffect(()=>{const g=d.current;g&&h((g.textContent??"").trim())},[a.children]),r.jsx(mn.ItemSlot,{scope:n,disabled:s,textValue:o??f,children:r.jsx(wl,{asChild:!0,...c,focusable:!s,children:r.jsx(xn.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...a,ref:u,onPointerMove:tt(e.onPointerMove,fn(g=>{s?i.onItemLeave(g):(i.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:tt(e.onPointerLeave,fn(g=>i.onItemLeave(g))),onFocus:tt(e.onFocus,()=>m(!0)),onBlur:tt(e.onBlur,()=>m(!1))})})})}),Tf="MenuCheckboxItem",Tl=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...o}=e;return r.jsx(Ll,{scope:e.__scopeMenu,checked:n,children:r.jsx(ys,{role:"menuitemcheckbox","aria-checked":ss(n)?"mixed":n,...o,ref:t,"data-state":Qo(n),onSelect:tt(o.onSelect,()=>s?.(ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Tl.displayName=Tf;var Ml="MenuRadioGroup",[Mf,Df]=Fr(Ml,{value:void 0,onValueChange:()=>{}}),Dl=l.forwardRef((e,t)=>{const{value:n,onValueChange:s,...o}=e,a=or(s);return r.jsx(Mf,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(Yo,{...o,ref:t})})});Dl.displayName=Ml;var Pl="MenuRadioItem",Rl=l.forwardRef((e,t)=>{const{value:n,...s}=e,o=Df(Pl,e.__scopeMenu),a=n===o.value;return r.jsx(Ll,{scope:e.__scopeMenu,checked:a,children:r.jsx(ys,{role:"menuitemradio","aria-checked":a,...s,ref:t,"data-state":Qo(a),onSelect:tt(s.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Rl.displayName=Pl;var Xo="MenuItemIndicator",[Ll,Pf]=Fr(Xo,{checked:!1}),Ol=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...o}=e,a=Pf(Xo,n);return r.jsx(vr,{present:s||ss(a.checked)||a.checked===!0,children:r.jsx(xn.span,{...o,ref:t,"data-state":Qo(a.checked)})})});Ol.displayName=Xo;var Rf="MenuSeparator",Fl=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(xn.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});Fl.displayName=Rf;var Lf="MenuArrow",$l=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=xs(n);return r.jsx(Xu,{...o,...s,ref:t})});$l.displayName=Lf;var Of="MenuSub",[Db,Bl]=Fr(Of),cn="MenuSubTrigger",zl=l.forwardRef((e,t)=>{const n=$r(cn,e.__scopeMenu),s=bn(cn,e.__scopeMenu),o=Bl(cn,e.__scopeMenu),a=Go(cn,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},p=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>p,[p]),l.useEffect(()=>{const m=c.current;return()=>{window.clearTimeout(m),d(null)}},[c,d]),r.jsx(Ko,{asChild:!0,...u,children:r.jsx(Il,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Hl(n.open),...e,ref:Lr(t,o.onTriggerChange),onClick:m=>{e.onClick?.(m),!(e.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:tt(e.onPointerMove,fn(m=>{a.onItemEnter(m),!m.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:tt(e.onPointerLeave,fn(m=>{p();const f=n.content?.getBoundingClientRect();if(f){const h=n.content?.dataset.side,g=h==="right",b=g?-5:5,v=f[g?"left":"right"],j=f[g?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+b,y:m.clientY},{x:v,y:f.top},{x:j,y:f.top},{x:j,y:f.bottom},{x:v,y:f.bottom}],side:h}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:tt(e.onKeyDown,m=>{const f=a.searchRef.current!=="";e.disabled||f&&m.key===" "||xf[s.dir].includes(m.key)&&(n.onOpenChange(!0),n.content?.focus(),m.preventDefault())})})})});zl.displayName=cn;var Wl="MenuSubContent",Ul=l.forwardRef((e,t)=>{const n=Cl(Gt,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=$r(Gt,e.__scopeMenu),i=bn(Gt,e.__scopeMenu),c=Bl(Wl,e.__scopeMenu),d=l.useRef(null),u=Yt(t,d);return r.jsx(mn.Provider,{scope:e.__scopeMenu,children:r.jsx(vr,{present:s||a.open,children:r.jsx(mn.Slot,{scope:e.__scopeMenu,children:r.jsx(Jo,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{i.isUsingKeyboardRef.current&&d.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:tt(e.onFocusOutside,p=>{p.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:tt(e.onEscapeKeyDown,p=>{i.onClose(),p.preventDefault()}),onKeyDown:tt(e.onKeyDown,p=>{const m=p.currentTarget.contains(p.target),f=yf[i.dir].includes(p.key);m&&f&&(a.onOpenChange(!1),c.trigger?.focus(),p.preventDefault())})})})})})});Ul.displayName=Wl;function Hl(e){return e?"open":"closed"}function ss(e){return e==="indeterminate"}function Qo(e){return ss(e)?"indeterminate":e?"checked":"unchecked"}function Ff(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function $f(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function Bf(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=$f(e,Math.max(a,0));o.length===1&&(i=i.filter(u=>u!==n));const d=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return d!==n?d:void 0}function zf(e,t){const{x:n,y:s}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],u=c.x,p=c.y,m=d.x,f=d.y;p>s!=f>s&&n<(m-u)*(s-p)/(f-p)+u&&(o=!o)}return o}function Wf(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return zf(n,t)}function fn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Uf=Nl,Hf=Ko,qf=El,Kf=Al,Vf=Yo,Gf=_l,Jf=ys,Yf=Tl,Xf=Dl,Qf=Rl,Zf=Ol,eh=Fl,th=$l,rh=zl,nh=Ul;function sh(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:f,children:h,...g}=m,b=f?.[e]?.[d]||c,v=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:v,children:h})};u.displayName=a+"Provider";function p(m,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,oh(o,...t)]}function oh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function ah(e){const t=ih(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(ch);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function ih(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=uh(o),c=dh(a,o.props);return o.type!==l.Fragment&&(c.ref=s?Lr(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var lh=Symbol("radix.slottable");function ch(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===lh}function dh(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function uh(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ph=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],mh=ph.reduce((e,t)=>{const n=ah(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),vs="DropdownMenu",[fh,Pb]=sh(vs,[jl]),$t=jl(),[hh,ql]=fh(vs),Kl=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:o,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,d=$t(t),u=l.useRef(null),[p,m]=Wo({prop:o,defaultProp:a??!1,onChange:i,caller:vs});return r.jsx(hh,{scope:t,triggerId:rs(),triggerRef:u,contentId:rs(),open:p,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(f=>!f),[m]),modal:c,children:r.jsx(Uf,{...d,open:p,onOpenChange:m,dir:s,modal:c,children:n})})};Kl.displayName=vs;var Vl="DropdownMenuTrigger",Gl=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...o}=e,a=ql(Vl,n),i=$t(n);return r.jsx(Hf,{asChild:!0,...i,children:r.jsx(mh.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...o,ref:Lr(t,a.triggerRef),onPointerDown:tt(e.onPointerDown,c=>{!s&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:tt(e.onKeyDown,c=>{s||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});Gl.displayName=Vl;var gh="DropdownMenuPortal",Jl=e=>{const{__scopeDropdownMenu:t,...n}=e,s=$t(t);return r.jsx(qf,{...s,...n})};Jl.displayName=gh;var Yl="DropdownMenuContent",Xl=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=ql(Yl,n),a=$t(n),i=l.useRef(!1);return r.jsx(Kf,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...s,ref:t,onCloseAutoFocus:tt(e.onCloseAutoFocus,c=>{i.current||o.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:tt(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!o.modal||p)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Xl.displayName=Yl;var xh="DropdownMenuGroup",yh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(Vf,{...o,...s,ref:t})});yh.displayName=xh;var vh="DropdownMenuLabel",bh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(Gf,{...o,...s,ref:t})});bh.displayName=vh;var wh="DropdownMenuItem",Ql=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(Jf,{...o,...s,ref:t})});Ql.displayName=wh;var kh="DropdownMenuCheckboxItem",jh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(Yf,{...o,...s,ref:t})});jh.displayName=kh;var Sh="DropdownMenuRadioGroup",Nh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(Xf,{...o,...s,ref:t})});Nh.displayName=Sh;var Ch="DropdownMenuRadioItem",Eh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(Qf,{...o,...s,ref:t})});Eh.displayName=Ch;var Ah="DropdownMenuItemIndicator",_h=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(Zf,{...o,...s,ref:t})});_h.displayName=Ah;var Ih="DropdownMenuSeparator",Zl=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(eh,{...o,...s,ref:t})});Zl.displayName=Ih;var Th="DropdownMenuArrow",Mh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(th,{...o,...s,ref:t})});Mh.displayName=Th;var Dh="DropdownMenuSubTrigger",Ph=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(rh,{...o,...s,ref:t})});Ph.displayName=Dh;var Rh="DropdownMenuSubContent",Lh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=$t(n);return r.jsx(nh,{...o,...s,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Lh.displayName=Rh;var Pn=Kl,Rn=Gl,Ln=Jl,On=Xl,nr=Ql,$a=Zl;function Oh(e){const t=Fh(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Bh);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Fh(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Wh(o),c=zh(a,o.props);return o.type!==l.Fragment&&(c.ref=s?Lr(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var $h=Symbol("radix.slottable");function Bh(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===$h}function zh(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Wh(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 Uh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wn=Uh.reduce((e,t)=>{const n=Oh(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function Hh(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:f,children:h,...g}=m,b=f?.[e]?.[d]||c,v=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:v,children:h})};u.displayName=a+"Provider";function p(m,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,qh(o,...t)]}function qh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Kh(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var Zo="ScrollArea",[ec,Rb]=Hh(Zo),[Vh,Xt]=ec(Zo),tc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[u,p]=l.useState(null),[m,f]=l.useState(null),[h,g]=l.useState(null),[b,v]=l.useState(null),[j,O]=l.useState(0),[C,L]=l.useState(0),[_,R]=l.useState(!1),[I,k]=l.useState(!1),q=Yt(t,re=>d(re)),G=hs(o);return r.jsx(Vh,{scope:n,type:s,dir:G,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:p,content:m,onContentChange:f,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:_,onScrollbarXEnabledChange:R,scrollbarY:b,onScrollbarYChange:v,scrollbarYEnabled:I,onScrollbarYEnabledChange:k,onCornerWidthChange:O,onCornerHeightChange:L,children:r.jsx(wn.div,{dir:G,...i,ref:q,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});tc.displayName=Zo;var rc="ScrollAreaViewport",nc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:o,...a}=e,i=Xt(rc,n),c=l.useRef(null),d=Yt(t,c,i.onViewportChange);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),r.jsx(wn.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});nc.displayName=rc;var dr="ScrollAreaScrollbar",sc=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Xt(dr,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=o,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),o.type==="hover"?r.jsx(Gh,{...s,ref:t,forceMount:n}):o.type==="scroll"?r.jsx(Jh,{...s,ref:t,forceMount:n}):o.type==="auto"?r.jsx(oc,{...s,ref:t,forceMount:n}):o.type==="always"?r.jsx(ea,{...s,ref:t}):null});sc.displayName=dr;var Gh=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Xt(dr,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=o.scrollArea;let d=0;if(c){const u=()=>{window.clearTimeout(d),i(!0)},p=()=>{d=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",p)}}},[o.scrollArea,o.scrollHideDelay]),r.jsx(vr,{present:n||a,children:r.jsx(oc,{"data-state":a?"visible":"hidden",...s,ref:t})})}),Jh=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Xt(dr,e.__scopeScrollArea),a=e.orientation==="horizontal",i=ws(()=>d("SCROLL_END"),100),[c,d]=Kh("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const u=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const u=o.viewport,p=a?"scrollLeft":"scrollTop";if(u){let m=u[p];const f=()=>{const h=u[p];m!==h&&(d("SCROLL"),i()),m=h};return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[o.viewport,a,d,i]),r.jsx(vr,{present:n||c!=="hidden",children:r.jsx(ea,{"data-state":c==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:tt(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:tt(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),oc=l.forwardRef((e,t)=>{const n=Xt(dr,e.__scopeScrollArea),{forceMount:s,...o}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=ws(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;i(c?u:p)}},10);return Jr(n.viewport,d),Jr(n.content,d),r.jsx(vr,{present:s||a,children:r.jsx(ea,{"data-state":a?"visible":"hidden",...o,ref:t})})}),ea=l.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,o=Xt(dr,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=dc(c.viewport,c.content),p={...s,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function m(f,h){return tg(f,i.current,c,h)}return n==="horizontal"?r.jsx(Yh,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const f=o.viewport.scrollLeft,h=Ba(f,c,o.dir);a.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{o.viewport&&(o.viewport.scrollLeft=f)},onDragScroll:f=>{o.viewport&&(o.viewport.scrollLeft=m(f,o.dir))}}):n==="vertical"?r.jsx(Xh,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const f=o.viewport.scrollTop,h=Ba(f,c);a.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{o.viewport&&(o.viewport.scrollTop=f)},onDragScroll:f=>{o.viewport&&(o.viewport.scrollTop=m(f))}}):null}),Yh=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=Xt(dr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=Yt(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(ic,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":bs(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.x),onDragScroll:p=>e.onDragScroll(p.x),onWheelScroll:(p,m)=>{if(a.viewport){const f=a.viewport.scrollLeft+p.deltaX;e.onWheelScroll(f),pc(f,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&s({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:as(i.paddingLeft),paddingEnd:as(i.paddingRight)}})}})}),Xh=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=Xt(dr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=Yt(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(ic,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":bs(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.y),onDragScroll:p=>e.onDragScroll(p.y),onWheelScroll:(p,m)=>{if(a.viewport){const f=a.viewport.scrollTop+p.deltaY;e.onWheelScroll(f),pc(f,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&s({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:as(i.paddingTop),paddingEnd:as(i.paddingBottom)}})}})}),[Qh,ac]=ec(dr),ic=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:m,...f}=e,h=Xt(dr,n),[g,b]=l.useState(null),v=Yt(t,q=>b(q)),j=l.useRef(null),O=l.useRef(""),C=h.viewport,L=s.content-s.viewport,_=or(p),R=or(d),I=ws(m,10);function k(q){if(j.current){const G=q.clientX-j.current.left,re=q.clientY-j.current.top;u({x:G,y:re})}}return l.useEffect(()=>{const q=G=>{const re=G.target;g?.contains(re)&&_(G,L)};return document.addEventListener("wheel",q,{passive:!1}),()=>document.removeEventListener("wheel",q,{passive:!1})},[C,g,L,_]),l.useEffect(R,[s,R]),Jr(g,I),Jr(h.content,I),r.jsx(Qh,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:or(a),onThumbPointerUp:or(i),onThumbPositionChange:R,onThumbPointerDown:or(c),children:r.jsx(wn.div,{...f,ref:v,style:{position:"absolute",...f.style},onPointerDown:tt(e.onPointerDown,q=>{q.button===0&&(q.target.setPointerCapture(q.pointerId),j.current=g.getBoundingClientRect(),O.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),k(q))}),onPointerMove:tt(e.onPointerMove,k),onPointerUp:tt(e.onPointerUp,q=>{const G=q.target;G.hasPointerCapture(q.pointerId)&&G.releasePointerCapture(q.pointerId),document.body.style.webkitUserSelect=O.current,h.viewport&&(h.viewport.style.scrollBehavior=""),j.current=null})})})}),os="ScrollAreaThumb",lc=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=ac(os,e.__scopeScrollArea);return r.jsx(vr,{present:n||o.hasThumb,children:r.jsx(Zh,{ref:t,...s})})}),Zh=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...o}=e,a=Xt(os,n),i=ac(os,n),{onThumbPositionChange:c}=i,d=Yt(t,m=>i.onThumbChange(m)),u=l.useRef(void 0),p=ws(()=>{u.current&&(u.current(),u.current=void 0)},100);return l.useEffect(()=>{const m=a.viewport;if(m){const f=()=>{if(p(),!u.current){const h=rg(m,c);u.current=h,c()}};return c(),m.addEventListener("scroll",f),()=>m.removeEventListener("scroll",f)}},[a.viewport,p,c]),r.jsx(wn.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:tt(e.onPointerDownCapture,m=>{const h=m.target.getBoundingClientRect(),g=m.clientX-h.left,b=m.clientY-h.top;i.onThumbPointerDown({x:g,y:b})}),onPointerUp:tt(e.onPointerUp,i.onThumbPointerUp)})});lc.displayName=os;var ta="ScrollAreaCorner",cc=l.forwardRef((e,t)=>{const n=Xt(ta,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?r.jsx(eg,{...e,ref:t}):null});cc.displayName=ta;var eg=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,o=Xt(ta,n),[a,i]=l.useState(0),[c,d]=l.useState(0),u=!!(a&&c);return Jr(o.scrollbarX,()=>{const p=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(p),d(p)}),Jr(o.scrollbarY,()=>{const p=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(p),i(p)}),u?r.jsx(wn.div,{...s,ref:t,style:{width:a,height:c,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function as(e){return e?parseInt(e,10):0}function dc(e,t){const n=e/t;return isNaN(n)?0:n}function bs(e){const t=dc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function tg(e,t,n,s="ltr"){const o=bs(n),a=o/2,i=t||a,c=o-i,d=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-c,p=n.content-n.viewport,m=s==="ltr"?[0,p]:[p*-1,0];return uc([d,u],m)(e)}function Ba(e,t,n="ltr"){const s=bs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-o,i=t.content-t.viewport,c=a-s,d=n==="ltr"?[0,i]:[i*-1,0],u=Zu(e,d);return uc([0,i],[0,c])(u)}function uc(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function pc(e,t){return e>0&&e<t}var rg=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},s=0;return function o(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,c=n.top!==a.top;(i||c)&&t(),n=a,s=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(s)};function ws(e,t){const n=or(e),s=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(s.current),[]),l.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(n,t)},[n,t])}function Jr(e,t){const n=or(t);Qu(()=>{let s=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(s),o.unobserve(e)}}},[e,n])}var mc=tc,ng=nc,fc=sc,sg=lc,og=cc;function ag(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:f,children:h,...g}=m,b=f?.[e]?.[d]||c,v=l.useMemo(()=>g,Object.values(g));return r.jsx(b.Provider,{value:v,children:h})};u.displayName=a+"Provider";function p(m,f){const h=f?.[e]?.[d]||c,g=l.useContext(h);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,ig(o,...t)]}function ig(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:d,scopeName:u})=>{const m=d(a)[`__scope${u}`];return{...c,...m}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function lg(e){const t=cg(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(ug);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function cg(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=mg(o),c=pg(a,o.props);return o.type!==l.Fragment&&(c.ref=s?Lr(s,i):i),l.cloneElement(o,c)}return l.Children.count(o)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var dg=Symbol("radix.slottable");function ug(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dg}function pg(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const d=a(...c);return o(...c),d}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function mg(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 fg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ks=fg.reduce((e,t)=>{const n=lg(`Primitive.${t}`),s=l.forwardRef((o,a)=>{const{asChild:i,...c}=o,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),js="Tabs",[hg,Lb]=ag(js,[gs]),hc=gs(),[gg,ra]=hg(js),xg=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...u}=e,p=hs(c),[m,f]=Wo({prop:s,onChange:o,defaultProp:a??"",caller:js});return r.jsx(gg,{scope:n,baseId:rs(),value:m,onValueChange:f,orientation:i,dir:p,activationMode:d,children:r.jsx(ks.div,{dir:p,"data-orientation":i,...u,ref:t})})});xg.displayName=js;var gc="TabsList",xc=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=ra(gc,n),i=hc(n);return r.jsx(bl,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(ks.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});xc.displayName=gc;var yc="TabsTrigger",vc=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,i=ra(yc,n),c=hc(n),d=kc(i.baseId,s),u=jc(i.baseId,s),p=s===i.value;return r.jsx(wl,{asChild:!0,...c,focusable:!o,active:p,children:r.jsx(ks.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...a,ref:t,onMouseDown:tt(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?i.onValueChange(s):m.preventDefault()}),onKeyDown:tt(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&i.onValueChange(s)}),onFocus:tt(e.onFocus,()=>{const m=i.activationMode!=="manual";!p&&!o&&m&&i.onValueChange(s)})})})});vc.displayName=yc;var bc="TabsContent",wc=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...i}=e,c=ra(bc,n),d=kc(c.baseId,s),u=jc(c.baseId,s),p=s===c.value,m=l.useRef(p);return l.useEffect(()=>{const f=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(f)},[]),r.jsx(vr,{present:o||p,children:({present:f})=>r.jsx(ks.div,{"data-state":p?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:f&&a})})});wc.displayName=bc;function kc(e,t){return`${e}-trigger-${t}`}function jc(e,t){return`${e}-content-${t}`}var Sc=xc,Nc=vc,Cc=wc;const Ec=l.forwardRef(({className:e,orientation:t="vertical",...n},s)=>r.jsx(fc,{ref:s,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(sg,{className:"relative flex-1 rounded-full bg-border/80"})}));Ec.displayName=fc.displayName;const Ac=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(mc,{ref:s,className:yt("relative overflow-hidden",e),...n,children:[r.jsx(ng,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsx(Ec,{}),r.jsx(og,{})]}));Ac.displayName=mc.displayName;const ar=l.forwardRef(({className:e,type:t,...n},s)=>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:s,...n}));ar.displayName="Input";const rn=({className:e="w-5 h-5"})=>r.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),kn=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Uo();return r.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},jn=({className:e="w-5 h-5"})=>{const t=l.useId(),n=l.useId(),s=l.useId();return r.jsxs("svg",{"aria-label":"Gemini",className:e,role:"img",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("title",{children:"Gemini"}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${t})`}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${n})`}),r.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:`url(#${s})`}),r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:t,x1:"7",x2:"11",y1:"15.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#08B962"}),r.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:n,x1:"8",x2:"11.5",y1:"5.5",y2:"11",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#F94543"}),r.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:s,x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#FABC12"}),r.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]})},Sn=({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"})]}),yg=!1,me=(e,t={})=>{const n=localStorage.getItem("auth-token"),s={};return t.body instanceof FormData||(s["Content-Type"]="application/json"),n&&(s.Authorization=`Bearer ${n}`),fetch(e,{...t,headers:{...s,...t.headers}})},it={auth:{status:()=>fetch("/api/auth/status"),login:(e,t)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),register:(e,t)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),user:()=>me("/api/auth/user"),logout:()=>me("/api/auth/logout",{method:"POST"})},projects:()=>me("/api/projects"),sessions:(e,t=5,n=0)=>me(`/api/projects/${e}/sessions?limit=${t}&offset=${n}`),historyIndex:e=>me(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("projectPath",t),me(`/api/session-core/providers/${e}${n.toString()?`?${n.toString()}`:""}`)},providersDiscovery:(e=null)=>{const t=new URLSearchParams;return e&&t.append("projectPath",e),me(`/api/session-core/providers${t.toString()?`?${t.toString()}`:""}`)},sessionEvents:(e,t,n=null,s=null,o=null,a=0)=>{const i=new URLSearchParams;return n&&i.append("projectName",n),s&&i.append("projectPath",s),o!==null&&(i.append("limit",o),i.append("offset",a)),me(`/api/session-core/sessions/${e}/${t}/events${i.toString()?`?${i.toString()}`:""}`)},sessionMessages:(e,t,n=null,s=0,o="claude")=>{const a=new URLSearchParams;return e&&a.append("projectName",e),n!==null&&(a.append("limit",n),a.append("offset",s)),me(`/api/session-core/sessions/${o}/${t}/events${a.toString()?`?${a.toString()}`:""}`)},resolveSession:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("provider",t),me(`/api/session-core/sessions/${e}/resolve${n.toString()?`?${n.toString()}`:""}`)},renameProject:(e,t)=>me(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:t})}),deleteSession:(e,t)=>me(`/api/projects/${e}/sessions/${t}`,{method:"DELETE"}),deleteCodexSession:e=>me(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteOpencodeSession:e=>me(`/api/opencode/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,t=!1)=>me(`/api/projects/${e}${t?"?force=true":""}`,{method:"DELETE"}),createProject:e=>me("/api/projects/create",{method:"POST",body:JSON.stringify({path:e})}),createWorkspace:e=>me("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),readFile:(e,t)=>me(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),saveFile:(e,t,n)=>me(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:t,content:n})}),getFiles:e=>me(`/api/projects/${e}/files`),transcribe:e=>me("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>{const t=new URLSearchParams;return e&&t.append("path",e),me(`/api/browse-filesystem?${t}`)},createFolder:e=>me("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),ccConnect:{status:()=>me("/api/cc-connect/status"),providers:()=>me("/api/cc-connect/providers"),platforms:()=>me("/api/cc-connect/platforms"),install:()=>me("/api/cc-connect/install",{method:"POST"}),setup:(e,t)=>me(`/api/cc-connect/${e}/setup`,{method:"POST",body:JSON.stringify(t)}),sessionStatus:(e,t)=>me(`/api/cc-connect/${e}/status?sessionId=${encodeURIComponent(t)}`),refresh:(e,t)=>me(`/api/cc-connect/${e}/refresh`,{method:"POST",body:JSON.stringify({sessionId:t})}),cleanupSession:(e,t)=>me(`/api/cc-connect/${e}/session?sessionId=${encodeURIComponent(t)}`,{method:"DELETE"}),activeProvider:e=>me(`/api/cc-connect/${e}/active-provider`),switchProvider:(e,t)=>me(`/api/cc-connect/${e}/switch-provider`,{method:"POST",body:JSON.stringify({provider:t})}),updateProject:(e,t)=>me(`/api/cc-connect/${e}/project`,{method:"POST",body:JSON.stringify(t)}),unbind:e=>me(`/api/cc-connect/${e}/unbind`,{method:"POST"})},get:e=>me(`/api${e}`)},za="__windows_drives__",vg="__workspace_roots__",bg=/^[A-Za-z]:\\?$/,wg=({onClose:e,onProjectCreated:t})=>{const{t:n}=Et(),[s,o]=l.useState(1),[a,i]=l.useState("existing"),[c,d]=l.useState(""),[u,p]=l.useState(!1),[m,f]=l.useState(null),[h,g]=l.useState([]),[b,v]=l.useState(!1),[j,O]=l.useState(!1),[C,L]=l.useState("~"),[_,R]=l.useState("~"),[I,k]=l.useState([]),[q,G]=l.useState(!1),[re,le]=l.useState(!1),[K,Z]=l.useState(!1),[U,de]=l.useState(""),[ue,ce]=l.useState(!1),[J,_e]=l.useState(null),[F,ee]=l.useState(null),[ne,xe]=l.useState(!1),fe=A=>{const V=A.trim();if(!V)return"~";if(V.endsWith("/")||V.endsWith("\\"))return V;if(/^[A-Za-z]:$/.test(V))return`${V}\\`;const y=Math.max(V.lastIndexOf("/"),V.lastIndexOf("\\"));return y>0?y===2&&/^[A-Za-z]:/.test(V)?V.substring(0,3):V.substring(0,y):"~"},be=F==="windows-drives",te=F==="workspace-roots",Se=!!F,he=J==="win32"&&!ne,nt=ne,Le=!Se,ke=!Se;l.useEffect(()=>{c.length>2?Ee(c):(g([]),v(!1))},[c]);const Ee=async A=>{try{const V=fe(A),x=await(await it.browseFilesystem(V)).json();if(x.suggestions){const S=x.suggestions.filter(B=>B.path.toLowerCase().startsWith(A.toLowerCase())&&B.path.toLowerCase()!==A.toLowerCase());g(S.slice(0,5)),v(S.length>0)}}catch(V){console.error("Error loading path suggestions:",V)}},Fe=()=>{if(f(null),s===1){if(!a){f(n("projectWizard.errors.selectType"));return}o(2)}else if(s===2){if(!c.trim()){f(n("projectWizard.errors.providePath"));return}o(3)}},rt=()=>{f(null),o(s-1)},He=async()=>{p(!0),f(null);try{const A={workspaceType:a,path:c.trim()},V=await it.createWorkspace(A),y=await V.json();if(!V.ok)throw new Error(y.details||y.error||n("projectWizard.errors.failedToCreate"));t&&t(y.project),e()}catch(A){console.error("Error creating workspace:",A),f(A.message||n("projectWizard.errors.failedToCreate"))}finally{p(!1)}},Xe=A=>{d(A.path),v(!1)},pe=async()=>{O(!0),await De()},De=async A=>{try{G(!0);const y=await(await it.browseFilesystem(A)).json();L(y.path||A),R(y.displayPath||y.path||A),k(y.suggestions||[]),_e(y.platform||null),ee(y.virtualRoot||null),xe(!!y.hasWorkspaceRootRestriction)}catch(V){console.error("Error loading folders:",V)}finally{G(!1)}},at=(A,V=!1)=>{!A||A===za||(d(A),O(!1),V&&o(3))},Ke=async A=>{await De(A)},Be=async()=>{if(!(!U.trim()||!ke)){ce(!0),f(null);try{const A=C.includes("\\")?"\\":"/",V=C.endsWith(A)?`${C}${U.trim()}`:`${C}${A}${U.trim()}`,y=await it.createFolder(V),x=await y.json();if(!y.ok)throw new Error(x.error||n("projectWizard.errors.failedToCreateFolder"));de(""),Z(!1),await De(x.path||V)}catch(A){console.error("Error creating folder:",A),f(A.message||n("projectWizard.errors.failedToCreateFolder"))}finally{ce(!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(Ir,{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(Ut,{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(A=>r.jsxs(Ct.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 ${A<s?"bg-green-500 text-white":A===s?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:A<s?r.jsx(ir,{className:"w-4 h-4"}):A}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:n(A===1?"projectWizard.steps.type":A===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),A<3&&r.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${A<s?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},A))})}),r.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[m&&r.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[r.jsx(ep,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),r.jsx("div",{className:"flex-1",children:r.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:m})})]}),s===1&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:n("projectWizard.step1.question")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${a==="existing"?"border-primary bg-primary/10 dark:bg-primary/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:r.jsx(Ir,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.existing.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.existing.description")})]})]})}),r.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${a==="new"?"border-primary bg-primary/10 dark:bg-primary/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:r.jsx(Ir,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.new.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.new.description")})]})]})})]})]})}),s===2&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n(a==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),r.jsxs("div",{className:"relative flex gap-2",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(ar,{type:"text",value:c,onChange:A=>d(A.target.value),placeholder:n(a==="existing"?"projectWizard.step2.existingPlaceholder":"projectWizard.step2.newPlaceholder"),className:"w-full"}),b&&h.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:h.map((A,V)=>r.jsxs("button",{onClick:()=>Xe(A),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:A.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:A.path})]},V))})]}),r.jsx(Ge,{type:"button",variant:"outline",onClick:pe,className:"px-3",title:n("projectWizard.folderBrowser.browseFolders"),children:r.jsx(Mr,{className:"w-4 h-4"})})]}),r.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n(a==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]})}),s===3&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[r.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:n("projectWizard.step3.reviewConfig")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.workspaceType")}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:n(a==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.path")}),r.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]})]})]}),r.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-4 border border-primary/30 dark:border-primary/60",children:r.jsx("p",{className:"text-sm text-primary",children:n(a==="existing"?"projectWizard.step3.existingInfo":"projectWizard.step3.newEmpty")})})]})]}),r.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[r.jsx(Ge,{variant:"outline",onClick:s===1?e:rt,disabled:u,children:s===1?n("projectWizard.buttons.cancel"):r.jsxs(r.Fragment,{children:[r.jsx(ll,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.back")]})}),r.jsx(Ge,{onClick:s===3?He:Fe,disabled:u||s===1&&!a,children:u?r.jsxs(r.Fragment,{children:[r.jsx(Ot,{className:"w-4 h-4 mr-2 animate-spin"}),n("projectWizard.buttons.creating")]}):s===3?r.jsxs(r.Fragment,{children:[r.jsx(ir,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.createProject")]}):r.jsxs(r.Fragment,{children:[n("projectWizard.buttons.next"),r.jsx(qr,{className:"w-4 h-4 ml-1"})]})})]})]}),j&&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(Mr,{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:()=>Ke(he?za:vg),className:`p-2 rounded-md transition-colors ${Se?"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"} ${he||nt?"":"hidden"}`,title:n(he?"projectWizard.folderBrowser.browseDrives":"projectWizard.folderBrowser.browseRoots"),children:r.jsx(rm,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>le(!re),className:`p-2 rounded-md transition-colors ${re?"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(re?"projectWizard.folderBrowser.hideHiddenFolders":"projectWizard.folderBrowser.showHiddenFolders"),children:re?r.jsx(cl,{className:"w-5 h-5"}):r.jsx(zp,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>Z(!K),className:`p-2 rounded-md transition-colors ${K?"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:!ke,children:r.jsx(Gr,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>O(!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(Ut,{className:"w-5 h-5"})})]})]}),K&&ke&&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(ar,{type:"text",value:U,onChange:A=>de(A.target.value),placeholder:n("projectWizard.folderBrowser.newFolderPlaceholder"),className:"flex-1",onKeyDown:A=>{A.key==="Enter"&&Be(),A.key==="Escape"&&(Z(!1),de(""))},autoFocus:!0}),r.jsx(Ge,{size:"sm",onClick:Be,disabled:!U.trim()||ue,children:ue?r.jsx(Ot,{className:"w-4 h-4 animate-spin"}):n("buttons.create")}),r.jsx(Ge,{size:"sm",variant:"ghost",onClick:()=>{Z(!1),de("")},children:n("buttons.cancel")})]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:q?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Ot,{className:"w-6 h-6 animate-spin text-gray-400"})}):r.jsxs("div",{className:"space-y-1",children:[C!=="~"&&C!=="/"&&!bg.test(C)&&!Se&&r.jsxs("button",{onClick:()=>{const A=Math.max(C.lastIndexOf("/"),C.lastIndexOf("\\"));let V;A<=0?V="/":A===2&&/^[A-Za-z]:/.test(C)?V=C.substring(0,3):V=C.substring(0,A),Ke(V)},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(Mr,{className:"w-5 h-5 text-gray-400"}),r.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),I.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("projectWizard.folderBrowser.noSubfolders")}):I.filter(A=>re||!A.name.startsWith(".")).sort((A,V)=>A.name.toLowerCase().localeCompare(V.name.toLowerCase())).map((A,V)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>Ke(A.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(Ir,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:A.name})]}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>at(A.path,a==="existing"),className:"text-xs px-3",children:n("buttons.select")})]},V))]})}),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:be?n("projectWizard.folderBrowser.drivesRoot"):te?n("projectWizard.folderBrowser.workspaceRoots"):_})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[r.jsx(Ge,{variant:"outline",onClick:()=>{O(!1),Z(!1),de("")},children:n("buttons.cancel")}),r.jsx(Ge,{variant:"outline",onClick:()=>at(C,a==="existing"),disabled:!Le,children:n("projectWizard.folderBrowser.useCurrentFolder")})]})]})]})})]})};var kg=["size","strokeWidth","strokeLinecap","strokeLinejoin","theme","fill","className","spin"];function Wa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function Ua(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Wa(Object(n),!0).forEach(function(s){jg(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wa(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function jg(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Sg(e,t){if(e==null)return{};var n=Ng(e,t),s,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)s=a[o],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function Ng(e,t){if(e==null)return{};var n={},s=Object.keys(e),o,a;for(a=0;a<s.length;a++)o=s[a],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var Cg={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 Eg(){return"icon-"+((1+Math.random())*4294967296|0).toString(16).substring(1)}function Ag(e,t,n){var s=typeof t.fill=="string"?[t.fill]:t.fill||[],o=[],a=t.theme||n.theme;switch(a){case"outline":o.push(typeof s[0]=="string"?s[0]:"currentColor"),o.push("none"),o.push(typeof s[0]=="string"?s[0]:"currentColor"),o.push("none");break;case"filled":o.push(typeof s[0]=="string"?s[0]:"currentColor"),o.push(typeof s[0]=="string"?s[0]:"currentColor"),o.push("#FFF"),o.push("#FFF");break;case"two-tone":o.push(typeof s[0]=="string"?s[0]:"currentColor"),o.push(typeof s[1]=="string"?s[1]:n.colors.twoTone.twoTone),o.push(typeof s[0]=="string"?s[0]:"currentColor"),o.push(typeof s[1]=="string"?s[1]:n.colors.twoTone.twoTone);break;case"multi-color":o.push(typeof s[0]=="string"?s[0]:"currentColor"),o.push(typeof s[1]=="string"?s[1]:n.colors.multiColor.outFillColor),o.push(typeof s[2]=="string"?s[2]:n.colors.multiColor.innerStrokeColor),o.push(typeof s[3]=="string"?s[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:o,id:e}}var _c=l.createContext(Cg);_c.Provider;function Ic(e,t,n){return function(s){var o=s.size,a=s.strokeWidth,i=s.strokeLinecap,c=s.strokeLinejoin,d=s.theme,u=s.fill,p=s.className,m=s.spin,f=Sg(s,kg),h=l.useContext(_c),g=l.useMemo(Eg,[]),b=Ag(g,{size:o,strokeWidth:a,strokeLinecap:i,strokeLinejoin:c,theme:d,fill:u},h),v=[h.prefix+"-icon"];return v.push(h.prefix+"-icon-"+e),h.rtl&&v.push(h.prefix+"-icon-rtl"),m&&v.push(h.prefix+"-icon-spin"),p&&v.push(p),Ct.createElement("span",Ua(Ua({},f),{},{className:v.join(" ")}),n(b))}}const _g=Ic("new-lark",!0,function(e){return Ct.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},Ct.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}),Ct.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]}),Ct.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}))}),Ig=Ic("wechat",!0,function(e){return Ct.createElement("svg",{width:e.size,height:e.size,viewBox:"0 0 48 48",fill:"none"},Ct.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]}),Ct.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}),Ct.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]}),Ct.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]}),Ct.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]}),Ct.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}),Ct.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M42.0024 35.9728L43 42L38.7618 39.9293",fill:e.colors[1]}),Ct.createElement("path",{d:"M42.0024 35.9728L43 42L38.7618 39.9293",stroke:e.colors[0],strokeWidth:e.strokeWidth,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin}),Ct.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]}),Ct.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]}))}),Tg=2e3,Mg={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode"};function Dg({provider:e,className:t="h-4 w-4"}){return e==="codex"?r.jsx(kn,{className:t}):e==="gemini"?r.jsx(jn,{className:t}):e==="opencode"?r.jsx(Sn,{className:"h-4 w-auto"}):r.jsx(rn,{className:t})}function Fn({platform:e,size:t=20}){return e==="weixin"?r.jsx(Ig,{size:t,theme:"filled",fill:"#07C160"}):r.jsx(_g,{size:t,theme:"filled",fill:"#3370FF"})}function Pg(e){return Mg[e]||e}function Rg(e){if(!e)return"0:00";const t=e-Date.now();if(t<=0)return"0:00";const n=Math.ceil(t/1e3),s=Math.floor(n/60),o=n%60;return`${s}:${String(o).padStart(2,"0")}`}function vo(e){return e?.fullPath||e?.path||""}function Ws(e){const t=vo(e),n=typeof e?.displayName=="string"?e.displayName.trim():"",s=typeof e?.name=="string"?e.name.trim():"";if(n)return n;if(s)return s;if(!t)return"";const a=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean);return a[a.length-1]||t}function Ha(e){return e&&(e.title||e.label||e.value)||""}function Lg({open:e,onOpenChange:t,selectedProject:n,projects:s=[],onConnectionChange:o}){const{t:a}=Et("sidebar"),[i,c]=l.useState(null),[d,u]=l.useState(!1),[p,m]=l.useState(null),[f,h]=l.useState(null),[g,b]=l.useState(""),[v,j]=l.useState(""),[O,C]=l.useState(!1),[L,_]=l.useState(""),[R,I]=l.useState({}),[k,q]=l.useState({}),G=l.useRef(null),re=l.useRef(null),le=vo(n),K=i?.ccConnect?.installed===!0,Z=l.useMemo(()=>i?.platforms?.find(y=>y.id===p)||null,[i,p]),U=f&&f.platform===p?f:null,de=l.useMemo(()=>(i?.providers||[]).filter(y=>y.installed).map(y=>y.id),[i]),ue=l.useMemo(()=>{const y=new Map,x=(S,B)=>{const D=String(S||"").trim();!D||y.has(D)||y.set(D,{value:D,title:String(B||D).trim()||D,subtitle:D})};for(const S of s){const B=vo(S);x(B,Ws(S))}le&&x(le,Ws(n));for(const S of i?.platforms||[])S?.projectPath&&x(S.projectPath,Ws({path:S.projectPath}));return Array.from(y.values())},[s,n,le,i]),ce=l.useMemo(()=>new Map(ue.map(y=>[y.value,y])),[ue]),J=()=>{G.current&&(clearInterval(G.current),G.current=null)},_e=async({silent:y=!1}={})=>{y||u(!0);try{const x=await it.ccConnect.platforms(),S=await x.json();if(!x.ok)throw new Error(S?.error||"Failed to load connection summary.");return c(S),o?.(S),S}catch(x){return b(x.message),null}finally{y||u(!1)}},F=async()=>{const y=re.current;if(J(),!(!y?.sessionId||!y?.platform||new Set(["confirmed","error","expired"]).has(y.status)))try{await it.ccConnect.cleanupSession(y.platform,y.sessionId)}catch{}};l.useEffect(()=>{re.current=f},[f]),l.useEffect(()=>{if(!e){F(),c(null),m(null),h(null),b(""),j(""),_(""),I({}),q({});return}return _e(),()=>{J()}},[e]),l.useEffect(()=>{if(!U?.sessionId){J();return}const y=async()=>{try{const x=await it.ccConnect.sessionStatus(U.platform,U.sessionId),S=await x.json();if(!x.ok)throw new Error(S?.error||"Failed to read setup status.");h(S),S.status==="confirmed"?(J(),j(S.message||a("ccConnect.messages.connected")),_(""),h(null),await _e({silent:!0})):(S.status==="error"||S.status==="expired")&&(J(),_(""))}catch(x){J(),_(""),b(x.message)}};return y(),G.current=setInterval(()=>{y()},Tg),()=>J()},[U?.platform,U?.sessionId,a]),l.useEffect(()=>{e&&I(y=>{const x={...y};let S=!1;const B=i?.platforms||[];for(const D of B){if(typeof y[D.id]=="string"?y[D.id].trim():"")continue;const we=D.projectPath||le||ue[0]?.value||"";we&&(x[D.id]=we,S=!0)}return S?x:y})},[e,ue,le,i]),l.useEffect(()=>{e&&q(y=>{const x={...y};let S=!1;for(const B of i?.platforms||[]){const D=Array.isArray(B.configuredProviders)&&B.configuredProviders.length>0?B.configuredProviders:de,Y=typeof y[B.id]=="string"?y[B.id].trim():"";if(Y&&D.includes(Y))continue;const we=D.includes(B.activeProvider)?B.activeProvider:D[0]||"";we&&(x[B.id]=we,S=!0)}return S?x:y})},[de,e,i]);const ee=y=>{const x=typeof R[y]=="string"?R[y].trim():"";return x||i?.platforms?.find(B=>B.id===y)?.projectPath||le||ue[0]?.value||""},ne=y=>Array.isArray(y?.configuredProviders)&&y.configuredProviders.length>0?y.configuredProviders:de,xe=y=>{const x=ne(y),S=typeof k[y?.id]=="string"?k[y.id].trim():"";return S&&x.includes(S)?S:y?.activeProvider&&x.includes(y.activeProvider)?y.activeProvider:x[0]||null},fe=async(y,x)=>{if(I(S=>({...S,[y.id]:x})),b(""),j(""),y.connected&&x&&x!==y.projectPath)try{await $e(y.id,x)}catch{}},be=async(y,x,{persist:S=!1}={})=>{q(B=>({...B,[y.id]:x})),S&&(b(""),j(""),await Le(y.id,x))},te=()=>{t(!1)},Se=async(y,x)=>{const S=ee(y);if(!S){b(a("ccConnect.messages.selectProjectFirst"));return}b(""),j(""),_(`setup:${y}:${x}`);const B={projectPath:S,mode:x},D=xe(i?.platforms?.find(Y=>Y.id===y));D&&(B.provider=D);try{const Y=await it.ccConnect.setup(y,B),we=await Y.json();if(!Y.ok)throw new Error(we?.error||a("ccConnect.messages.setupFailed"));h(we),_(""),m(y)}catch(Y){_(""),b(Y.message)}},$e=async(y,x=null)=>{const S=x||ee(y);if(!S){b(a("ccConnect.messages.selectProjectFirst"));return}b(""),j(""),_(`project:${y}`);try{const B=await it.ccConnect.updateProject(y,{projectPath:S}),D=await B.json();if(!B.ok)throw new Error(D?.error||a("ccConnect.messages.projectUpdateFailed"));j(D.message||a("ccConnect.messages.projectUpdateSuccess")),await _e({silent:!0})}catch(B){throw b(B.message),B}finally{_("")}},he=async()=>{if(!(!U?.platform||!U?.sessionId)){b(""),_(`refresh:${U.platform}`);try{const y=await it.ccConnect.refresh(U.platform,U.sessionId),x=await y.json();if(!y.ok)throw new Error(x?.error||a("ccConnect.messages.refreshFailed"));h(x),_("")}catch(y){_(""),b(y.message)}}},nt=async()=>{b(""),j(""),C(!0);try{const y=await it.ccConnect.install(),x=await y.json();if(!y.ok)throw new Error(x?.error||a("ccConnect.messages.installFailed"));j(x.message||a("ccConnect.messages.installSuccess")),await _e({silent:!0})}catch(y){b(y.message)}finally{C(!1)}},Le=async(y,x)=>{b(""),j(""),_(`switch:${y}:${x}`);try{const S=await it.ccConnect.switchProvider(y,x),B=await S.json();if(!S.ok)throw new Error(B?.error||a("ccConnect.messages.switchFailed"));j(B.message||a("ccConnect.messages.switchSuccess")),await _e({silent:!0})}catch(S){b(S.message)}finally{_("")}},ke=async y=>{b(""),j(""),_(`unbind:${y}`);try{const x=await it.ccConnect.unbind(y),S=await x.json();if(!x.ok)throw new Error(S?.error||a("ccConnect.messages.unbindFailed"));j(S.message||a("ccConnect.messages.unbindSuccess")),await _e({silent:!0}),h(null)}catch(x){b(x.message)}finally{_("")}},Ee=async()=>{U?.sessionId&&(await F(),h(null)),b(""),j(""),m(null)};if(!e)return null;const Fe=(y,x)=>{if(!x)return null;const S=y==="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 ${S}`,children:x})},rt=()=>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(Os,{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@beta"}),r.jsxs(Ge,{onClick:nt,disabled:O,children:[O?r.jsx(Ot,{className:"h-4 w-4 animate-spin"}):r.jsx(Os,{className:"h-4 w-4"}),a(O?"ccConnect.install.installing":"ccConnect.install.action")]})]}),He=y=>{const x=ee(y.id),S=L===`project:${y.id}`,B=ce.get(x)||null,D=ue.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")}),S&&r.jsx(Ot,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"})]}),r.jsxs(ao,{value:x||void 0,onValueChange:Y=>{fe(y,Y)},disabled:!D||!!L||!!U,children:[r.jsx(io,{className:"h-auto min-h-12 w-full items-start py-3",children:B?r.jsxs("div",{className:"min-w-0 text-left",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Ha(B)}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:B.subtitle})]}):r.jsx("div",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.placeholder")})}),r.jsx(lo,{children:ue.map(Y=>r.jsx(Zn,{value:Y.value,children:r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate font-medium text-foreground",children:Ha(Y)}),r.jsx("div",{className:"truncate text-xs text-muted-foreground",children:Y.subtitle})]})},Y.value))})]}),!x&&r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.project.empty")})]})},Xe=({platform:y,providers:x,selectedProvider:S,onSelect:B,disabled:D=!1,disableSelected:Y=!1,busyActionForProvider:we=null})=>x?.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:x.map(Ie=>{const Oe=Ie===S,dt=typeof we=="function"?we(Ie):!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 ${Oe?"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:D||Y&&Oe&&!dt,onClick:()=>{B(Ie)},children:[r.jsx(Dg,{provider:Ie,className:"h-3.5 w-3.5"}),r.jsx("span",{children:Pg(Ie)}),dt?r.jsx(Ot,{className:"h-3.5 w-3.5 animate-spin"}):Oe?r.jsx(Ta,{className:"h-3.5 w-3.5"}):null]},`${y.id}:${Ie}`)})})]}):null,pe=()=>r.jsxs("div",{className:"space-y-4",children:[Fe("success",v),Fe("error",g),r.jsx("div",{className:"grid gap-3",children:(i?.platforms||[]).map(y=>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:()=>{m(y.id),b(""),j("")},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(Fn,{platform:y.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.${y.id}.title`)}),y.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.${y.id}.description`)}),y.projectPath?r.jsx("p",{className:"mt-3 break-all text-xs text-muted-foreground",children:y.projectPath}):r.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:a("ccConnect.status.notConnected")})]})]})}),y.connected&&y.configuredProviders?.length>0&&r.jsx("div",{className:"border-t border-border/60 bg-muted/10 px-4 py-3",children:Xe({platform:y,providers:y.configuredProviders,selectedProvider:y.activeProvider,disabled:!!L,disableSelected:!0,busyActionForProvider:x=>L===`switch:${y.id}:${x}`,onSelect:async x=>{await be(y,x,{persist:!0})}})})]},y.id))})]}),De=y=>Xe({platform:y,providers:ne(y),selectedProvider:y.activeProvider,disabled:!!L,disableSelected:!0,busyActionForProvider:x=>L===`switch:${y.id}:${x}`,onSelect:async x=>{await be(y,x,{persist:!0})}}),at=y=>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(Fm,{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.${y.id}.title`)})}),r.jsx("p",{className:"mt-1 text-sm text-green-700/80 dark:text-green-300/80",children:a("ccConnect.labels.connectedHint")})]})]})}),He(y),De(y),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs(Ge,{variant:"outline",onClick:()=>{ke(y.id)},disabled:!!L,className:"text-red-600 hover:text-red-600",children:[L===`unbind:${y.id}`?r.jsx(Ot,{className:"h-4 w-4 animate-spin"}):r.jsx(Rm,{className:"h-4 w-4"}),a("ccConnect.actions.unbind")]}),r.jsx(Ge,{variant:"ghost",onClick:Ee,children:a("ccConnect.actions.back")})]})]}),Ke=()=>{if(!U)return null;const y=U.mode==="qr",x=U.status==="pending"&&(U.qrImageBase64||U.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:[(U.status==="starting"||L.startsWith("setup:"))&&r.jsxs(r.Fragment,{children:[r.jsx(Ot,{className:"h-8 w-8 animate-spin text-primary"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.starting")})]}),x&&r.jsxs(r.Fragment,{children:[U.qrImageBase64?r.jsx("img",{src:`data:image/png;base64,${U.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:U.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:Rg(U.expiresAt)})})]}),U.status==="scanned"&&r.jsxs(r.Fragment,{children:[r.jsx(Ta,{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")})]}),U.status==="error"&&r.jsxs(r.Fragment,{children:[r.jsx(Os,{className:"h-8 w-8 text-red-500"}),r.jsx("p",{className:"text-sm font-medium text-red-600 dark:text-red-300",children:U.message})]}),U.status==="expired"&&r.jsxs(r.Fragment,{children:[r.jsx(Zt,{className:"h-8 w-8 text-muted-foreground"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.status.expired")})]})]})}),y&&(U.status==="pending"||U.status==="error"||U.status==="expired")&&r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(Ge,{variant:"outline",onClick:()=>{he()},disabled:!!L,children:[L.startsWith("refresh:")?r.jsx(Ot,{className:"h-4 w-4 animate-spin"}):r.jsx(Zt,{className:"h-4 w-4"}),a("ccConnect.actions.refreshQr")]}),r.jsx(Ge,{variant:"ghost",onClick:Ee,children:a("ccConnect.actions.cancel")})]})]})},Be=y=>r.jsxs("div",{className:"space-y-4",children:[He(y),Xe({platform:y,providers:ne(y),selectedProvider:xe(y),disabled:!!U||!!L,onSelect:async x=>{await be(y,x)}}),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(La,{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")})]})]}),!U&&r.jsxs(Ge,{className:"mt-4",onClick:()=>{Se(y.id,"qr")},disabled:!ee(y.id)||!xe(y)||!!L,children:[L==="setup:weixin:qr"?r.jsx(Ot,{className:"h-4 w-4 animate-spin"}):r.jsx(Fn,{platform:y.id,size:16}),a("ccConnect.actions.connectWeixin")]})]}),Ke(),!U&&r.jsx(Ge,{variant:"ghost",onClick:Ee,children:a("ccConnect.actions.back")})]}),A=y=>r.jsxs("div",{className:"space-y-4",children:[He(y),Xe({platform:y,providers:ne(y),selectedProvider:xe(y),disabled:!!U||!!L,onSelect:async x=>{await be(y,x)}}),!U&&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(La,{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:()=>{Se(y.id,"qr")},disabled:!ee(y.id)||!xe(y)||!!L,children:[L==="setup:feishu:qr"?r.jsx(Ot,{className:"h-4 w-4 animate-spin"}):r.jsx(Fn,{platform:y.id,size:16}),a("ccConnect.actions.startQrSetup")]})]}),Ke(),!U&&r.jsx(Ge,{variant:"ghost",onClick:Ee,children:a("ccConnect.actions.back")})]}),V=y=>y?r.jsxs("div",{className:"space-y-4",children:[Fe("success",v),Fe("error",g),!K&&!y.connected?r.jsxs("div",{className:"space-y-4",children:[rt(),r.jsx(Ge,{variant:"ghost",onClick:Ee,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:()=>{Ee()},children:[r.jsx(Mp,{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:[r.jsx(Fn,{platform:y.id,size:16}),a(`ccConnect.platforms.${y.id}.title`)]})]}),y.connected&&!U?at(y):y.id==="weixin"?Be(y):A(y)]})]}):null;return Qn.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(Ot,{className:"h-4 w-4 animate-spin text-muted-foreground"}),r.jsx(Ge,{variant:"ghost",size:"icon",onClick:te,"aria-label":a("actions.cancel"),children:r.jsx(Ut,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"max-h-[80vh] overflow-y-auto px-6 py-5",children:[i?Z?V(Z):pe():r.jsxs("div",{className:"flex min-h-[240px] flex-col items-center justify-center gap-3",children:[r.jsx(Ot,{className:"h-8 w-8 animate-spin text-primary"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:a("ccConnect.loading")})]}),!K&&i&&!Z&&rt()]})]})}),document.body)}const Og=(e,t,n)=>{const s=new Date(e),o=t;if(isNaN(s.getTime()))return n?n("status.unknown"):"Unknown";const a=o-s,i=Math.floor(a/1e3),c=Math.floor(a/(1e3*60)),d=Math.floor(a/(1e3*60*60)),u=Math.floor(a/(1e3*60*60*24));return i<60?n?n("time.justNow"):"Just now":c===1?n?n("time.oneMinuteAgo"):"1 min ago":c<60?n?n("time.minutesAgo",{count:c}):`${c} mins ago`:d===1?n?n("time.oneHourAgo"):"1 hour ago":d<24?n?n("time.hoursAgo",{count:d}):`${d} hours ago`:u===1?n?n("time.oneDayAgo"):"1 day ago":u<7?n?n("time.daysAgo",{count:u}):`${u} days ago`:s.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},Fg=(e,t)=>{if(typeof e!="string")return"";const n=e.trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`},Ur="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",$n="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",Us="block min-w-0 w-full max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",qa=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?r.jsx(kn,{className:t}):e==="gemini"?r.jsx(jn,{className:t}):e==="opencode"?r.jsx(Sn,{className:"h-3.5 w-auto max-w-full"}):r.jsx(rn,{className:t});function Ka({projects:e,selectedProject:t,selectedSession:n,onProjectSelect:s,onProjectRename:o,onSessionSelect:a,onNewSession:i,onSessionDelete:c,onProjectDelete:d,isLoading:u,loadingProgress:p,onRefresh:m,updateAvailable:f,latestVersion:h,currentVersion:g,releaseInfo:b,onShowVersionModal:v,isPWA:j,isMobile:O,onToggleSidebar:C,onShowSettings:L,lockedProjectName:_,showNewProject:R,setShowNewProject:I}){const{t:k}=Et("sidebar"),[q,G]=l.useState(new Set),[re,le]=l.useState(null),[K,Z]=l.useState(""),[U,de]=l.useState({}),[ue,ce]=l.useState({}),[J,_e]=l.useState(new Set),[F,ee]=l.useState(new Date),[ne,xe]=l.useState("name"),[fe,be]=l.useState(!1),[te,Se]=l.useState(null),[$e,he]=l.useState(null),[nt,Le]=l.useState(""),[ke,Ee]=l.useState(null),[Fe,rt]=l.useState(null),[He,Xe]=l.useState({}),[pe,De]=l.useState(""),[at,Ke]=l.useState(new Set),[Be,A]=l.useState(null),[V,y]=l.useState(null),[x,S]=l.useState(null),[B,D]=l.useState(!1),[Y,we]=l.useState(()=>{try{const E=localStorage.getItem("starredProjects");return E?new Set(JSON.parse(E)):new Set}catch(E){return console.error("Error loading starred projects:",E),new Set}}),Ie=E=>je=>{je.target.closest(".overflow-y-auto")||je.target.closest("[data-scroll-container]")||(je.preventDefault(),je.stopPropagation(),E())};l.useEffect(()=>{const E=setInterval(()=>{ee(new Date)},6e4);return()=>clearInterval(E)},[]),l.useEffect(()=>{ce({}),_e(new Set)},[e]),l.useEffect(()=>{n&&t&&G(E=>new Set([...E,t.name]))},[n,t]),l.useEffect(()=>{_&&G(new Set([_]))},[_,e.length]),l.useEffect(()=>{if(e.length>0&&!u){const E=new Set;e.forEach(je=>{je.sessions&&je.sessions.length>=0&&E.add(je.name)}),_e(E)}},[e,u]),l.useEffect(()=>{const E=()=>{try{const P=localStorage.getItem("claude-settings");if(P){const ae=JSON.parse(P);xe(ae.projectSortOrder||"name")}}catch(P){console.error("Error loading sort order:",P)}};E();const je=P=>{P.key==="claude-settings"&&E()};window.addEventListener("storage",je);const T=setInterval(()=>{document.hasFocus()&&E()},1e3);return()=>{window.removeEventListener("storage",je),clearInterval(T)}},[]);const Oe=l.useCallback(async()=>{try{const E=await it.ccConnect.platforms();if(!E.ok)return;const je=await E.json();S(je)}catch{}},[]);l.useEffect(()=>{Oe()},[Oe]);const dt=E=>{const je=new Set;q.has(E)||je.add(E),G(je)},Ne=(E,je)=>{a({...E,__projectName:je})},Re=E=>{const je=new Set(Y);je.has(E)?je.delete(E):je.add(E),we(je);try{localStorage.setItem("starredProjects",JSON.stringify([...je]))}catch(T){console.error("Error saving starred projects:",T)}},lt=E=>Y.has(E),gt=E=>{let je={};try{je=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const T=[...E.sessions||[],...ue[E.name]||[]].map(ot=>({...ot,__provider:je[ot.id]||"claude"})),P=(E.codexSessions||[]).map(ot=>({...ot,__provider:"codex"})),ae=(E.geminiSessions||[]).map(ot=>({...ot,__provider:"gemini"})),Ve=(E.opencodeSessions||[]).map(ot=>({...ot,__provider:"opencode"})),xt=ot=>ot.__provider==="codex"?new Date(ot.createdAt||ot.lastActivity):ot.__provider==="gemini"?new Date(ot.createdAt||ot.lastActivity):ot.__provider==="opencode"?new Date(ot.createdAt||ot.lastActivity):new Date(ot.lastActivity);return[...T,...P,...ae,...Ve].sort((ot,H)=>xt(H)-xt(ot))},It=E=>{const je=gt(E);return je.length===0?new Date(0):je.reduce((P,ae)=>{const Ve=new Date(ae.lastActivity);return Ve>P?Ve:P},new Date(0))},pt=[...e].sort((E,je)=>{const T=lt(E.name),P=lt(je.name);if(T&&!P)return-1;if(!T&&P)return 1;if(ne==="date")return It(je)-It(E);{const ae=E.displayName||E.name,Ve=je.displayName||je.name;return ae.localeCompare(Ve)}}),Nt=E=>{le(E.name),Z(E.displayName||E.name||"")},bt=()=>{le(null),Z("")},ye=async E=>{const je=K.trim();if(te!==E)try{if(Se(E),(await it.renameProject(E,je)).ok)if(je&&typeof o=="function"&&o(E,je),typeof m=="function")await m();else if(window.refreshProjects)await window.refreshProjects();else{window.location.reload();return}else console.error("Failed to rename project")}catch(T){console.error("Error renaming project:",T)}finally{Se(null),le(null),Z("")}},X=(E,je,T,P="claude")=>{y({projectName:E,sessionId:je,sessionTitle:T,provider:P})},ie=async()=>{if(!V)return;const{projectName:E,sessionId:je,provider:T}=V;y(null);try{console.log("[Sidebar] Deleting session:",{projectName:E,sessionId:je,provider:T});let P;if(T==="codex"?P=await it.deleteCodexSession(je):T==="opencode"?P=await it.deleteOpencodeSession(je):P=await it.deleteSession(E,je),console.log("[Sidebar] Delete response:",{ok:P.ok,status:P.status}),P.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),c?c(je):console.warn("[Sidebar] No onSessionDelete callback provided");else{const ae=await P.text();console.error("[Sidebar] Failed to delete session:",{status:P.status,error:ae}),alert(k("messages.deleteSessionFailed"))}}catch(P){console.error("[Sidebar] Error deleting session:",P),alert(k("messages.deleteSessionError"))}},oe=E=>{const je=gt(E).length;A({project:E,sessionCount:je})},Je=async()=>{if(!Be)return;const{project:E,sessionCount:je}=Be,T=je===0;A(null),Ke(P=>new Set([...P,E.name]));try{const P=await it.deleteProject(E.name,!T);if(P.ok)d&&d(E.name);else{const ae=await P.json();console.error("Failed to delete project"),alert(ae.error||k("messages.deleteProjectFailed"))}}catch(P){console.error("Error deleting project:",P),alert(k("messages.deleteProjectError"))}finally{Ke(P=>{const ae=new Set(P);return ae.delete(E.name),ae})}},ct=async E=>{if(!(!(E.sessionMeta?.hasMore!==!1)||U[E.name])){de(T=>({...T,[E.name]:!0}));try{const T=(E.sessions?.length||0)+(ue[E.name]?.length||0),P=await it.sessions(E.name,5,T);if(P.ok){const ae=await P.json();ce(Ve=>({...Ve,[E.name]:[...Ve[E.name]||[],...ae.sessions]})),ae.hasMore===!1&&(E.sessionMeta={...E.sessionMeta,hasMore:!1})}}catch(T){console.error("Error loading more sessions:",T)}finally{de(T=>({...T,[E.name]:!1}))}}},wt=pt.filter(E=>{if(!pe.trim())return!0;const je=pe.toLowerCase(),T=(E.displayName||E.name).toLowerCase(),P=E.name.toLowerCase();return T.includes(je)||P.includes(je)}),Pe=!!_,M=Pe?pt.filter(E=>E.name===_):wt,W=t||M[0]||null,Ce=O?"bottom":"right",st=O?"end":"start",kt=O?4:8;return r.jsxs(r.Fragment,{children:[R&&Qn.createPortal(r.jsx(wg,{onClose:()=>I(!1),onProjectCreated:E=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),Be&&Qn.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(go,{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:k("deleteConfirmation.deleteProject")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[k("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:Be.project.displayName||Be.project.name}),"?"]}),Be.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:k("deleteConfirmation.sessionCount",{count:Be.sessionCount})}),r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:k("deleteConfirmation.allConversationsDeleted")})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:k("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:()=>A(null),children:k("actions.cancel")}),r.jsxs(Ge,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:Je,children:[r.jsx(er,{className:"w-4 h-4 mr-2"}),k("actions.delete")]})]})]})}),document.body),V&&Qn.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(go,{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:k("deleteConfirmation.deleteSession")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[k("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:V.sessionTitle||k("sessions.unnamed")}),"?"]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:k("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:()=>y(null),children:k("actions.cancel")}),r.jsxs(Ge,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:ie,children:[r.jsx(er,{className:"w-4 h-4 mr-2"}),k("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:j&&O?{paddingTop:"44px"}:{},children:[r.jsxs("div",{className:"md:flex-shrink-0 md:px-3 md:pt-3",children:[r.jsxs("div",{className:"hidden h-[60px] items-center justify-between gap-3 border-b border-border/60 bg-muted/10 px-4 md:flex",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-8 h-8 rounded-lg flex-shrink-0"}),r.jsx("div",{className:"min-w-0",children:r.jsx("h1",{className:"text-base font-semibold leading-none text-foreground truncate",children:k("app.title")})})]}),C&&r.jsx(Ge,{variant:"ghost",size:"sm",className:"h-8 w-8 flex-shrink-0 rounded-xl bg-muted/70 px-0 text-muted-foreground transition-colors duration-200 hover:bg-muted hover:text-foreground",onClick:C,title:k("tooltips.hideSidebar"),children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),r.jsx("div",{className:"chat-header border-b border-border/60 bg-white p-3 dark:bg-background md:hidden",style:j&&O?{paddingTop:"16px"}:{},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-8 h-8 rounded-lg flex-shrink-0"}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:k("app.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:k("projects.title")})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-muted/70 text-foreground transition-all duration-150 active:scale-95",onClick:()=>D(!0),title:k("ccConnect.actions.open"),"aria-label":k("ccConnect.actions.open"),children:r.jsx(mo,{className:"h-4 w-4"})}),r.jsx("button",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-muted/70 text-foreground transition-all duration-150 active:scale-95",onClick:async()=>{be(!0);try{await m()}finally{be(!1)}},disabled:fe,children:r.jsx(Zt,{className:`w-4 h-4 text-foreground ${fe?"animate-spin":""}`})}),!Pe&&r.jsx("button",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-foreground text-background transition-all duration-150 active:scale-95",onClick:()=>I(!0),children:r.jsx(Ir,{className:"w-4 h-4"})})]})]})})]}),!u&&!O&&!Pe&&r.jsx("div",{className:"hidden"}),e.length>0&&!u&&!Pe&&r.jsx("div",{className:"px-3 py-3 md:px-3",children:r.jsxs("div",{className:"relative",children:[r.jsx(co,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),r.jsx(ar,{type:"text",placeholder:k("projects.searchPlaceholder"),value:pe,onChange:E=>De(E.target.value),className:"h-10 rounded-xl border-0 bg-background/80 pl-9 text-sm shadow-none focus:bg-background focus:ring-2 focus:ring-primary/20"}),pe&&r.jsx("button",{onClick:()=>De(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:r.jsx(Ut,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.length>0&&!u&&W&&r.jsx("div",{className:"px-3 pb-2",children:r.jsxs(Ge,{variant:"subtle",className:"h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm",onClick:()=>i(W),children:[r.jsx(Gr,{className:"h-4 w-4"}),k("sessions.newSession")]})}),r.jsx(Ac,{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:p&&p.total>0?r.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${p.current/p.total*100}%`}}):r.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),p?.currentProject&&r.jsx("p",{className:"mx-auto max-w-[260px] break-words text-base font-medium leading-6 text-foreground",title:p.currentProject,children:p.currentProject.split("-").slice(-2).join("/")}),p&&p.total>0?r.jsxs("p",{className:"text-sm text-muted-foreground",children:[p.current,"/",p.total,r.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:k("projects.projects")})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:k("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(Fs,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:k("projects.noProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:k("projects.runClaudeCli")})]}):M.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(co,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:k("projects.noMatchingProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:k("projects.tryDifferentSearch")})]}):M.map(E=>{const je=q.has(E.name),T=t?.name===E.name,P=lt(E.name),ae=at.has(E.name),Ve=Pe&&E.name===_,xt=Ve||je,ot=E.displayName||E.name,H=Fg(ot,O?22:28);return r.jsxs("div",{className:yt("space-y-2",ae&&"pointer-events-none opacity-50"),children:[!Ve&&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]",T?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==E.name&&s(E),dt(E.name)},onTouchEnd:Ie(()=>{t?.name!==E.name&&s(E),dt(E.name)}),children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx("div",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:je?r.jsx(Mr,{className:yt("h-4 w-4",P?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Fs,{className:yt("h-4 w-4",P?"text-yellow-600 dark:text-yellow-400":T?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:re===E.name?r.jsx("input",{type:"text",value:K,onChange:N=>Z(N.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:k("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:N=>N.stopPropagation(),onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),N.stopPropagation(),ye(E.name)),N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),bt())},style:{fontSize:"16px"}}):r.jsx("div",{className:yt(Us,T&&"font-semibold"),children:H})})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:re===E.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:N=>{N.stopPropagation(),ye(E.name)},title:k("tooltips.save"),disabled:te===E.name,children:r.jsx(ir,{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:N=>{N.stopPropagation(),bt()},title:k("tooltips.cancel"),children:r.jsx(Ut,{className:"h-3.5 w-3.5"})})]}):r.jsxs(Pn,{children:[r.jsx(Rn,{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:N=>N.stopPropagation(),"aria-label":k("actions.settings"),children:r.jsx(Mn,{className:"h-4 w-4"})})}),r.jsx(Ln,{children:r.jsxs(On,{side:Ce,align:st,sideOffset:kt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:N=>N.stopPropagation(),children:[r.jsxs(nr,{className:Ur,onSelect:N=>{N.preventDefault(),Nt(E)},children:[r.jsx(Pa,{className:"h-4 w-4"}),k("tooltips.renameProject")]}),r.jsxs(nr,{className:Ur,onSelect:N=>{N.preventDefault(),Re(E.name)},children:[r.jsx(Oa,{className:yt("h-4 w-4",P&&"fill-yellow-400 text-yellow-500")}),k(P?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx($a,{className:"my-1 h-px bg-border"}),r.jsxs(nr,{className:$n,onSelect:N=>{N.preventDefault(),oe(E)},children:[r.jsx(er,{className:"h-4 w-4"}),k("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",re===E.name?"h-auto":"h-9",T?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==E.name&&s(E),dt(E.name)},onTouchEnd:Ie(()=>{t?.name!==E.name&&s(E),dt(E.name)}),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),t?.name!==E.name&&s(E),dt(E.name))},title:E.fullPath||ot,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:je?r.jsx(Mr,{className:yt("h-4 w-4",P?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Fs,{className:yt("h-4 w-4",P?"text-yellow-600 dark:text-yellow-400":T?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:re===E.name?r.jsx("input",{type:"text",value:K,onChange:N=>Z(N.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:k("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:N=>{N.key==="Enter"&&(N.preventDefault(),N.stopPropagation(),ye(E.name)),N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),bt())},onClick:N=>N.stopPropagation()}):r.jsx("div",{className:yt(Us,T&&"font-semibold"),children:H})})]}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:re===E.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:N=>{N.stopPropagation(),ye(E.name)},title:k("tooltips.save"),disabled:te===E.name,children:r.jsx(ir,{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:N=>{N.stopPropagation(),bt()},title:k("tooltips.cancel"),children:r.jsx(Ut,{className:"h-3.5 w-3.5"})})]}):r.jsxs(Pn,{children:[r.jsx(Rn,{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:N=>N.stopPropagation(),"aria-label":k("actions.settings"),children:r.jsx(Mn,{className:"h-4 w-4"})})}),r.jsx(Ln,{children:r.jsxs(On,{side:Ce,align:st,sideOffset:kt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:N=>N.stopPropagation(),children:[r.jsxs(nr,{className:Ur,onSelect:N=>{N.preventDefault(),Nt(E)},children:[r.jsx(Pa,{className:"h-4 w-4"}),k("tooltips.renameProject")]}),r.jsxs(nr,{className:Ur,onSelect:N=>{N.preventDefault(),Re(E.name)},children:[r.jsx(Oa,{className:yt("h-4 w-4",P&&"fill-yellow-400 text-yellow-500")}),k(P?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx($a,{className:"my-1 h-px bg-border"}),r.jsxs(nr,{className:$n,onSelect:N=>{N.preventDefault(),oe(E)},children:[r.jsx(er,{className:"h-4 w-4"}),k("tooltips.deleteProject")]})]})})]})})]})]}),xt&&r.jsxs("div",{className:yt("space-y-1",Ve?"px-1 md:px-0":"px-0"),children:[J.has(E.name)?gt(E).length===0&&!U[E.name]?r.jsx("div",{className:"px-3 py-2 text-left",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:k("sessions.noSessions")})}):gt(E).map(N=>{const se=N.__provider==="codex",Te=N.__provider==="gemini",ge=N.__provider==="opencode",Qe=se||Te||ge,et=$e===N.id&&!se,vt=n?.id===N.id,qe=se?N.summary||N.name||k("projects.codexSession"):ge?N.summary||N.name||k("projects.opencodeSession"):N.summary||N.name||k("projects.newSession"),mt=Qe&&N.createdAt||N.lastActivity,Ze=ke===N.id||Fe===N.id;return r.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>Ee(N.id),onMouseLeave:()=>Ee(Ae=>Ae===N.id?null:Ae),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",vt?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),onClick:()=>{s(E),Ne(N,E.name)},onTouchEnd:Ie(()=>{s(E),Ne(N,E.name)}),children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:r.jsx(qa,{provider:N.__provider})}),r.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:et?r.jsx("input",{type:"text",value:nt,onChange:Ae=>Le(Ae.target.value),onKeyDown:Ae=>{Ae.stopPropagation(),Ae.key==="Enter"?updateSessionSummary(E.name,N.id,nt):Ae.key==="Escape"&&(he(null),Le(""))},onClick:Ae=>Ae.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:Us,title:qe,children:qe})}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:et?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:Ae=>{Ae.stopPropagation(),updateSessionSummary(E.name,N.id,nt)},title:k("tooltips.save"),children:r.jsx(ir,{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:Ae=>{Ae.stopPropagation(),he(null),Le("")},title:k("tooltips.cancel"),children:r.jsx(Ut,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:r.jsxs(Pn,{children:[r.jsx(Rn,{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:Ae=>Ae.stopPropagation(),"aria-label":k("actions.settings"),children:r.jsx(Mn,{className:"h-4 w-4"})})}),r.jsx(Ln,{children:r.jsxs(On,{side:Ce,align:st,sideOffset:kt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:Ae=>Ae.stopPropagation(),children:[!se&&r.jsxs(nr,{className:Ur,onSelect:Ae=>{Ae.preventDefault(),he(N.id),Le(N.summary||N.name||k("projects.newSession"))},children:[r.jsx(Ra,{className:"h-4 w-4"}),k("tooltips.editSessionName")]}),r.jsxs(nr,{className:$n,onSelect:Ae=>{Ae.preventDefault(),X(E.name,N.id,qe,N.__provider)},children:[r.jsx(er,{className:"h-4 w-4"}),k("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",vt?"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:()=>Ne(N,E.name),onTouchEnd:Ie(()=>Ne(N,E.name)),children:[r.jsx("span",{className:yt("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",vt||et?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:r.jsx(qa,{provider:N.__provider})}),et?r.jsx("input",{type:"text",value:nt,onChange:Ae=>Le(Ae.target.value),onKeyDown:Ae=>{Ae.stopPropagation(),Ae.key==="Enter"?updateSessionSummary(E.name,N.id,nt):Ae.key==="Escape"&&(he(null),Le(""))},onClick:Ae=>Ae.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:qe,children:qe})]}),r.jsx("div",{className:"relative flex shrink-0 items-center justify-end pl-1 min-w-[28px]",children:et?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:Ae=>{Ae.stopPropagation(),updateSessionSummary(E.name,N.id,nt)},title:k("tooltips.save"),children:r.jsx(ir,{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:Ae=>{Ae.stopPropagation(),he(null),Le("")},title:k("tooltips.cancel"),children:r.jsx(Ut,{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",Ze?"opacity-0":"opacity-100"),children:Og(mt,F,k)}),Ze&&r.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 flex items-center justify-end",children:r.jsxs(Pn,{onOpenChange:Ae=>rt(Ae?N.id:null),children:[r.jsx(Rn,{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:Ae=>Ae.stopPropagation(),onFocus:()=>Ee(N.id),"aria-label":k("actions.settings"),children:r.jsx(Mn,{className:"h-4 w-4"})})}),r.jsx(Ln,{children:r.jsxs(On,{side:Ce,align:st,sideOffset:kt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:Ae=>Ae.stopPropagation(),children:[!se&&r.jsxs(nr,{className:Ur,onSelect:Ae=>{Ae.preventDefault(),he(N.id),Le(N.summary||N.name||k("projects.newSession"))},children:[r.jsx(Ra,{className:"h-4 w-4"}),k("tooltips.editSessionName")]}),r.jsxs(nr,{className:$n,onSelect:Ae=>{Ae.preventDefault(),X(E.name,N.id,qe,N.__provider)},children:[r.jsx(er,{className:"h-4 w-4"}),k("tooltips.deleteSession")]})]})})]})})]})})]})})]},N.id)}):Array.from({length:3}).map((N,se)=>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+se*15}%`}})},se)),gt(E).length>0&&E.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:()=>ct(E),disabled:U[E.name],children:U[E.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"}),k("sessions.loading")]}):r.jsxs(r.Fragment,{children:[r.jsx(jr,{className:"w-3 h-3"}),k("sessions.showMore")]})})]})]},E.name)})})}),f&&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:v,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:b?.title||`Version ${h}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:k("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:v,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:b?.title||`Version ${h}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:k("version.updateAvailable")})]})]})})]}),r.jsx("div",{className:"md:p-2 flex-shrink-0",children:r.jsxs("div",{className:"hidden md:flex items-center justify-between gap-2",children:[!Pe&&r.jsxs(Ge,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:()=>I(!0),title:k("tooltips.createProject"),children:[r.jsx(Ir,{className:"w-4 h-4"}),r.jsx("span",{className:"text-xs leading-none",children:k("projects.newProject").includes("Project")?"New":k("projects.newProject").substring(0,2)})]}),r.jsxs(Ge,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:()=>D(!0),title:k("ccConnect.actions.open"),children:[r.jsx(mo,{className:"w-4 h-4"}),r.jsx("span",{className:"text-xs leading-none",children:k("ccConnect.actions.shortOpen")})]}),r.jsxs(Ge,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:async()=>{be(!0);try{await m()}finally{be(!1)}},disabled:fe,title:k("tooltips.refresh"),children:[r.jsx(Zt,{className:`w-4 h-4 ${fe?"animate-spin":""}`}),r.jsx("span",{className:"text-xs leading-none",children:k("actions.refresh")||"Sync"})]})]})})]}),r.jsx(Lg,{open:B,onOpenChange:D,selectedProject:t,projects:e,onConnectionChange:S})]})}function $g(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Va(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:$g(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function Ga(e,t){return e||""}function Bg(e){const t=String(e||"").replace(/\\\s*\n\s*/g," ").trim();if(!t)return"";const s=t.split(/\s*(?:&&|\|\||;|\|)\s*/).map(o=>o.trim()).filter(Boolean).map(o=>o.split(/\s+/)[0]).filter(Boolean);return s.length===0?t:s.slice(0,4).join(" · ")+(s.length>4?"…":"")}function zg(e,t,n){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof n=="string"?n:""}function Wg(e,t,n,s){const o=zg(e,t,t),a=Ga(o);if(e==="Bash"){const i=t?.command||"";return{activityKind:"command",title:s("activity.actions.runCommand"),summary:Bg(i)||s("activity.actions.commandPending"),filePath:o,icon:_m,heavy:!0}}if(e==="Grep"||e==="Glob"){const i=t?.pattern||t?.glob||"",c=Ga(t?.path||""),d=[];return i&&d.push(i),c&&d.push(c),{activityKind:"search",title:s("activity.actions.searchContent"),summary:d.join(" · ")||s("activity.actions.searchPending"),filePath:t?.path||"",icon:co,heavy:!1}}return e==="Read"?{activityKind:"read",title:s("activity.actions.readFile"),summary:a||s("activity.actions.readPending"),filePath:o,icon:Vp,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:s("activity.actions.updateFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:Up,heavy:!0}:e==="Write"?{activityKind:"write",title:s("activity.actions.createFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:qp,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:s("activity.actions.updateTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:Da,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:s("activity.actions.readTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:Da,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:s("activity.actions.generatePlan"),summary:s("activity.actions.planSummary"),filePath:"",icon:Ho,heavy:!0}:{activityKind:"tool",title:s("activity.actions.runTool"),summary:e,filePath:o,icon:tp,heavy:!0}}function Ug({status:e,messages:t=[],pendingPermissionRequests:n=[],t:s}){if(n.length>0){const a=n[0];return{phaseText:s("activity.stage.waitingPermission"),detailText:s("activity.requestTool",{tool:a.toolName||s("messageTypes.tool")}),canAbort:!0,startedAt:e?.startedAt||Date.now()}}const o=[...t].reverse().find(a=>a?.isToolUse);if(o&&!Va(o.toolResult)&&!o.toolEndedAt){const a=al(o.toolInput)||{},i=Va(o.toolResult),c=Wg(o.toolName,a,null,s);return{phaseText:i?.isError?s("activity.stage.toolFailed"):c.activityKind==="search"?s("activity.stage.searching"):c.activityKind==="command"?s("activity.stage.runningCommand"):c.activityKind==="edit"||c.activityKind==="write"?s("activity.stage.editingFile"):c.activityKind==="read"?s("activity.stage.readingFile"):c.activityKind.startsWith("todo")?s("activity.stage.updatingTodo"):s("activity.stage.working"),detailText:c.summary,canAbort:e?.canAbort??!0,startedAt:e?.startedAt||Date.now()}}return e||null}const ze={USER_MESSAGE:"user_message",ASSISTANT_TEXT_START:"assistant_text_start",ASSISTANT_TEXT_DELTA:"assistant_text_delta",ASSISTANT_TEXT_END:"assistant_text_end",ASSISTANT_CONTENT_BLOCK:"assistant_content_block",REASONING_START:"reasoning_start",REASONING_DELTA:"reasoning_delta",REASONING_END:"reasoning_end",TOOL_CALL_START:"tool_call_start",TOOL_CALL_INPUT:"tool_call_input",TOOL_CALL_END:"tool_call_end",TOOL_RESULT:"tool_result",PLAN_UPDATE:"plan_update",MODE_UPDATE:"mode_update",AVAILABLE_COMMANDS_UPDATE:"available_commands_update",APPROVAL_REQUEST:"approval_request",APPROVAL_RESOLVED:"approval_resolved",SESSION_STATE_CHANGED:"session_state_changed",SYSTEM_NOTICE:"system_notice",ERROR:"error"};function Kt(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function Tc(e){if(!e)return new Date().toISOString();if(e instanceof Date)return e.toISOString();const t=new Date(e);return Number.isNaN(t.getTime())?new Date().toISOString():t.toISOString()}function Lt({kind:e,provider:t="claude",sessionId:n=null,timestamp:s,payload:o={},extensions:a={},rawRef:i=null,eventId:c=null}){return{eventId:c||Kt(e),kind:e,provider:t,sessionId:n,timestamp:Tc(s),payload:o,extensions:a,rawRef:i}}function na(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function Hs({kindPrefix:e="assistant_text",text:t,provider:n,sessionId:s,timestamp:o,messageId:a,extensions:i={},rawRef:c=null}){if(typeof t!="string"||!t.trim())return[];const d=a||Kt(e),u={...i,messageId:d};return[Lt({kind:`${e}_start`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c}),Lt({kind:`${e}_delta`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d,text:t},extensions:u,rawRef:c}),Lt({kind:`${e}_end`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c})]}function Hg(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
|
|
242
|
+
|
|
243
|
+
[USER MESSAGE]
|
|
244
|
+
`,o=t.indexOf(s);return o>=0?t.slice(o+s.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function qs(e){const t=String(e||"").trim();return!t||t.startsWith("[System Context]")||t.startsWith("[Attached Context]")||t.startsWith("[Dynamic Context]")||t.startsWith("[Hidden Context]")||t.startsWith("# AGENTS.md instructions for ")||t.startsWith("[DYNAMIC CONTEXT V1]")?!0:/^<dynamic_context(?:\s|>)/i.test(t)||t.includes("<environment_context>")}function Tr(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function fr(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function sa(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map(t=>fr(t)):[]}function Mc(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function qg(e){const t=e?.clientRequestId||e?.extensions?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function Kg(e={}){return[...Array.isArray(e?.images)?e.images.map(n=>({type:"image",data:n?.data||n?.image||"",mimeType:n?.mimeType||"application/octet-stream",name:n?.name||n?.filename||""})):[],...sa(e?.contentBlocks)]}function Vg(e,t,n={}){const s=Mc(t);if(!s)return-1;const o=JSON.stringify(sa(n.contentBlocks));return Dr(e,a=>String(a?.type||"").trim().toLowerCase()!=="user"||qg(a)!==s||String(a?.content||"")!==String(n.text||"")?!1:JSON.stringify(Kg(a))===o)}function Gg(e){if(!e||typeof e!="object")return null;const t=Array.isArray(e.availableModes)?e.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:s.description==null?null:String(s.description)})):[],n=typeof e.currentModeId=="string"&&e.currentModeId.trim()?e.currentModeId.trim():null;return!t.length&&!n?null:{availableModes:t,currentModeId:n||t[0]?.id||null}}function Jg(e){return(Array.isArray(e?.availableCommands)?e.availableCommands:Array.isArray(e)?e:[]).filter(n=>n&&typeof n=="object"&&String(n.name||"").trim()).map(n=>({name:String(n.name).trim(),description:n.description==null?"":String(n.description),input:n.input&&typeof n.input=="object"?fr(n.input):null,source:"acp",namespace:"acp",type:"acp"}))}function Bn(e=null,t={}){const n=e&&typeof e=="object"?{...e}:{};return t.title!=null&&(n.title=String(t.title)),t.kind!=null&&(n.kind=String(t.kind)),t.status!=null&&(n.status=String(t.status)),t.rawInput!==void 0&&(n.rawInput=fr(t.rawInput)),t.rawOutput!==void 0&&(n.rawOutput=fr(t.rawOutput)),Array.isArray(t.contentBlocks)&&(n.content=fr(t.contentBlocks)),Array.isArray(t.locations)&&(n.locations=fr(t.locations)),Object.keys(n).length>0?n:null}function Yg(e){const t=new Map;for(const n of e||[])if(!(n?.message?.role!=="user"||!Array.isArray(n?.message?.content)))for(const s of n.message.content)s?.type==="tool_result"&&s.tool_use_id&&t.set(s.tool_use_id,{content:s.content,isError:!!s.is_error,timestamp:n.timestamp,toolUseResult:n.toolUseResult||null});return t}function Dr(e,t){for(let n=e.length-1;n>=0;n-=1)if(t(e[n],n))return n;return-1}function Ja(e="",t=""){return t?e?e.endsWith(t)?e:`${e}${t}`:t:e}function zn(e,{messageId:t,timestamp:n,provider:s,isThinking:o=!1,kind:a="assistant"}){const i=Dr(e,d=>d?.eventMessageId===t&&!d.isToolUse&&!!d.isThinking==!!o);if(i>=0){const d={...e[i]};return d.isStreaming=!0,s&&(d.provider=s),n&&(d.timestamp=d.timestamp||n),e[i]=d,{messages:e,index:i}}const c={type:a,content:"",timestamp:n,provider:s,isStreaming:!0,eventMessageId:t};return o&&(c.isThinking=!0),e.push(c),{messages:e,index:e.length-1}}function Xg(e,{messageId:t,timestamp:n,provider:s,role:o="assistant"}){const a=Dr(e,i=>i?.eventMessageId===t&&!i.isToolUse&&!i.isThinking&&String(i?.type||"").trim().toLowerCase()===String(o||"assistant").trim().toLowerCase());if(a>=0){const i={...e[a]};return s&&(i.provider=s),n&&!i.timestamp&&(i.timestamp=n),e[a]=i,{messages:e,index:a}}return e.push({type:o,content:"",timestamp:n,provider:s,isStreaming:!1,eventMessageId:t,contentBlocks:[]}),{messages:e,index:e.length-1}}function Wn(e,{toolCallId:t,toolName:n,timestamp:s,provider:o}){const a=Dr(e,i=>i?.isToolUse&&(i.toolId===t||i.toolCallId===t));if(a>=0){const i={...e[a]};return n&&(i.toolName=n),o&&(i.provider=o),s&&!i.timestamp&&(i.timestamp=s),e[a]=i,{messages:e,index:a}}return e.push({type:"assistant",content:"",timestamp:s,provider:o,isToolUse:!0,toolName:n||"Unknown Tool",toolId:t,toolCallId:t}),{messages:e,index:e.length-1}}function Qg(e=[],t="claude",n=null){if(!Array.isArray(e))return[];const s=[],o=Yg(e);for(const a of e){const i=Tc(a?.timestamp),c={provider:t,timestamp:i,type:a?.type||a?.message?.role||"unknown"};if(a?.message?.role==="user"&&a?.message?.content){let d="";Array.isArray(a.message.content)?d=a.message.content.filter(p=>p?.type==="text").map(p=>p?.text||"").join(`
|
|
245
|
+
`):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=Hg(d);u&&(!qs(d)||u!==d)&&s.push(Lt({kind:ze.USER_MESSAGE,provider:t,sessionId:n,timestamp:i,payload:{text:u},rawRef:c}));continue}if(a?.type==="thinking"&&a?.message?.content){s.push(...Hs({kindPrefix:"reasoning",text:a.message.content,provider:t,sessionId:n,timestamp:i,rawRef:c}));continue}if(a?.type==="tool_use"&&a?.toolName){const d=a.toolCallId||Kt("tool"),u=a.toolResult||null;s.push(Lt({kind:ze.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),s.push(Lt({kind:ze.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,input:a.toolInput||""},rawRef:c})),s.push(Lt({kind:ze.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),u&&s.push(Lt({kind:ze.TOOL_RESULT,provider:t,sessionId:n,timestamp:u.timestamp||i,payload:{toolCallId:d,content:Tr(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:c}));continue}if(a?.type==="tool_result"){s.push(Lt({kind:ze.TOOL_RESULT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:a.toolCallId||null,content:Tr(a.output||""),isError:!1},rawRef:c}));continue}if(a?.message?.role==="assistant"&&a?.message?.content){if(Array.isArray(a.message.content)){for(const d of a.message.content)if(d?.type==="text"&&!qs(d.text))s.push(...Hs({text:d.text,provider:t,sessionId:n,timestamp:i,rawRef:c}));else if(d?.type==="tool_use"){const u=d.id||Kt("tool"),p=o.get(d.id);s.push(Lt({kind:ze.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),s.push(Lt({kind:ze.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,input:Tr(d.input||{})},rawRef:c})),s.push(Lt({kind:ze.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),p&&s.push(Lt({kind:ze.TOOL_RESULT,provider:t,sessionId:n,timestamp:p.timestamp||i,payload:{toolCallId:u,content:Tr(p.content),isError:!!p.isError,toolUseResult:p.toolUseResult||null},rawRef:c}))}}else qs(a.message.content)||s.push(...Hs({text:a.message.content,provider:t,sessionId:n,timestamp:i,rawRef:c}));continue}a?.type&&/error/i.test(a.type)&&s.push(Lt({kind:ze.ERROR,provider:t,sessionId:n,timestamp:i,payload:{message:a.error||a.message||"Provider error"},rawRef:c}))}return s.sort((a,i)=>new Date(a.timestamp)-new Date(i.timestamp))}function Dc(e=[],t,n="claude"){const s=Array.isArray(e)?[...e]:[];if(!na(t))return s;const o=t.provider||n,a=t.timestamp||new Date().toISOString(),i=t.payload||{};switch(t.kind){case ze.USER_MESSAGE:{const c=Mc(t),d=Vg(s,t,i),u=sa(i.contentBlocks);if(d>=0){const p=s[d]||{},m=Array.isArray(p.images)&&p.images.length>0?u.filter(f=>f?.type!=="image"):u;s[d]={...p,type:"user",content:i.text||p.content||"",timestamp:p.timestamp||a,provider:o,contentBlocks:m,clientRequestId:c||p.clientRequestId||null,eventId:t.eventId||p.eventId,id:p.id||t.eventId||p.id};break}s.push({type:"user",content:i.text||"",timestamp:a,provider:o,contentBlocks:u,clientRequestId:c});break}case ze.ASSISTANT_TEXT_START:{const c=i.messageId||t.extensions?.messageId||Kt("assistant_text");zn(s,{messageId:c,timestamp:a,provider:o,isThinking:!1});break}case ze.ASSISTANT_TEXT_DELTA:{const c=i.messageId||t.extensions?.messageId||Kt("assistant_text"),{index:d}=zn(s,{messageId:c,timestamp:a,provider:o,isThinking:!1}),u={...s[d]};u.content=Ja(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,s[d]=u;break}case ze.ASSISTANT_TEXT_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Dr(s,u=>u?.eventMessageId===c&&!u.isToolUse&&!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1});break}case ze.ASSISTANT_CONTENT_BLOCK:{const c=i.messageId||t.extensions?.messageId||Kt("assistant_content"),{index:d}=Xg(s,{messageId:c,timestamp:a,provider:o,role:"assistant"}),u={...s[d]},p=Array.isArray(u.contentBlocks)?[...u.contentBlocks]:[];i.contentBlock&&typeof i.contentBlock=="object"&&p.push(fr(i.contentBlock)),u.contentBlocks=p,u.provider=u.provider||o,u.timestamp=u.timestamp||a,s[d]=u;break}case ze.REASONING_START:{const c=i.messageId||t.extensions?.messageId||Kt("reasoning");zn(s,{messageId:c,timestamp:a,provider:o,isThinking:!0});break}case ze.REASONING_DELTA:{const c=i.messageId||t.extensions?.messageId||Kt("reasoning"),{index:d}=zn(s,{messageId:c,timestamp:a,provider:o,isThinking:!0}),u={...s[d]};u.content=Ja(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,u.isThinking=!0,s[d]=u;break}case ze.REASONING_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Dr(s,u=>u?.eventMessageId===c&&!!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1,isThinking:!0});break}case ze.TOOL_CALL_START:{const c=i.toolCallId||Kt("tool"),{index:d}=Wn(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:i.toolName||s[d].toolName,acpToolCall:Bn(s[d].acpToolCall,i)};break}case ze.TOOL_CALL_INPUT:{const c=i.toolCallId||Kt("tool"),{index:d}=Wn(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolInput:i.input!==void 0?Tr(i.input):i.rawInput!==void 0?Tr(i.rawInput):s[d].toolInput,provider:s[d].provider||o,acpToolCall:Bn(s[d].acpToolCall,i)};break}case ze.TOOL_CALL_END:{const c=i.toolCallId||t.extensions?.toolCallId;if(!c)break;const{index:d}=Wn(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:i.toolName||s[d].toolName,toolEndedAt:a,acpToolCall:Bn(s[d].acpToolCall,i)};break}case ze.TOOL_RESULT:{const c=i.toolCallId||t.extensions?.toolCallId||Kt("tool"),{index:d}=Wn(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolResult:{content:Tr(i.content??""),isError:!!i.isError,toolUseResult:i.toolUseResult||null,rawOutput:i.rawOutput,contentBlocks:Array.isArray(i.contentBlocks)?fr(i.contentBlocks):null,status:i.status||null,timestamp:a},toolError:!!i.isError,toolEndedAt:s[d].toolEndedAt||a,provider:s[d].provider||o,acpToolCall:Bn(s[d].acpToolCall,i)};break}case ze.PLAN_UPDATE:{const c=Array.isArray(i.entries)?fr(i.entries):[],d=Dr(s,p=>!!p?.isPlanUpdate),u={...d>=0?s[d]:{},id:(d>=0?s[d]?.id:null)||`plan:${t.sessionId||o}`,type:"assistant",content:String(i.message||"Plan updated"),timestamp:a,provider:o,isPlanUpdate:!0,planEntries:c};d>=0?s[d]=u:s.push(u);break}case ze.APPROVAL_REQUEST:i.message&&s.push({type:"assistant",content:i.message,timestamp:a,provider:o,isApprovalRequest:!0,approvalRequest:i});break;case ze.APPROVAL_RESOLVED:i.message&&s.push({type:"assistant",content:i.message,timestamp:a,provider:o,approvalResolution:i});break;case ze.SYSTEM_NOTICE:if(i.message){const c=s[s.length-1];c&&c.type==="assistant"&&!c.isToolUse&&(c.content||"").trim()===String(i.message).trim()||s.push({type:"assistant",content:i.message,timestamp:a,provider:o,isSystemNotice:!0})}break;case ze.ERROR:s.push({type:"error",content:i.message||"Provider error",timestamp:a,provider:o,rawRef:t.rawRef||null,extensions:t.extensions||{}});break}return s}function Pc(e=[],t="claude"){return Array.isArray(e)?e.length>0&&!na(e[0])?Pc(Qg(e,t),t):e.reduce((n,s)=>Dc(n,s,t),[]):[]}function Zg(e=[]){const t={modeState:null,availableCommands:[]};for(const n of Array.isArray(e)?e:[])if(na(n)){if(n.kind===ze.MODE_UPDATE){const s=Gg(n.payload||{});s&&(t.modeState=t.modeState?{availableModes:s.availableModes.length>0?s.availableModes:t.modeState.availableModes,currentModeId:s.currentModeId||t.modeState.currentModeId||null}:s)}n.kind===ze.AVAILABLE_COMMANDS_UPDATE&&(t.availableCommands=Jg(n.payload||{}))}return t}const ve={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},is=new Set([ve.CONNECTING,ve.QUEUED,ve.STREAMING,ve.AWAITING_APPROVAL]);function mr(e){return e==null?"":String(e).replace(/\r\n/g,`
|
|
246
|
+
`).trim()}function Ya(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:mr(e.content),isError:!!e.isError}}function ex(e,t){if(!e||!t)return!1;const n=String(e.type||""),s=String(t.type||"");if(n!==s)return!1;const o=!!e.isToolUse,a=!!t.isToolUse;if(o!==a)return!1;if(o&&a){const i=Ya(e.toolResult),c=Ya(t.toolResult);return mr(e.toolName)===mr(t.toolName)&&mr(e.toolInput)===mr(t.toolInput)&&i.content===c.content&&i.isError===c.isError}return!!e.isThinking!=!!t.isThinking?!1:mr(e.content)===mr(t.content)}function tx(e,t){const n=Math.min(e.length,t.length);let s=0;for(;s<n&&ex(e[s],t[s]);)s+=1;return s}function rx(e=[],t=[],n={}){const s=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[],a=!!n.preserveLocalTail;if(s.length===0)return o;if(o.length===0)return a?s:o;const i=tx(s,o);return i===s.length&&i===o.length?o:a&&i===o.length&&s.length>o.length?s:o}function Un(e,t){return typeof t=="function"?t(e):t}function Xa(e,t={}){const n=is.has(e),s=is.has(e);return{isLoading:n,canAbortSession:s,...t}}function bo(e,t=ve.IDLE){const n=String(e||"").trim().toLowerCase();return Object.values(ve).includes(n)?n:t}function nx(e,t){return!e||typeof e!="object"?t:e.kind===ze.SESSION_STATE_CHANGED?bo(e.payload?.state,t):e.kind===ze.APPROVAL_REQUEST?ve.AWAITING_APPROVAL:e.kind===ze.APPROVAL_RESOLVED?ve.STREAMING:e.kind===ze.ERROR?ve.ERRORED:e.kind===ze.ASSISTANT_TEXT_START||e.kind===ze.ASSISTANT_TEXT_DELTA||e.kind===ze.ASSISTANT_CONTENT_BLOCK||e.kind===ze.REASONING_START||e.kind===ze.REASONING_DELTA||e.kind===ze.TOOL_CALL_START||e.kind===ze.TOOL_CALL_INPUT||e.kind===ze.TOOL_CALL_END||e.kind===ze.TOOL_RESULT||e.kind===ze.PLAN_UPDATE||e.kind===ze.SYSTEM_NOTICE?ve.STREAMING:t}function sx(e,t){const n=t?.payload||{},s=n.requestId||t?.extensions?.requestId||null,o=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!s||e.some(i=>i?.requestId===s)?e:[...e,{requestId:s,toolName:o?.title||n.toolName||"UnknownTool",input:o?.rawInput??n.input,context:{...n.context||{},kind:o?.kind||n.context?.kind||null,options:a},toolCall:o,options:a,message:n.message||null,sessionId:t?.sessionId||n.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function ox(e,t){const s=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return s?e.filter(o=>o?.requestId!==s):e}function ax(e,t){return t?e===ve.AWAITING_APPROVAL||is.has(e)?e:ve.STREAMING:e===ve.COMPLETED||e===ve.ABORTED||e===ve.ERRORED?e:ve.IDLE}function ix(e=[]){return{messages:e,pendingPermissionRequests:[],phase:ve.IDLE,isLoading:!1,canAbortSession:!1}}function lx(e,t){switch(t.type){case"replace_messages":return{...e,messages:Un(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Un(e.pendingPermissionRequests,t.value)};case"set_phase":{const n=bo(t.phase,e.phase);return{...e,phase:n,...Xa(n,t.overrides)}}case"set_loading":{const n=!!Un(e.isLoading,t.value),s=ax(e.phase,n);return{...e,phase:s,isLoading:n,canAbortSession:n?e.canAbortSession||is.has(s):!1}}case"set_can_abort":return{...e,canAbortSession:!!Un(e.canAbortSession,t.value)};case"apply_conversation_event":{const n=Dc(e.messages,t.event,t.provider),s=nx(t.event,e.phase);let o=e.pendingPermissionRequests;if(t.event?.kind===ze.APPROVAL_REQUEST)o=sx(o,t.event);else if(t.event?.kind===ze.APPROVAL_RESOLVED)o=ox(o,t.event);else if(t.event?.kind===ze.SESSION_STATE_CHANGED){const a=bo(t.event?.payload?.state,"");(a===ve.COMPLETED||a===ve.ABORTED||a===ve.ERRORED||a===ve.IDLE)&&(o=[])}return{...e,messages:n,pendingPermissionRequests:o,phase:s,...Xa(s)}}default:return e}}function Er(e){return e&&e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function cx(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function wo(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(t,n)=>{let s=parseInt(n,10);if(!Number.isFinite(s))return t;s<1e12&&(s*=1e3);const o=new Date(s),a=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(o),i=-o.getTimezoneOffset(),c=i>=0?"+":"-",d=Math.abs(i),u=Math.floor(d/60),p=d%60,m=`GMT${c}${u}${p?`:${String(p).padStart(2,"0")}`:""}`,g=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,O=>O.toUpperCase()),b=g?`${m} (${g})`:m,v=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],j=`${o.getDate()} ${v[o.getMonth()]} ${o.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${b}** - ${j}`})}catch{return e}}function dx(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
|
|
247
|
+
|
|
248
|
+
[USER MESSAGE]
|
|
249
|
+
`,o=t.indexOf(s);return o>=0?t.slice(o+s.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function oa(e=[]){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];if(t.isToolUse||t.isPlanUpdate||t.approvalRequest||t.approvalResolution)return[t];if(typeof t.content!="string")return[t];const n=dx(t.content);return n?n===t.content?[t]:[{...t,content:n}]:[]}):[]}function ux(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const s=e[n],o=t[n];if(s?.type!==o?.type||s?.role!==o?.role||s?.content!==o?.content||s?.timestamp!==o?.timestamp||!!s?.isToolUse!=!!o?.isToolUse)return!1}return!0}function aa({phaseText:e,detailText:t="",canAbort:n=!0,startedAt:s=Date.now(),elapsedSeconds:o}={}){return{phaseText:e,detailText:t,canAbort:n,startedAt:s,elapsedSeconds:o}}function px(e,t,n=null){const s=n?.startedAt||Date.now(),o=typeof e=="string"?e:e?.message||e?.status||e?.text||"",a=String(o||"").trim(),i=a.toLowerCase();let c=t("activity.stage.working");return i.includes("permission")?c=t("activity.stage.waitingPermission"):i.includes("think")?c=t("activity.stage.thinking"):i.includes("search")||i.includes("grep")||i.includes("glob")?c=t("activity.stage.searching"):i.includes("command")||i.includes("bash")?c=t("activity.stage.runningCommand"):i.includes("read")?c=t("activity.stage.readingFile"):i.includes("write")||i.includes("edit")||i.includes("patch")?c=t("activity.stage.editingFile"):i.includes("todo")?c=t("activity.stage.updatingTodo"):(i.includes("respond")||i.includes("reply"))&&(c=t("activity.stage.generatingReply")),aa({phaseText:c,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:s,elapsedSeconds:e?.elapsedSeconds})}const mx=({node:e,inline:t,className:n,children:s,...o})=>{const{t:a}=Et("chat"),[i,c]=l.useState(!1),d=Array.isArray(s)?s.join(""):String(s??""),u=/[\r\n]/.test(d);if(t||e&&e.type==="inlineCode"||!u)return r.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${n||""}`,...o,children:s});const f=/language-(\w+)/.exec(n||""),h=f?f[1]:"text",g=d,b=()=>{const v=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator?.clipboard?.writeText)navigator.clipboard.writeText(g).then(v).catch(()=>{const j=document.createElement("textarea");j.value=g,j.style.position="fixed",j.style.opacity="0",document.body.appendChild(j),j.select();try{document.execCommand("copy")}catch{}document.body.removeChild(j),v()});else{const j=document.createElement("textarea");j.value=g,j.style.position="fixed",j.style.opacity="0",document.body.appendChild(j),j.select();try{document.execCommand("copy")}catch{}document.body.removeChild(j),v()}}catch{}};return r.jsxs("div",{className:"relative group my-2",children:[h&&h!=="text"&&r.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:h}),r.jsx("button",{type:"button",onClick:b,className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:a(i?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":a(i?"codeBlock.copied":"codeBlock.copyCode"),children:i?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),a("codeBlock.copied")]}):r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),a("codeBlock.copy")]})}),r.jsx(ap,{language:h,style:ip,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:h&&h!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},fx={code:mx,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})},ko=({children:e,className:t})=>{const n=cx(String(e??"")),s=l.useMemo(()=>[rp,np],[]),o=l.useMemo(()=>[sp],[]);return r.jsx("div",{className:t,children:r.jsx(op,{remarkPlugins:s,rehypePlugins:o,components:fx,children:n})})};l.memo(({message:e,prevMessage:t,provider:n,showThinking:s,isActiveStreamingCard:o})=>{const{t:a}=Et("chat"),i=e.provider||e.__provider||n||"claude",c=i==="codex",d=i==="gemini",u=i==="opencode",p=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} ${p?"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((m,f)=>r.jsx("img",{src:m.data,alt:m.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(m.data,"_blank")},f))}),r.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!p&&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:[!p&&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(kn,{className:"w-full h-full"}):d?r.jsx(jn,{className:"w-full h-full"}):u?r.jsx(Sn,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):r.jsx(rn,{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(lp,{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:o,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(ko,{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:[s&&e.reasoning&&r.jsxs("details",{className:"mb-3",open:o,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 m=wo(String(e.content||"")),f=m.trim();if((f.startsWith("{")||f.startsWith("["))&&(f.endsWith("}")||f.endsWith("]")))try{const h=JSON.parse(f),g=JSON.stringify(h,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:g})})})]})}catch{}return e.type==="assistant"?r.jsx(ko,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:m}):r.jsx("div",{className:"whitespace-pre-wrap",children:m})})()]}),r.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${p?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});const hx=[{id:"claude",label:"Claude Code",Logo:rn},{id:"codex",label:"Codex",Logo:kn},{id:"gemini",label:"Gemini",Logo:jn},{id:"opencode",label:"OpenCode",Logo:Sn}];function gx({provider:e,onSelect:t}){return r.jsx("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:hx.map(({id:n,label:s,Logo:o})=>r.jsxs("button",{onMouseDown:a=>a.preventDefault(),onClick:()=>t(n),className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${e===n?"border-primary/50 bg-primary/5 text-foreground shadow-sm":"border-border/60 bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:text-foreground"}`,children:[n==="opencode"?r.jsx(o,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}):r.jsx(o,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:s})]},n))})}function xx(e,t){const n=e.split(`
|
|
250
|
+
`),s=t.split(`
|
|
251
|
+
`),o=[];let a=0,i=0;for(;a<n.length||i<s.length;){const c=n[a],d=s[i];a>=n.length?(o.push({type:"added",content:d,lineNum:i+1}),i+=1):i>=s.length?(o.push({type:"removed",content:c,lineNum:a+1}),a+=1):c===d?(a+=1,i+=1):(o.push({type:"removed",content:c,lineNum:a+1}),o.push({type:"added",content:d,lineNum:i+1}),a+=1,i+=1)}return o}function yx({selectedProject:e,selectedSession:t,currentSessionId:n,provider:s,chatMessages:o,threadMessages:a,isLoading:i,isLoadingSessionMessages:c,isLoadingMoreMessages:d,hasMoreMessages:u,totalMessages:p,sessionMessages:m,visibleMessageCount:f,pendingPermissionRequests:h,scrollContainerRef:g,messagesEndRef:b,onScroll:v,onLoadEarlierSessionMessages:j,onLoadEarlierMessages:O,onProviderSelection:C,onFileOpen:L,onShowSettings:_,onGrantToolPermission:R,onPermissionDecision:I,autoExpandTools:k,showRawParameters:q}){const{t:G}=Et("chat"),re=s==="codex"?"Codex":s==="gemini"?"Gemini":s==="opencode"?"OpenCode":"Claude",le=l.useMemo(()=>{const U=new Map;return(de,ue)=>{const ce=`${de.length}-${ue.length}-${de.slice(0,50)}`;if(U.has(ce))return U.get(ce);const J=xx(de,ue);if(U.set(ce,J),U.size>100){const _e=U.keys().next().value;U.delete(_e)}return J}},[]),K=o.length===0?null:r.jsxs(r.Fragment,{children:[d&&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:G("session.loading.olderMessages")})]})}),u&&!d&&r.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:p>0&&r.jsxs("span",{children:[G("session.messages.showingOf",{shown:m.length,total:p})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:j,children:G("session.messages.loadEarlier")}),r.jsx("span",{className:"ml-1 text-xs",children:G("session.messages.scrollToLoad")})]})}),!t&&!u&&o.length>f&&r.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[G("session.messages.showingLast",{count:f,total:o.length})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:O,children:G("session.messages.loadEarlier")})]})]}),Z=o.length===0?null:r.jsx(r.Fragment,{children:h.map(U=>r.jsx(cp,{request:U,className:"mx-1 my-3 sm:mx-0",onSelectOption:de=>I(U.requestId,{optionId:de,outcome:{outcome:"selected",optionId:de}}),onCancel:()=>I(U.requestId,{cancelled:!0,outcome:{outcome:"cancelled"}})},U.requestId))});return e?r.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:c&&o.length===0?r.jsx("div",{className:"px-3 py-4 text-center text-gray-500 dark:text-gray-400 sm:px-6 sm:py-5 mt-8",children:r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),r.jsx("p",{children:G("session.loading.sessionMessages")})]})}):o.length===0?r.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:!t&&!n?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:G("providerSelection.title")}),r.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:G("providerSelection.description")}),r.jsx(gx,{provider:s,onSelect:C})]}):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:G("session.continue.title")}),r.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:G("session.continue.description")})]})}):r.jsx(dp,{messages:a,convertMessage:up,isRunning:i,scrollContainerRef:g,onScroll:v,messagesEndRef:b,provider:s,providerLabel:re,createDiff:le,onFileOpen:L,onShowSettings:_,onGrantToolPermission:R,showRawParameters:q,autoExpandTools:k,selectedProject:e,markdownRenderer:ko,topContent:K,bottomContent:Z})}):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(mo,{className:"h-7 w-7"})}),r.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})})}const Hn=({children:e,content:t,position:n="top",className:s="",delay:o=500})=>{const[a,i]=l.useState(!1),[c,d]=l.useState(null),u=()=>{const h=setTimeout(()=>{i(!0)},o);d(h)},p=()=>{c&&(clearTimeout(c),d(null)),i(!1)},m=()=>{switch(n){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},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:p,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",m(),s),children:[t,r.jsx("div",{className:yt("absolute w-0 h-0 border-4 border-transparent",f())})]})]}):e};function vx(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bx(e){if(typeof e!="string")return"";const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]||e}function Rc(e,t=""){let n=[];for(const s of Array.isArray(e)?e:[]){const o=t?`${t}/${s.name}`:s.name;s.type==="directory"&&s.children?n=n.concat(Rc(s.children,o)):s.type==="file"&&n.push({name:s.name,path:o,relativePath:s.path})}return n}const Yr="1",Qa=5,Za="replace",jo="append";function hr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function cr(e){return typeof e=="string"&&e.trim().length>0}function So(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function Ss(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!hr(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 Xr(e){return Ss(e)?.path||""}function wx(e){const t=Ss(e);return t?cr(t.displayName)?t.displayName:bx(t.path):""}function kx(e,t=72){if(typeof e!="string")return"";const n=e.trim().replace(/\s+/g," ");if(n.length<=t)return n;const s=n.split(/\s*>\s*/).filter(Boolean);if(s.length<=1)return`...${n.slice(-(t-3))}`;const o=[];let a=3;for(let c=s.length-1;c>=0;c-=1){const d=s[c],u=a+d.length+(o.length>0?3:0);if(o.length>0&&u>t)break;o.unshift(d),a=u}const i=`... > ${o.join(" > ")}`;return i.length<=t?i:`...${i.slice(-(t-3))}`}function ei(e){if(!e)return"";const t=[];cr(e.label)&&t.push(e.label.trim());const n=kx(e.selector);return n&&t.push(n),t.join(" · ")}function jx(e){return e?cr(e.systemContext)||cr(Xr(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:hr(e.extensions)&&Object.keys(e.extensions).length>0:!1}function Sx(e){return e?cr(e.systemContext)||cr(Xr(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function Lc(e){if(!hr(e)||e.version!==Yr||typeof e.systemContext!="string")return null;const t=Ss(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const n=[];for(const o of e.selectedElements){if(!hr(o)||typeof o.tag!="string"||typeof o.selector!="string"||typeof o.label!="string")return null;n.push({tag:o.tag,selector:o.selector,label:o.label})}if(e.extensions!==void 0&&!hr(e.extensions))return null;const s={version:Yr,systemContext:e.systemContext,currentFile:t,selectedElements:n};return e.extensions!==void 0&&(s.extensions={...e.extensions}),s}function Nx(e){if(!hr(e)||e.version!==void 0&&e.version!==Yr||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=Ss(e.currentFile);if(!n)return null;t.currentFile=n}if(e.selectedElements!==void 0){const n=[];for(const s of e.selectedElements){if(!hr(s)||typeof s.tag!="string"||typeof s.selector!="string"||typeof s.label!="string")return null;n.push({tag:s.tag,selector:s.selector,label:s.label})}t.selectedElements=n}if(e.extensions!==void 0){if(!hr(e.extensions))return null;t.extensions={...e.extensions}}return t}function Cx(e){return`${e.tag}::${e.selector}::${e.label}`}function Ex(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,n=[];for(const s of e){const o=Cx(s);t.has(o)||(t.add(o),n.push(s))}return n}function Ax(){return{version:Yr,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function _x(e,t){const n=Lc(e)||Ax(),s=Nx(t);if(!s)return null;const o={...n};return s.systemContext!==void 0&&(o.systemContext=s.systemContext),s.currentFile!==void 0&&(o.currentFile=s.currentFile),s.selectedElements!==void 0&&(o.selectedElements=Ex([...Array.isArray(n.selectedElements)?n.selectedElements:[],...s.selectedElements])),s.extensions!==void 0&&(o.extensions={...hr(n.extensions)?n.extensions:{},...s.extensions}),o}function Ix(e){return typeof e!="string"?Za:e.trim().toLowerCase()===jo?jo:Za}function ti(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const s=So(e);if(!s)return null;try{t=JSON.parse(s)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const n=Lc(t);return n||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function Tx(e){if(!e)return null;const t={version:Yr,systemContext:e.systemContext||"",currentFile:Xr(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(t.extensions=e.extensions),t}function Mx(e,t){return`<dynamic_context version="${Yr}">
|
|
252
|
+
${JSON.stringify(e,null,2)}
|
|
253
|
+
</dynamic_context>
|
|
254
|
+
|
|
255
|
+
<user_message>
|
|
256
|
+
${t}
|
|
257
|
+
</user_message>`}function Dx({visibleDynamicContext:e,visibleSelectedElements:t,hiddenSelectedElements:n,onDismissSystemContext:s,onDismissCurrentFile:o,onDismissSelectedElement:a}){const{t:i}=Et("chat");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:[cr(e.systemContext)&&r.jsx(Hn,{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:i("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:i("input.dynamicContext.removeSystem"),"aria-label":i("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"})})})]})}),cr(Xr(e.currentFile))&&r.jsx(Hn,{content:Xr(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:wx(e.currentFile)}),r.jsx("button",{type:"button",onClick:o,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:i("input.dynamicContext.removeCurrentFile"),"aria-label":i("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((c,d)=>r.jsx(Hn,{content:ei(c),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:c.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:c.tag||i("input.dynamicContext.elementFallback")}),r.jsx("button",{type:"button",onClick:()=>a(c),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:i("input.dynamicContext.removeElement"),"aria-label":i("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"})})})]})},`${c.selector}-${d}`)),n.length>0&&r.jsx(Hn,{content:n.map(ei).join(`
|
|
258
|
+
`),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]})})]})}):null}function Px({file:e,onRemove:t,uploadProgress:n,error:s}){const[o,a]=l.useState(null);return l.useEffect(()=>{const i=URL.createObjectURL(e);return a(i),()=>URL.revokeObjectURL(i)},[e]),r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:o,alt:e.name,className:"w-20 h-20 object-cover rounded"}),n!==void 0&&n<100&&r.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:r.jsxs("div",{className:"text-white text-xs",children:[n,"%"]})}),s&&r.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:r.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),r.jsx("button",{onClick:t,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}function Rx({attachedImages:e,uploadingImages:t,imageErrors:n,onRemove:s}){return e.length?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((o,a)=>r.jsx(Px,{file:o,onRemove:()=>s(a),uploadProgress:t.get(o.name),error:n.get(o.name)},`${o.name}-${a}`))})}):null}function Lx(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 Ox({composer:e,statusPresentation:t,shouldShowClaudeStatus:n,isLoading:s,chatMessages:o,sendByCtrlEnter:a}){const{t:i}=Et("chat"),{provider:c,currentModel:d,modelOptions:u,selectedModelLabel:p,isModelSelectionLocked:m,isOpencodeModelLoading:f,permissionMode:h,acpModes:g,acpModeId:b,handleAcpModeChange:v,selectedPermissionShortLabel:j,permissionDropdownTitle:O,providerModeConfig:C,getPermissionModeLabel:L,providerThinkingConfig:_,thinkingMode:R,setThinkingMode:I,tokenBudget:k,input:q,isInputFocused:G,setIsInputFocused:re,textareaRef:le,inputContainerRef:K,inputHighlightRef:Z,showFileDropdown:U,filteredFiles:de,selectedFileIndex:ue,selectFile:ce,showCommandMenu:J,filteredCommands:_e,selectedCommandIndex:F,handleCommandSelect:ee,commandQuery:ne,frequentCommands:xe,slashPosition:fe,setShowCommandMenu:be,setSelectedCommandIndex:te,setSlashPosition:Se,setCommandQuery:$e,getRootProps:he,getInputProps:nt,isDragActive:Le,openImagePicker:ke,attachedImages:Ee,uploadingImages:Fe,imageErrors:rt,removeAttachedImage:He,visibleDynamicContext:Xe,visibleSelectedElements:pe,hiddenSelectedElements:De,handleDismissSystemContext:at,handleDismissCurrentFile:Ke,handleDismissSelectedElement:Be,renderInputWithMentions:A,handleInputChange:V,handleTextareaClick:y,handleKeyDown:x,handlePaste:S,syncInputOverlayScroll:B,handleTextareaInput:D,activeInputProvider:Y,isActiveProviderNotInstalled:we,unavailablePlaceholder:Ie,isInputDisabled:Oe,activeProviderInstallReason:dt,activeProviderInstallHint:Ne,isCheckingProviderInstallation:Re,checkProviderInstallation:lt,providerCheckLoadingByName:gt,handleSubmit:It,isUserScrolledUp:pt,scrollToBottom:Nt,setProviderModel:bt,setPermissionMode:ye,selectedSession:X,handleAbortSession:ie,modelSelectorRef:oe,permissionSelectorRef:Je,activeProviderInstallState:ct,activeInputProviderLabel:wt}=e;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",{className:"flex-1",children:r.jsx(pp,{phaseText:t?.phaseText,detailText:t?.detailText,elapsedSeconds:t?.elapsedSeconds,startedAt:t?.startedAt,canAbort:t?.canAbort,isLoading:n,onAbort:ie,provider:c})}),r.jsx("div",{ref:K,className:"mx-auto mb-3 w-full max-w-4xl"}),r.jsxs("form",{onSubmit:It,className:"relative mx-auto w-full max-w-4xl",children:[pt&&o.length>0&&r.jsx("button",{type:"button",onClick:Nt,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"})})}),Le&&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(Rx,{attachedImages:Ee,uploadingImages:Fe,imageErrors:rt,onRemove:He}),r.jsx(Dx,{visibleDynamicContext:Xe,visibleSelectedElements:pe,hiddenSelectedElements:De,onDismissSystemContext:at,onDismissCurrentFile:Ke,onDismissSelectedElement:Be}),U&&de.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:de.map((Pe,M)=>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 ${M===ue?"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:W=>{W.preventDefault(),W.stopPropagation()},onClick:W=>{W.preventDefault(),W.stopPropagation(),ce(Pe)},children:[r.jsx("div",{className:"font-medium text-sm",children:Pe.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:Pe.path})]},Pe.path))}),r.jsx(mp,{commands:_e,selectedIndex:F,onSelect:ee,onClose:()=>{be(!1),Se(-1),$e(""),te(-1)},position:{top:le.current?Math.max(16,le.current.getBoundingClientRect().top-316):0,left:le.current?le.current.getBoundingClientRect().left:16,bottom:le.current?window.innerHeight-le.current.getBoundingClientRect().top+8:90},isOpen:J,frequentCommands:ne?[]:xe}),r.jsxs("div",{...he(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${e.isTextareaExpanded?"chat-input-expanded":""} ${G?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[r.jsx("input",{...nt()}),r.jsx("div",{ref:Z,"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:A(q)})}),r.jsxs("div",{className:"relative z-10 flex flex-col",children:[r.jsx("div",{className:"relative px-4 pt-4",children:r.jsx("textarea",{ref:le,value:q,onChange:V,onClick:y,onKeyDown:x,onPaste:S,onScroll:Pe=>B(Pe.target),onFocus:()=>re(!0),onBlur:()=>re(!1),onInput:D,placeholder:we?Ie:i("input.placeholder",{provider:Y==="codex"?i("messageTypes.codex"):Y==="gemini"?i("messageTypes.gemini"):Y==="opencode"?"OpenCode":i("messageTypes.claude")}),disabled:Oe,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"}})}),we&&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:dt||Ie}),Ne&&r.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:Ne}),r.jsx("div",{className:"mt-2",children:r.jsx("button",{type:"button",onClick:()=>lt(Y,{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:Re,children:i(Re?"input.checkingInstallation":"input.recheckInstallation")})})]}),r.jsxs("div",{className:"flex items-end justify-between gap-2 px-3 pb-3 pt-2 sm:items-center",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1.5 sm:flex-nowrap sm:gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>{Oe||ke()},disabled:Oe,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:i("input.attachImages"),children:[r.jsx(Gr,{className:"h-4 w-4 sm:hidden"}),r.jsx("svg",{className:"hidden h-5 w-5 sm:block",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})]}),r.jsx("div",{ref:oe,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:r.jsxs(ao,{value:d||void 0,onValueChange:bt,disabled:Oe||f||m,children:[r.jsx(io,{className:"h-8 w-auto !min-w-0 max-w-full shrink justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 sm:h-8 sm:px-1.5 sm:text-xs",children:r.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[f&&r.jsx(Ot,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),r.jsx("span",{className:"truncate max-w-[120px] sm:max-w-[240px] md:max-w-[300px] text-xs font-normal text-muted-foreground",children:f?i("input.loadingModels"):p}),r.jsx(jr,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(lo,{children:f?r.jsx(Zn,{value:"__loading",disabled:!0,children:i("input.loadingModels")}):u.map(({value:Pe,label:M})=>r.jsx(Zn,{value:Pe,children:M},Pe))})]})}),r.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:Je,children:r.jsxs(ao,{value:h,onValueChange:Pe=>{ye(Pe),X&&localStorage.setItem(`permissionMode-${X.id}`,Pe)},disabled:Oe,children:[r.jsx(io,{className:"h-8 w-auto !min-w-0 max-w-full shrink justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 sm:h-8 sm:px-1.5 sm:text-xs",children:r.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[r.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:j||O||i("input.clickToChangeMode")}),r.jsx(jr,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(lo,{children:r.jsxs(fp,{children:[r.jsx(hp,{children:O}),C.modes.map(Pe=>r.jsx(Zn,{value:Pe,children:L(Pe,{short:!0})},Pe))]})})]})}),r.jsx(gp,{modes:g,value:b,onValueChange:v,disabled:Oe||!X?.id,label:"智能体模式"}),_.enabled&&r.jsx(xp,{selectedMode:R,onModeChange:I,className:"sm:flex-none"}),k!==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:Lx(k)})]}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700 mx-1 hidden sm:block"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative group hidden sm:block",children:[r.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:i("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:i(a?"input.hintText.ctrlEnter":"input.hintText.enter")})})]}),r.jsx("button",{type:"submit",disabled:!q.trim()||Oe,onMouseDown:Pe=>{Pe.preventDefault(),It(Pe)},onTouchStart:Pe=>{Pe.preventDefault(),It(Pe)},className:"flex h-9 w-9 items-center justify-center rounded-full bg-foreground text-background transition-colors hover:opacity-90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",children:r.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h12m-5-5 5 5-5 5"})})})]})]})]})]})]})]})}const Fx={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},Oc={OPTIONS:[{value:"gpt-5",label:"GPT-5"},{value:"gpt-5-codex",label:"GPT-5 Codex"},{value:"gpt-5-codex-mini",label:"GPT-5 Codex Mini"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-mini",label:"GPT-5.1 Codex Mini"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gpt-5.2-low",label:"GPT-5.2 Low"},{value:"gpt-5.2-medium",label:"GPT-5.2 Medium"},{value:"gpt-5.2-xhigh",label:"GPT-5.2 XHigh"},{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.3-codex-high",label:"GPT-5.3 Codex High"},{value:"gpt-5.3-codex-low",label:"GPT-5.3 Codex Low"},{value:"gpt-5.3-codex-medium",label:"GPT-5.3 Codex Medium"},{value:"gpt-5.3-codex-xhigh",label:"GPT-5.3 Codex XHigh"}],DEFAULT:"gpt-5.2-codex"},$x={OPTIONS:[{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro"},{value:"gemini-2.5-flash",label:"Gemini 2.5 Flash"},{value:"gemini-3-pro-preview",label:"Gemini 3 Pro Preview"},{value:"gemini-3-flash-preview",label:"Gemini 3 Flash Preview"}],DEFAULT:"gemini-3-pro-preview"},Bx={OPTIONS:[{value:"kimi-k2.5",label:"Kimi K2.5"}],DEFAULT:"kimi-k2.5"},zx=["claude","codex","gemini","opencode"],qn="unknown",Wx="installed",Ks="not_installed",Ux="checking",Hx=["claude","codex","gemini","opencode"],qx=300*1e3;function Vt(e){const t=String(e||"").trim().toLowerCase();return zx.includes(t)?t:"claude"}function Kx(e){switch(e){case"codex":return Oc;case"gemini":return $x;case"opencode":return Bx;case"claude":default:return Fx}}function Ns(e){return`${Vt(e)}-model`}function ia(e){return`${Ns(e)}-selection-source`}function Kn(e){const t=Vt(e),n=Ns(t),s=ia(t);return localStorage.getItem(s)!=="manual"?"":localStorage.getItem(n)||""}function Vx(e,t){const n=Vt(e);localStorage.setItem(Ns(n),t),localStorage.setItem(ia(n),"manual")}function Gx(e){const t=Vt(e);localStorage.removeItem(Ns(t)),localStorage.removeItem(ia(t))}function Fc(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const Jx=new Set(Oc.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function Yx(e){if(!Fc(e))return!1;const t=e.trim().toLowerCase();return Jx.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function Xx(e,t){return Vt(e)==="codex"?Yx(t):Fc(t)}function Vn(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}const ri=new WeakMap;let Qx=0;function Zx(e,t){if(e?.__threadMessageId)return String(e.__threadMessageId);const n=e?.id||e?.eventMessageId||e?.messageId||e?.toolCallId||e?.toolId||e?.requestId;if(n)return String(n);const s=(()=>{const i=e?.timestamp instanceof Date?e.timestamp.getTime():new Date(e?.timestamp||Date.now()).getTime();return Number.isNaN(i)?Date.now():i})(),o=String(e?.role||e?.type||"assistant"),a=String(e?.provider||e?.__provider||"");if(e&&typeof e=="object"){const i=ri.get(e);if(i)return i;const c=`${o}:${a}:${s}:runtime-${Qx++}`;return ri.set(e,c),c}return`${o}:${a}:${s}:${t}`}const jt={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 s=n.slice(-50);t=JSON.stringify(s)}}catch(n){console.warn("Could not parse chat messages for truncation:",n)}localStorage.setItem(e,t)}catch(n){if(n.name==="QuotaExceededError"){const s=Object.keys(localStorage),o=s.filter(i=>i.startsWith("chat_messages_")).sort();o.length>3&&o.slice(0,o.length-3).forEach(i=>{localStorage.removeItem(i)}),s.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(e,t)}catch(i){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:",i)}}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 $c(e){return e?`chat_messages_${e}`:""}function Bc(e,t=null){return e?t?`chat_messages_${e}__session_${t}`:$c(e):""}function e0(e,t=null){const n=Bc(e,t);if(!n)return[];const s=jt.getItem(n);if(!s)return[];try{return oa(JSON.parse(s))}catch(o){return console.warn("Failed to parse cached chat messages:",o),[]}}function zc(e,t=null,n=[]){const s=Bc(e,t);if(!s)return;const o=oa(n);if(o.length===0){jt.removeItem(s);return}jt.setItem(s,JSON.stringify(o)),t&&jt.removeItem($c(e))}const Wc="claude-settings";function t0(){const e=jt.getItem(Wc);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 r0(e){if(!e)return{success:!1};const t=t0(),n=t.allowedTools.includes(e),s=n?t.allowedTools:[...t.allowedTools,e],o=t.disallowedTools.filter(i=>i!==e),a={...t,allowedTools:s,disallowedTools:o,lastUpdated:new Date().toISOString()};return jt.setItem(Wc,JSON.stringify(a)),{success:!0,alreadyAllowed:n,updatedSettings:a}}const n0=100;function ni(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function s0(e,t){if(!e||!t)return!1;const n=ni(e),s=ni(t);return n&&s&&n===s?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 o0({selectedProject:e,selectedProjectRef:t,selectedSession:n,currentSessionId:s,setCurrentSessionId:o,provider:a,runtimePhase:i,isLoading:c,isLoadingRef:d,processingSessions:u,autoScrollToBottom:p,externalMessageUpdate:m,ws:f,sendMessage:h,chatMessages:g,setChatMessages:b,setIsLoading:v,setCanAbortSession:j,setRuntimePhase:O,setClaudeStatus:C,setPendingPermissionRequests:L,resetStreamingState:_,clearLocalRunGuard:R,localRunGuardRef:I,pendingViewSessionRef:k,isSystemSessionChange:q,setIsSystemSessionChange:G,onSessionInactive:re,onSessionNotProcessing:le,onSessionProcessing:K}){const[Z,U]=l.useState([]),[de,ue]=l.useState(!1),[ce,J]=l.useState(!1),[_e,F]=l.useState(0),[ee,ne]=l.useState(!1),[xe,fe]=l.useState(0),[be,te]=l.useState(null),[Se,$e]=l.useState(!1),[he,nt]=l.useState(100),Le=l.useRef(null),ke=l.useRef(null),Ee=l.useRef(!1),Fe=l.useRef(!1),rt=l.useRef(0),He=l.useRef(!1),Xe=l.useRef(null),pe=l.useRef({height:0,top:0}),De=l.useRef(new Map),at=l.useRef(m),Ke=e?.fullPath||e?.path||null;l.useEffect(()=>()=>{De.current.forEach(X=>clearTimeout(X)),De.current.clear()},[]);const Be=l.useCallback(async(X,ie,oe=!1,Je="claude",ct=null)=>{if(!X||!ie)return[];const wt=!oe;wt?ue(!0):J(!0);try{const Pe=ct??(oe?rt.current:0),M=await it.sessionEvents(Je,ie,X,Ke,n0,Pe);if(!M.ok)throw new Error("Failed to load session messages");const W=await M.json();if(wt&&W.tokenUsage&&te(W.tokenUsage),W.hasMore!==void 0){ne(W.hasMore),fe(W.total);const st=Pe+(W.events?.length||0);return rt.current=st,F(st),W.events||[]}const Ce=W.events||W.messages||[];return ne(!1),fe(Ce.length),rt.current=Ce.length,F(Ce.length),Ce}catch(Pe){return console.error("Error loading session messages:",Pe),[]}finally{wt?ue(!1):J(!1)}},[Ke]),A=l.useCallback((X,ie="claude")=>Pc(X,ie).map(oe=>({...oe,provider:oe.provider||ie})),[]),V=n?.__provider||a||"claude",y=l.useMemo(()=>A(Z,V),[V,A,Z]),x=l.useCallback((X=[])=>{let ie=null;for(const oe of X)if(!(!oe||typeof oe!="object")){if(oe.kind==="error"){ie=ve.ERRORED;continue}if(oe.kind==="session_state_changed"){const Je=String(oe.payload?.state||"").trim().toLowerCase();Object.values(ve).includes(Je)&&(ie=Je);continue}if(oe.kind==="approval_request"){ie=ve.AWAITING_APPROVAL;continue}if(oe.kind==="approval_resolved"){ie=ve.STREAMING;continue}(oe.kind==="assistant_text_start"||oe.kind==="assistant_text_delta"||oe.kind==="assistant_content_block"||oe.kind==="reasoning_start"||oe.kind==="reasoning_delta"||oe.kind==="tool_call_start"||oe.kind==="tool_call_input"||oe.kind==="tool_call_end"||oe.kind==="tool_result"||oe.kind==="plan_update"||oe.kind==="system_notice")&&(ie=ve.STREAMING)}return ie},[]),S=l.useCallback((X=[])=>{const ie=x(X);return ie===ve.COMPLETED||ie===ve.ABORTED||ie===ve.ERRORED?ie:null},[x]),B=l.useCallback(X=>!(X===ve.COMPLETED||X===ve.ABORTED||X===ve.ERRORED),[]),D=l.useCallback((X,ie)=>ie&&(O(ie),(ie===ve.COMPLETED||ie===ve.ABORTED||ie===ve.ERRORED)&&(R(X),C(null),X&&(re?.(X),le?.(X))),ie),[R,re,le,C,O]),Y=l.useCallback(async(X,ie)=>{const oe=t.current;if(!oe?.name||!X)return null;const Je=await Be(oe.name,X,!1,ie||V);return Array.isArray(Je)&&Je.length>0&&U(Je),x(Je)},[V,x,Be,t]),we=l.useCallback(async(X,ie)=>{const oe=await Y(X,ie);return D(X,oe)},[Y,D]),Ie=l.useCallback((X,ie=[])=>{const oe=x(ie);return D(X,oe),oe},[x,D]),Oe=l.useCallback((X,ie)=>ie===ve.COMPLETED||ie===ve.ABORTED||ie===ve.ERRORED?(D(X,ie),ie):null,[D]),dt=l.useCallback((X,ie)=>{if(!X)return;const oe=De.current.get(X);oe&&clearTimeout(oe);const Je=setTimeout(()=>{De.current.delete(X);const ct=n?.id||s||null;!ct||ct!==X||(we(X,ie),h&&h({type:"check-session-status",sessionId:X,provider:ie||V}))},1200);De.current.set(X,Je)},[V,s,we,n?.id,h]),Ne=l.useCallback(()=>{ke.current&&(ke.current.scrollTop=ke.current.scrollHeight)},[]),Re=l.useCallback(()=>{if(!ke.current)return!1;const{scrollTop:X,scrollHeight:ie,clientHeight:oe}=ke.current;return ie-X-oe<50},[]),lt=l.useCallback(async(X=null)=>{const ie=X||ke.current;if(!ie||Fe.current||ce||!ee||!n||!e)return!1;const oe=n.__provider||a||"claude";Fe.current=!0;const Je=ie.scrollHeight,ct=ie.scrollTop,wt=rt.current;try{const Pe=await Be(e.name,n.id,!0,oe,wt);return Pe.length>0&&(Xe.current={height:Je,top:ct},U(M=>[...Pe,...M])),!0}finally{Fe.current=!1}},[ee,ce,Be,a,e,n]),gt=l.useCallback(async()=>{if(ke.current){const X=ke.current,ie=Re();$e(!ie),X.scrollTop<100?He.current||await lt(X)&&(He.current=!0):He.current=!1}},[Re,lt]);l.useLayoutEffect(()=>{if(!Xe.current||!ke.current)return;const{height:X,top:ie}=Xe.current,oe=ke.current,ct=oe.scrollHeight-X;oe.scrollTop=ie+Math.max(ct,0),Xe.current=null},[g.length]),l.useEffect(()=>{let X=!1,ie=null;return(async()=>{if(n&&e){const Je=n.__provider||Vt(localStorage.getItem("selected-provider"));Ee.current=!0,sessionStorage.removeItem("pendingSessionId");const ct=s!==null&&s!==n.id;let wt=null;if(ct?(q||(_(),R(),k.current=null,b([]),U([]),C(null),j(!1)),rt.current=0,F(0),ne(!1),fe(0),te(null),v(!1)):s===null&&(rt.current=0,F(0),ne(!1),fe(0)),o(n.id),q)X||G(!1);else{const Pe=await Be(e.name,n.id,!1,n.__provider||Je||"claude");if(X)return;U(Pe),wt=Ie(n.id,Pe),wt||O(ve.IDLE),f&&h&&B(wt)&&h({type:"check-session-status",sessionId:n.id,provider:Je})}}else{const ct=k.current?.sessionId||null||d.current&&(s||I.current.sessionId)||null,wt=!!(ct||d.current);q||wt||(_(),R(),k.current=null,b([]),U([]),C(null),j(!1),v(!1)),o(ct),rt.current=0,F(0),ne(!1),fe(0),te(null)}ie=setTimeout(()=>{X||(Ee.current=!1)},250)})(),()=>{X=!0,ie&&clearTimeout(ie)}},[n?.id,n?.__provider,e?.name,e?.fullPath,e?.path,Be,q,_,R,Ie,h,O,B,f]),l.useEffect(()=>{const X=at.current;if(m<=X||(at.current=m,!n||!e))return;(async()=>{try{const oe=n.__provider||Vt(localStorage.getItem("selected-provider")),Je=await Be(e.name,n.id,!1,n.__provider||oe||"claude");U(Je),p&&Re()&&setTimeout(()=>Ne(),200)}catch(oe){console.error("Error reloading messages from external update:",oe)}})()},[p,m,Re,Be,Ne,e,n]),l.useEffect(()=>{at.current=m},[m,e?.name,n?.id]),l.useEffect(()=>{n?.id&&(k.current=null)},[k,n?.id]),l.useEffect(()=>{const X=n?.id||s||null,ie=I.current,oe=!!(ie.startedAt&&(!ie.sessionId||!X||ie.sessionId===X)&&i!==ve.IDLE);b(Je=>rx(Je,y,{preserveLocalTail:oe}))},[y,s,I,i,n?.id,b]),l.useEffect(()=>{e?.name&&zc(e.name,n?.id||null,g)},[g,e?.name,n?.id]),l.useEffect(()=>{const X=oa(g);ux(g,X)||b(X)},[g,b]),l.useEffect(()=>{s&&c&&K&&K(s)},[s,c,K]),l.useEffect(()=>{if(s&&u){const X=u.has(s),ie=S(Z);if(X&&ie){le?.(s);return}X&&!c&&i!==ve.COMPLETED&&i!==ve.ABORTED&&i!==ve.ERRORED&&O(ve.STREAMING,{canAbortSession:!0})}},[s,S,c,le,u,i,Z,O]);const It=l.useMemo(()=>n||g.length<=he?g:g.slice(-he),[g,n,he]),pt=l.useMemo(()=>{const X=It.map((oe,Je)=>({...oe,__threadMessageId:Zx(oe,Je)}));return X.length===0||!c||X.some(oe=>oe?.type==="assistant"&&!!(oe.isStreaming||oe.isToolUse||oe.isThinking||oe.reasoning))?X:[...X,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:n?.__provider||a||"claude"}]},[c,a,n?.__provider,It]);l.useEffect(()=>{if(!p&&ke.current){const X=ke.current;pe.current={height:X.scrollHeight,top:X.scrollTop}}}),l.useEffect(()=>{if(ke.current&&g.length>0)if(p)Se||setTimeout(()=>Ne(),50);else{const X=ke.current,ie=pe.current.height,oe=pe.current.top,ct=X.scrollHeight-ie;ct>0&&oe>0&&(X.scrollTop=oe+ct)}},[p,g.length,Se,Ne]),l.useEffect(()=>{ke.current&&g.length>0&&!Ee.current&&($e(!1),setTimeout(()=>{Ne()},200))},[g.length,Ne,e?.name,n?.id]),l.useEffect(()=>{const X=ke.current;if(X)return X.addEventListener("scroll",gt),()=>X.removeEventListener("scroll",gt)},[gt]),l.useEffect(()=>{if(!e||!n?.id||n.id.startsWith("new-session-")){te(null);return}if((n.__provider||a||"claude")!=="claude")return;(async()=>{try{const oe=`/api/projects/${e.name}/sessions/${n.id}/token-usage`,Je=await me(oe);if(Je.ok){const ct=await Je.json();te(ct)}else te(null)}catch(oe){console.error("Failed to fetch initial token usage:",oe)}})()},[a,e,n?.__provider,n?.id]);const Nt=l.useCallback(()=>{nt(X=>X+100)},[]),bt=l.useCallback(X=>{!X||typeof X!="object"||U(ie=>{const oe=Array.isArray(ie)?ie:[];return oe.some(Je=>s0(Je,X))?oe:[...oe,X]})},[]),ye=l.useCallback(()=>{k.current=null,sessionStorage.removeItem("pendingSessionId"),o(null),U([]),b([]),L([]),G(!1),O(ve.IDLE),C(null),j(!1),te(null),$e(!1),e?.name&&(jt.removeItem(`chat_messages_${e.name}`),jt.removeItem(`draft_input_${e.name}`))},[k,e?.name,j,b,C,o,G,L,O]);return{sessionMessages:Z,setSessionMessages:U,isLoadingSessionMessages:de,isLoadingMoreMessages:ce,messagesOffset:_e,hasMoreMessages:ee,totalMessages:xe,tokenBudget:be,setTokenBudget:te,scrollContainerRef:ke,messagesEndRef:Le,isUserScrolledUp:Se,setIsUserScrolledUp:$e,visibleMessageCount:he,threadMessages:pt,scrollToBottom:Ne,handleScroll:gt,loadOlderMessages:lt,loadEarlierMessages:Nt,loadSessionMessages:Be,appendSessionConversationEvent:bt,inferRuntimePhaseFromSessionEvents:x,inferTerminalPhaseFromSessionEvents:S,recoverAndSettleSessionRuntime:we,recoverTerminalSessionPhase:Oe,scheduleSessionStatusRecovery:dt,resetSessionHistoryForNewChat:ye}}function si(e,t={}){const n=Array.isArray(t?.availableModes)?t.availableModes.filter(o=>o&&typeof o=="object"&&String(o.id||"").trim()).map(o=>({id:String(o.id).trim(),name:String(o.name||o.id||"").trim()||String(o.id).trim(),description:typeof o.description=="string"?o.description:""})):[],s=typeof t?.currentModeId=="string"&&t.currentModeId.trim()?t.currentModeId.trim():null;return!s&&n.length===0?e||null:{availableModes:n.length>0?n:Array.isArray(e?.availableModes)?e.availableModes:[],currentModeId:s||e?.currentModeId||null}}function a0(e={}){return Array.isArray(e?.availableCommands)?e.availableCommands.filter(t=>t&&typeof t=="object"&&String(t.name||"").trim()).map(t=>({name:String(t.name).trim(),description:typeof t.description=="string"?t.description:"",input:t.input&&typeof t.input=="object"?t.input:null,type:"acp",source:"acp",namespace:"acp"})):[]}function i0({latestMessage:e,provider:t,claudeStatus:n,selectedProject:s,selectedSession:o,currentSessionId:a,setCurrentSessionId:i,isLoading:c,runtimePhase:d,sendMessage:u,persistCurrentChatCache:p,setRuntimePhase:m,setIsSystemSessionChange:f,setPendingPermissionRequests:h,setIsLoading:g,setCanAbortSession:b,setClaudeStatus:v,setChatMessages:j,setTokenBudget:O,setAcpSessionModeState:C,setAcpAvailableCommands:L,applyRealtimeConversationEvent:_,streamBufferRef:R,streamTimerRef:I,clearLocalRunGuard:k,syncLocalRunGuardSession:q,shouldIgnoreStaleIdleSignal:G,pendingViewSessionRef:re,appendSessionConversationEvent:le,recoverAndSettleSessionRuntime:K,recoverTerminalSessionPhase:Z,inferRuntimePhaseFromSessionEvents:U,inferTerminalPhaseFromSessionEvents:de,scheduleSessionStatusRecovery:ue,sessionMessages:ce,setSessionMessages:J,loadSessionMessages:_e,onSessionInactive:F,onSessionNotProcessing:ee,onSessionProcessing:ne,onReplaceTemporarySession:xe,onNavigateToSession:fe,t:be}){const te=l.useRef(null),Se=l.useRef(new Set),$e=o?.__provider||t||"claude";l.useEffect(()=>()=>{I.current&&(clearTimeout(I.current),I.current=null),R.current=""},[R,I]),l.useEffect(()=>{te.current=n},[n]),l.useEffect(()=>{if(!e)return;const he=e.data?.message||e.data,Le=["projects_updated","session-created"].includes(e.type),ke=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),Ee=e.type==="conversation-event"?String(e.event?.payload?.state||"").trim().toLowerCase():"",Fe=e.type==="conversation-event"&&(e.event?.kind==="error"||e.event?.kind==="session_state_changed"&&["streaming","awaiting_approval","completed","aborted","errored"].includes(Ee)),He=e.type==="claude-response"&&he&&he.type==="system"&&he.subtype==="init"?he?.session_id:null,Xe=sessionStorage.getItem("pendingSessionId");let pe=o?.id||a||re.current?.sessionId||null;const De=He&&(!pe||He===pe),at=Le||De,Ke=!e.sessionId&&re.current&&!re.current.sessionId&&(/error/i.test(e.type||"")||e.type==="conversation-event"&&e.event?.kind==="error"),Be=x=>{x&&(F?.(x),ee?.(x))},A=x=>{x&&ne?.(x)};if(!at){if(!pe&&e.sessionId&&!Vn(e.sessionId)&&re.current&&!re.current.sessionId&&(pe=e.sessionId,re.current.sessionId=e.sessionId,i(e.sessionId)),!pe&&(e.sessionId&&(ke.has(e.type)||Fe)&&(Ee==="streaming"||Ee==="awaiting_approval"?A(e.sessionId):Be(e.sessionId)),!Ke)||!e.sessionId&&!Ke)return;if(!Ke&&e.sessionId!==pe){const x=Vn(pe),S=!!(e.sessionId&&Xe&&e.sessionId===Xe);if(x&&(S||!Vn(e.sessionId||"")))i(e.sessionId),re.current&&(re.current.sessionId=e.sessionId);else{e.sessionId&&(ke.has(e.type)||Fe)&&(Ee==="streaming"||Ee==="awaiting_approval"?A(e.sessionId):Be(e.sessionId)),console.log("Skipping message for different session:",e.sessionId,"current:",pe);return}}}const V=e?.event?.sessionId||e.sessionId||pe||null,y=!!(V&&Se.current.has(V));if(e.type==="conversation-event"&&e.event){const x=e.event.sessionId||e.sessionId||pe||null,S=e.event.rawRef?.type||null,B=e.event.kind==="session_state_changed"?String(e.event.payload?.state||"").trim().toLowerCase():"";if(x&&Se.current.add(x),B==="idle"&&G(x,S)){ue(x,e.event.provider||$e);return}if(!!(x&&(x===(o?.id||null)||x===(a||null)||x===(re.current?.sessionId||null)))&&le(e.event),_(e.event,e.event.provider||$e),e.event.kind==="mode_update"&&C(Y=>si(Y,e.event.payload)),e.event.kind==="available_commands_update"&&L(a0(e.event.payload)),e.event.kind==="approval_request"&&m(ve.AWAITING_APPROVAL),e.event.kind==="approval_resolved"&&m(ve.STREAMING),(e.event.kind==="assistant_text_start"||e.event.kind==="assistant_text_delta"||e.event.kind==="assistant_content_block"||e.event.kind==="reasoning_start"||e.event.kind==="reasoning_delta"||e.event.kind==="tool_call_start"||e.event.kind==="tool_call_input"||e.event.kind==="tool_call_end"||e.event.kind==="tool_result"||e.event.kind==="plan_update")&&m(ve.STREAMING),(e.event.kind==="error"||e.event.payload?.state==="errored")&&(k(x),m(ve.ERRORED),v(null),x&&(Be(x),K(x,e.event.provider||$e))),e.event.kind==="session_state_changed"){const Y=B;Y==="streaming"?(m(ve.STREAMING),x&&ne&&ne(x)):Y==="awaiting_approval"?(m(ve.AWAITING_APPROVAL),x&&ne&&ne(x)):Y==="completed"?(k(x),m(ve.COMPLETED),v(null),x&&(Be(x),K(x,e.event.provider||$e))):Y==="aborted"?(k(x),m(ve.ABORTED),v(null),x&&(Be(x),K(x,e.event.provider||$e))):Y==="errored"&&(k(x),m(ve.ERRORED),v(null),x&&(Be(x),K(x,e.event.provider||$e)))}return}switch(e.type){case"ws-connection-state":e.state==="connecting"&&(d===ve.QUEUED||c)?m(ve.CONNECTING,{canAbortSession:!1}):e.state==="connected"&&d===ve.CONNECTING&&m(ve.QUEUED);break;case"connection-error":m(ve.ERRORED),v(null),j(x=>[...x,{type:"error",content:e.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":m(ve.ERRORED),b(!1),v(null),j(x=>[...x,{type:"error",content:e.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(e.sessionId){const x=Vt(e.provider||$e||t||"claude"),S=re.current?.sessionId||a||null,B=Vn(e.sessionId);if(!(!a||x==="codex"&&e.sessionId!==a)||B)break;sessionStorage.setItem("pendingSessionId",e.sessionId);try{const Y=localStorage.getItem("session-provider-map"),we=Y?JSON.parse(Y):{};we[e.sessionId]=x,localStorage.setItem("session-provider-map",JSON.stringify(we))}catch{}p(e.sessionId),e.modes&&C(Y=>si(Y,e.modes)),re.current&&(re.current.sessionId=e.sessionId),i(e.sessionId),q(e.sessionId),ne?.(e.sessionId),f(!0),xe&&xe(e.sessionId,S),h(Y=>Y.map(we=>we.sessionId?we:{...we,sessionId:e.sessionId})),fe&&fe(e.sessionId),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":e.data&&O(e.data);break;case"claude-response":{const x=y&&!(e.data?.type==="system"&&e.data?.subtype==="init");if(!x&&he&&typeof he=="object"&&he.type){if(he.type==="content_block_delta"&&he.delta?.text){const S=Er(he.delta.text);R.current+=S,I.current||(I.current=setTimeout(()=>{const B=R.current;R.current="",I.current=null,B&&j(D=>{const Y=[...D],we=Y[Y.length-1];return we&&we.type==="assistant"&&!we.isToolUse&&we.isStreaming?Y[Y.length-1]={...we,content:(we.content||"")+B}:Y.push({type:"assistant",content:B,timestamp:new Date,isStreaming:!0}),Y})},100));return}if(he.type==="content_block_stop"){I.current&&(clearTimeout(I.current),I.current=null);const S=R.current;R.current="",S&&j(B=>{const D=[...B],Y=D[D.length-1];return Y&&Y.type==="assistant"&&!Y.isToolUse&&Y.isStreaming?D[D.length-1]={...Y,content:(Y.content||"")+S}:D.push({type:"assistant",content:S,timestamp:new Date,isStreaming:!0}),D}),j(B=>{const D=[...B],Y=D[D.length-1];return Y&&Y.type==="assistant"&&Y.isStreaming&&(D[D.length-1]={...Y,isStreaming:!1}),D});return}}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id!==a&&De){f(!0),p(e.data.session_id),fe?.(e.data.session_id);return}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&!a&&De){f(!0),p(e.data.session_id),fe?.(e.data.session_id);return}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id===a&&De)return;if(x)break;if(Array.isArray(he.content)){for(const S of he.content)if(S.type==="tool_use"){const B=S.input?JSON.stringify(S.input,null,2):"";j(D=>[...D,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:S.name,toolInput:B,toolId:S.id,toolResult:null}])}else if(S.type==="text"&&S.text?.trim()){let B=Er(S.text);B=wo(B),j(D=>[...D,{type:"assistant",content:B,timestamp:new Date}])}}else if(typeof he.content=="string"&&he.content.trim()){let S=Er(he.content);S=wo(S),j(B=>[...B,{type:"assistant",content:S,timestamp:new Date}])}if(he.role==="user"&&Array.isArray(he.content))for(const S of he.content)S.type==="tool_result"&&j(B=>B.map(D=>D.isToolUse&&D.toolId===S.tool_use_id?{...D,toolResult:{content:S.content,isError:S.is_error,timestamp:new Date}}:D));break}case"claude-output":if(y)break;{const x=String(e.data||"");x.trim()&&(R.current+=R.current?`
|
|
259
|
+
${x}`:x,I.current||(I.current=setTimeout(()=>{const S=R.current;R.current="",I.current=null,S&&j(B=>{const D=[...B],Y=D[D.length-1];return Y&&Y.type==="assistant"&&!Y.isToolUse&&Y.isStreaming?D[D.length-1]={...Y,content:Y.content?`${Y.content}
|
|
260
|
+
${S}`:S}:D.push({type:"assistant",content:S,timestamp:new Date,isStreaming:!0}),D})},100)))}break;case"claude-interactive-prompt":j(x=>[...x,{type:"assistant",content:e.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":if(y||t!=="claude"||!e.requestId)break;h(x=>x.some(S=>S.requestId===e.requestId)?x:[...x,{requestId:e.requestId,toolName:e.toolName||"UnknownTool",input:e.input,context:e.context,toolCall:e.toolCall||null,options:Array.isArray(e.options)?e.options:Array.isArray(e.context?.options)?e.context.options:[],message:e.message||null,sessionId:e.sessionId||null,receivedAt:new Date}]),g(!0),b(!0),v(aa({phaseText:be("activity.stage.waitingPermission"),detailText:e.toolName?be("activity.requestTool",{tool:yp(e.toolName)}):be("activity.permission.title"),canAbort:!0}));break;case"claude-permission-cancelled":if(y||!e.requestId)break;h(x=>{const S=x.filter(B=>B.requestId!==e.requestId);return S.length===0&&v(null),S});break;case"claude-error":if(y)break;k(e.sessionId||a||null),g(!1),b(!1),v(null),j(x=>[...x,{type:"error",content:`出错了:${e.error}`,timestamp:new Date}]);break;case"claude-complete":{if(y)break;const x=e.sessionId||a||sessionStorage.getItem("pendingSessionId");k(x),(x===a||!a)&&(g(!1),b(!1),v(null)),x&&(F?.(x),ee?.(x));const S=sessionStorage.getItem("pendingSessionId");S&&!a&&e.exitCode===0&&(i(S),sessionStorage.removeItem("pendingSessionId")),s&&e.exitCode===0&&jt.removeItem(`chat_messages_${s.name}`),h([]);break}case"codex-response":{const x=e.data;if(!x||y)break;if(x.type==="item_delta"&&x.delta){const S=Er(String(x.delta));if(S){const B=`codex:${x.itemType||"item"}:${x.itemId||"unknown"}`;j(D=>{const Y=[...D];let we=-1;for(let Ie=Y.length-1;Ie>=0;Ie-=1){const Oe=Y[Ie];if(Oe?.codexItemKey===B&&Oe.type==="assistant"&&!Oe.isToolUse){we=Ie;break}}if(we===-1)Y.push({type:"assistant",content:S,timestamp:new Date,isStreaming:!0,isThinking:!!x.isReasoning,codexItemKey:B});else{const Ie=Y[we],Oe=Ie.content||"";Oe.endsWith(S)||(Ie.content=Oe+S),Ie.isStreaming=!0}return Y})}break}if(x.type==="item_done"){const S=`codex:${x.itemType||"item"}:${x.itemId||"unknown"}`,B=typeof x.content=="string"?Er(x.content):"";j(D=>{const Y=[...D];let we=-1;for(let Ie=Y.length-1;Ie>=0;Ie-=1){const Oe=Y[Ie];if(Oe?.codexItemKey===S&&Oe.type==="assistant"&&!Oe.isToolUse){we=Ie;break}}if(we!==-1){const Ie=Y[we];B&&B!==(Ie.content||"")&&(Ie.content=B),Ie.isStreaming=!1}else B.trim()&&Y.push({type:"assistant",content:B,timestamp:new Date,isStreaming:!1,isThinking:!!x.isReasoning});return Y});break}if(x.type==="item")switch(x.itemType){case"agent_message":if(x.message?.content?.trim()){const S=Er(x.message.content);j(B=>{const D=B[B.length-1];return D&&D.type==="assistant"&&!D.isToolUse&&!D.isThinking&&(D.content||"").trim()===S.trim()?B:[...B,{type:"assistant",content:S,timestamp:new Date}]})}break;case"reasoning":if(x.message?.content?.trim()){const S=Er(x.message.content);j(B=>{const D=B[B.length-1];return D&&D.type==="assistant"&&!D.isToolUse&&D.isThinking&&(D.content||"").trim()===S.trim()?B:[...B,{type:"assistant",content:S,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":x.command&&j(S=>[...S,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:x.command,toolResult:x.output||null,exitCode:x.exitCode}]);break;case"file_change":if(x.changes?.length>0){const S=x.changes.map(B=>`${B.kind}: ${B.path}`).join(`
|
|
261
|
+
`);j(B=>[...B,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:S,toolResult:`Status: ${x.status}`}])}break;case"mcp_tool_call":j(S=>[...S,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${x.server}:${x.tool}`,toolInput:JSON.stringify(x.arguments,null,2),toolResult:x.result?JSON.stringify(x.result,null,2):x.error?.message||null}]);break;case"error":x.message?.content&&j(S=>[...S,{type:"error",content:x.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",x.itemType,x)}x.type==="turn_complete"&&g(!1),x.type==="turn_failed"&&(g(!1),j(S=>[...S,{type:"error",content:x.error?.message||"Turn failed",timestamp:new Date}]));break}case"codex-complete":{if(y)break;const x=e.sessionId||a||sessionStorage.getItem("pendingSessionId");k(x),(x===a||!a)&&(g(!1),b(!1),v(null),j(D=>D.map(Y=>Y?.codexItemKey&&Y.isStreaming?{...Y,isStreaming:!1}:Y))),x&&(F?.(x),ee?.(x));const S=sessionStorage.getItem("pendingSessionId"),B=e.actualSessionId||S;S&&!a&&(i(B),f(!0),fe?.(B),sessionStorage.removeItem("pendingSessionId")),s&&x&&_e(s.name,x,!1,"codex").then(D=>{Array.isArray(D)&&D.length>0&&J(D)}).catch(D=>{console.error("Error reloading Codex session after completion:",D)}),s&&jt.removeItem(`chat_messages_${s.name}`);break}case"codex-error":if(y)break;k(e.sessionId||a||null),g(!1),b(!1),j(x=>x.map(S=>S?.codexItemKey&&S.isStreaming?{...S,isStreaming:!1}:S)),j(x=>[...x,{type:"error",content:e.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(y)break;const x=e.sessionId||a;k(x),x===a&&(g(!1),b(!1),v(null)),x&&(F?.(x),ee?.(x)),h([]),j(S=>[...S,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(y)break;const x=e.sessionId,S=e.provider||o?.__provider||$e,B=x===a||o&&x===o.id,D=U(ce),Y=de(ce);if(B&&e.isProcessing){if(Y){Z(x,Y);break}g(!0),b(!0),ne?.(x)}else if(B&&e.isProcessing===!1){if(G(x,"session-status")){ue(x,S);break}K(x,S).then(we=>{if(!(we===ve.COMPLETED||we===ve.ABORTED||we===ve.ERRORED)){if(D===ve.STREAMING||D===ve.AWAITING_APPROVAL){m(D);return}g(!1),b(!1),v(null)}})}break}case"claude-status":{const x=e.data;if(x){let S={text:"Working...",tokens:0,can_interrupt:!0};x.message?S.text=x.message:x.status?S.text=x.status:typeof x=="string"&&(S.text=x),x.tokens?S.tokens=x.tokens:x.token_count&&(S.tokens=x.token_count),x.can_interrupt!==void 0&&(S.can_interrupt=x.can_interrupt);const B=px(x,be,te.current);te.current=B,v(B),g(!0),b(S.can_interrupt)}break}}},[$e,le,_,k,a,U,de,c,e,_e,fe,xe,F,ee,ne,re,p,t,K,Z,d,ue,s,o,ce,L,C,b,j,v,i,g,f,h,J,O,G,q,be])}function gr(e){return Array.isArray?Array.isArray(e):qc(e)==="[object Array]"}function l0(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function c0(e){return e==null?"":l0(e)}function lr(e){return typeof e=="string"}function Uc(e){return typeof e=="number"}function d0(e){return e===!0||e===!1||u0(e)&&qc(e)=="[object Boolean]"}function Hc(e){return typeof e=="object"}function u0(e){return Hc(e)&&e!==null}function Wt(e){return e!=null}function Vs(e){return!e.trim().length}function qc(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const p0="Incorrect 'index' type",m0=e=>`Invalid value for key ${e}`,f0=e=>`Pattern length exceeds max of ${e}.`,h0=e=>`Missing ${e} property in key`,g0=e=>`Property 'weight' in key '${e}' must be a positive integer`,oi=Object.prototype.hasOwnProperty;class x0{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(s=>{let o=Kc(s);this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(s=>{s.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Kc(e){let t=null,n=null,s=null,o=1,a=null;if(lr(e)||gr(e))s=e,t=ai(e),n=No(e);else{if(!oi.call(e,"name"))throw new Error(h0("name"));const i=e.name;if(s=i,oi.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(g0(i));t=ai(i),n=No(i),a=e.getFn}return{path:t,id:n,weight:o,src:s,getFn:a}}function ai(e){return gr(e)?e:e.split(".")}function No(e){return gr(e)?e.join("."):e}function y0(e,t){let n=[],s=!1;const o=(a,i,c)=>{if(Wt(a))if(!i[c])n.push(a);else{let d=i[c];const u=a[d];if(!Wt(u))return;if(c===i.length-1&&(lr(u)||Uc(u)||d0(u)))n.push(c0(u));else if(gr(u)){s=!0;for(let p=0,m=u.length;p<m;p+=1)o(u[p],i,c+1)}else i.length&&o(u,i,c+1)}};return o(e,lr(t)?t.split("."):t,0),s?n:n[0]}const v0={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},b0={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},w0={location:0,threshold:.6,distance:100},k0={useExtendedSearch:!1,getFn:y0,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var We={...b0,...v0,...w0,...k0};const j0=/[^ ]+/g;function S0(e=1,t=3){const n=new Map,s=Math.pow(10,t);return{get(o){const a=o.match(j0).length;if(n.has(a))return n.get(a);const i=1/Math.pow(a,.5*e),c=parseFloat(Math.round(i*s)/s);return n.set(a,c),c},clear(){n.clear()}}}class la{constructor({getFn:t=We.getFn,fieldNormWeight:n=We.fieldNormWeight}={}){this.norm=S0(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,s)=>{this._keysMap[n.id]=s})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,lr(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();lr(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,s=this.size();n<s;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!Wt(t)||Vs(t))return;let s={v:t,i:n,n:this.norm.get(t)};this.records.push(s)}_addObject(t,n){let s={i:n,$:{}};this.keys.forEach((o,a)=>{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if(Wt(i)){if(gr(i)){let c=[];const d=[{nestedArrIndex:-1,value:i}];for(;d.length;){const{nestedArrIndex:u,value:p}=d.pop();if(Wt(p))if(lr(p)&&!Vs(p)){let m={v:p,i:u,n:this.norm.get(p)};c.push(m)}else gr(p)&&p.forEach((m,f)=>{d.push({nestedArrIndex:f,value:m})})}s.$[a]=c}else if(lr(i)&&!Vs(i)){let c={v:i,n:this.norm.get(i)};s.$[a]=c}}}),this.records.push(s)}toJSON(){return{keys:this.keys,records:this.records}}}function Vc(e,t,{getFn:n=We.getFn,fieldNormWeight:s=We.fieldNormWeight}={}){const o=new la({getFn:n,fieldNormWeight:s});return o.setKeys(e.map(Kc)),o.setSources(t),o.create(),o}function N0(e,{getFn:t=We.getFn,fieldNormWeight:n=We.fieldNormWeight}={}){const{keys:s,records:o}=e,a=new la({getFn:t,fieldNormWeight:n});return a.setKeys(s),a.setIndexRecords(o),a}function Gn(e,{errors:t=0,currentLocation:n=0,expectedLocation:s=0,distance:o=We.distance,ignoreLocation:a=We.ignoreLocation}={}){const i=t/e.length;if(a)return i;const c=Math.abs(s-n);return o?i+c/o:c?1:i}function C0(e=[],t=We.minMatchCharLength){let n=[],s=-1,o=-1,a=0;for(let i=e.length;a<i;a+=1){let c=e[a];c&&s===-1?s=a:!c&&s!==-1&&(o=a-1,o-s+1>=t&&n.push([s,o]),s=-1)}return e[a-1]&&a-s>=t&&n.push([s,a-1]),n}const Ar=32;function E0(e,t,n,{location:s=We.location,distance:o=We.distance,threshold:a=We.threshold,findAllMatches:i=We.findAllMatches,minMatchCharLength:c=We.minMatchCharLength,includeMatches:d=We.includeMatches,ignoreLocation:u=We.ignoreLocation}={}){if(t.length>Ar)throw new Error(f0(Ar));const p=t.length,m=e.length,f=Math.max(0,Math.min(s,m));let h=a,g=f;const b=c>1||d,v=b?Array(m):[];let j;for(;(j=e.indexOf(t,g))>-1;){let I=Gn(t,{currentLocation:j,expectedLocation:f,distance:o,ignoreLocation:u});if(h=Math.min(I,h),g=j+p,b){let k=0;for(;k<p;)v[j+k]=1,k+=1}}g=-1;let O=[],C=1,L=p+m;const _=1<<p-1;for(let I=0;I<p;I+=1){let k=0,q=L;for(;k<q;)Gn(t,{errors:I,currentLocation:f+q,expectedLocation:f,distance:o,ignoreLocation:u})<=h?k=q:L=q,q=Math.floor((L-k)/2+k);L=q;let G=Math.max(1,f-q+1),re=i?m:Math.min(f+q,m)+p,le=Array(re+2);le[re+1]=(1<<I)-1;for(let Z=re;Z>=G;Z-=1){let U=Z-1,de=n[e.charAt(U)];if(b&&(v[U]=+!!de),le[Z]=(le[Z+1]<<1|1)&de,I&&(le[Z]|=(O[Z+1]|O[Z])<<1|1|O[Z+1]),le[Z]&_&&(C=Gn(t,{errors:I,currentLocation:U,expectedLocation:f,distance:o,ignoreLocation:u}),C<=h)){if(h=C,g=U,g<=f)break;G=Math.max(1,2*f-g)}}if(Gn(t,{errors:I+1,currentLocation:f,expectedLocation:f,distance:o,ignoreLocation:u})>h)break;O=le}const R={isMatch:g>=0,score:Math.max(.001,C)};if(b){const I=C0(v,c);I.length?d&&(R.indices=I):R.isMatch=!1}return R}function A0(e){let t={};for(let n=0,s=e.length;n<s;n+=1){const o=e.charAt(n);t[o]=(t[o]||0)|1<<s-n-1}return t}const ls=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 Gc{constructor(t,{location:n=We.location,threshold:s=We.threshold,distance:o=We.distance,includeMatches:a=We.includeMatches,findAllMatches:i=We.findAllMatches,minMatchCharLength:c=We.minMatchCharLength,isCaseSensitive:d=We.isCaseSensitive,ignoreDiacritics:u=We.ignoreDiacritics,ignoreLocation:p=We.ignoreLocation}={}){if(this.options={location:n,threshold:s,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:p},t=d?t:t.toLowerCase(),t=u?ls(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const m=(h,g)=>{this.chunks.push({pattern:h,alphabet:A0(h),startIndex:g})},f=this.pattern.length;if(f>Ar){let h=0;const g=f%Ar,b=f-g;for(;h<b;)m(this.pattern.substr(h,Ar),h),h+=Ar;if(g){const v=f-Ar;m(this.pattern.substr(v),v)}}else m(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o}=this.options;if(t=n?t:t.toLowerCase(),t=s?ls(t):t,this.pattern===t){let b={isMatch:!0,score:0};return o&&(b.indices=[[0,t.length-1]]),b}const{location:a,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:p}=this.options;let m=[],f=0,h=!1;this.chunks.forEach(({pattern:b,alphabet:v,startIndex:j})=>{const{isMatch:O,score:C,indices:L}=E0(t,b,v,{location:a+j,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:o,ignoreLocation:p});O&&(h=!0),f+=C,O&&L&&(m=[...m,...L])});let g={isMatch:h,score:h?f/this.chunks.length:1};return h&&o&&(g.indices=m),g}}class Sr{constructor(t){this.pattern=t}static isMultiMatch(t){return ii(t,this.multiRegex)}static isSingleMatch(t){return ii(t,this.singleRegex)}search(){}}function ii(e,t){const n=e.match(t);return n?n[1]:null}class _0 extends Sr{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 I0 extends Sr{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const s=t.indexOf(this.pattern)===-1;return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class T0 extends Sr{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 M0 extends Sr{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 D0 extends Sr{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 P0 extends Sr{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 Jc extends Sr{constructor(t,{location:n=We.location,threshold:s=We.threshold,distance:o=We.distance,includeMatches:a=We.includeMatches,findAllMatches:i=We.findAllMatches,minMatchCharLength:c=We.minMatchCharLength,isCaseSensitive:d=We.isCaseSensitive,ignoreDiacritics:u=We.ignoreDiacritics,ignoreLocation:p=We.ignoreLocation}={}){super(t),this._bitapSearch=new Gc(t,{location:n,threshold:s,distance:o,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:p})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Yc extends Sr{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,s;const o=[],a=this.pattern.length;for(;(s=t.indexOf(this.pattern,n))>-1;)n=s+a,o.push([s,n-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const Co=[_0,Yc,T0,M0,P0,D0,I0,Jc],li=Co.length,R0=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,L0="|";function O0(e,t={}){return e.split(L0).map(n=>{let s=n.trim().split(R0).filter(a=>a&&!!a.trim()),o=[];for(let a=0,i=s.length;a<i;a+=1){const c=s[a];let d=!1,u=-1;for(;!d&&++u<li;){const p=Co[u];let m=p.isMultiMatch(c);m&&(o.push(new p(m,t)),d=!0)}if(!d)for(u=-1;++u<li;){const p=Co[u];let m=p.isSingleMatch(c);if(m){o.push(new p(m,t));break}}}return o})}const F0=new Set([Jc.type,Yc.type]);class $0{constructor(t,{isCaseSensitive:n=We.isCaseSensitive,ignoreDiacritics:s=We.ignoreDiacritics,includeMatches:o=We.includeMatches,minMatchCharLength:a=We.minMatchCharLength,ignoreLocation:i=We.ignoreLocation,findAllMatches:c=We.findAllMatches,location:d=We.location,threshold:u=We.threshold,distance:p=We.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o,minMatchCharLength:a,findAllMatches:c,ignoreLocation:i,location:d,threshold:u,distance:p},t=n?t:t.toLowerCase(),t=s?ls(t):t,this.pattern=t,this.query=O0(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:s,isCaseSensitive:o,ignoreDiacritics:a}=this.options;t=o?t:t.toLowerCase(),t=a?ls(t):t;let i=0,c=[],d=0;for(let u=0,p=n.length;u<p;u+=1){const m=n[u];c.length=0,i=0;for(let f=0,h=m.length;f<h;f+=1){const g=m[f],{isMatch:b,indices:v,score:j}=g.search(t);if(b){if(i+=1,d+=j,s){const O=g.constructor.type;F0.has(O)?c=[...c,...v]:c.push(v)}}else{d=0,i=0,c.length=0;break}}if(i){let f={isMatch:!0,score:d/i};return s&&(f.indices=c),f}}return{isMatch:!1,score:1}}}const Eo=[];function B0(...e){Eo.push(...e)}function Ao(e,t){for(let n=0,s=Eo.length;n<s;n+=1){let o=Eo[n];if(o.condition(e,t))return new o(e,t)}return new Gc(e,t)}const cs={AND:"$and",OR:"$or"},_o={PATH:"$path",PATTERN:"$val"},Io=e=>!!(e[cs.AND]||e[cs.OR]),z0=e=>!!e[_o.PATH],W0=e=>!gr(e)&&Hc(e)&&!Io(e),ci=e=>({[cs.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Xc(e,t,{auto:n=!0}={}){const s=o=>{let a=Object.keys(o);const i=z0(o);if(!i&&a.length>1&&!Io(o))return s(ci(o));if(W0(o)){const d=i?o[_o.PATH]:a[0],u=i?o[_o.PATTERN]:o[d];if(!lr(u))throw new Error(m0(d));const p={keyId:No(d),pattern:u};return n&&(p.searcher=Ao(u,t)),p}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=o[d];gr(u)&&u.forEach(p=>{c.children.push(s(p))})}),c};return Io(e)||(e=ci(e)),s(e)}function U0(e,{ignoreFieldNorm:t=We.ignoreFieldNorm}){e.forEach(n=>{let s=1;n.matches.forEach(({key:o,norm:a,score:i})=>{const c=o?o.weight:null;s*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(t?1:a))}),n.score=s})}function H0(e,t){const n=e.matches;t.matches=[],Wt(n)&&n.forEach(s=>{if(!Wt(s.indices)||!s.indices.length)return;const{indices:o,value:a}=s;let i={indices:o,value:a};s.key&&(i.key=s.key.src),s.idx>-1&&(i.refIndex=s.idx),t.matches.push(i)})}function q0(e,t){t.score=e.score}function K0(e,t,{includeMatches:n=We.includeMatches,includeScore:s=We.includeScore}={}){const o=[];return n&&o.push(H0),s&&o.push(q0),e.map(a=>{const{idx:i}=a,c={item:t[i],refIndex:i};return o.length&&o.forEach(d=>{d(a,c)}),c})}class nn{constructor(t,n={},s){this.options={...We,...n},this.options.useExtendedSearch,this._keyStore=new x0(this.options.keys),this.setCollection(t,s)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof la))throw new Error(p0);this._myIndex=n||Vc(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Wt(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let s=0,o=this._docs.length;s<o;s+=1){const a=this._docs[s];t(a,s)&&(this.removeAt(s),s-=1,o-=1,n.push(a))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:s,includeScore:o,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;let d=lr(t)?lr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return U0(d,{ignoreFieldNorm:c}),a&&d.sort(i),Uc(n)&&n>-1&&(d=d.slice(0,n)),K0(d,this._docs,{includeMatches:s,includeScore:o})}_searchStringList(t){const n=Ao(t,this.options),{records:s}=this._myIndex,o=[];return s.forEach(({v:a,i,n:c})=>{if(!Wt(a))return;const{isMatch:d,score:u,indices:p}=n.searchIn(a);d&&o.push({item:a,idx:i,matches:[{score:u,value:a,norm:c,indices:p}]})}),o}_searchLogical(t){const n=Xc(t,this.options),s=(c,d,u)=>{if(!c.children){const{keyId:m,searcher:f}=c,h=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(d,m),searcher:f});return h&&h.length?[{idx:u,item:d,matches:h}]:[]}const p=[];for(let m=0,f=c.children.length;m<f;m+=1){const h=c.children[m],g=s(h,d,u);if(g.length)p.push(...g);else if(c.operator===cs.AND)return[]}return p},o=this._myIndex.records,a={},i=[];return o.forEach(({$:c,i:d})=>{if(Wt(c)){let u=s(n,c,d);u.length&&(a[d]||(a[d]={idx:d,item:c,matches:[]},i.push(a[d])),u.forEach(({matches:p})=>{a[d].matches.push(...p)}))}}),i}_searchObjectList(t){const n=Ao(t,this.options),{keys:s,records:o}=this._myIndex,a=[];return o.forEach(({$:i,i:c})=>{if(!Wt(i))return;let d=[];s.forEach((u,p)=>{d.push(...this._findMatches({key:u,value:i[p],searcher:n}))}),d.length&&a.push({idx:c,item:i,matches:d})}),a}_findMatches({key:t,value:n,searcher:s}){if(!Wt(n))return[];let o=[];if(gr(n))n.forEach(({v:a,i,n:c})=>{if(!Wt(a))return;const{isMatch:d,score:u,indices:p}=s.searchIn(a);d&&o.push({score:u,key:t,value:a,idx:i,norm:c,indices:p})});else{const{v:a,n:i}=n,{isMatch:c,score:d,indices:u}=s.searchIn(a);c&&o.push({score:d,key:t,value:a,norm:i,indices:u})}return o}}nn.version="7.1.0";nn.createIndex=Vc;nn.parseIndex=N0;nn.config=We;nn.parseQuery=Xc;B0($0);var Gs={exports:{}},Js,di;function V0(){if(di)return Js;di=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Js=e,Js}var Ys,ui;function G0(){if(ui)return Ys;ui=1;var e=V0();function t(){}function n(){}return n.resetWarningCache=t,Ys=function(){function s(i,c,d,u,p,m){if(m!==e){var f=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw f.name="Invariant Violation",f}}s.isRequired=s;function o(){return s}var a={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:o,element:s,elementType:s,instanceOf:o,node:s,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},Ys}var pi;function J0(){return pi||(pi=1,Gs.exports=G0()()),Gs.exports}var Y0=J0();const ht=nl(Y0),X0=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 Qr(e,t,n){const s=Q0(e),{webkitRelativePath:o}=e,a=typeof t=="string"?t:typeof o=="string"&&o.length>0?o:`./${e.name}`;return typeof s.path!="string"&&mi(s,"path",a),mi(s,"relativePath",a),s}function Q0(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const s=t.split(".").pop().toLowerCase(),o=X0.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}function mi(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const Z0=[".DS_Store","Thumbs.db"];function ey(e){return Or(this,void 0,void 0,function*(){return ds(e)&&ty(e.dataTransfer)?oy(e.dataTransfer,e.type):ry(e)?ny(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?sy(e):[]})}function ty(e){return ds(e)}function ry(e){return ds(e)&&ds(e.target)}function ds(e){return typeof e=="object"&&e!==null}function ny(e){return To(e.target.files).map(t=>Qr(t))}function sy(e){return Or(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>Qr(n))})}function oy(e,t){return Or(this,void 0,void 0,function*(){if(e.items){const n=To(e.items).filter(o=>o.kind==="file");if(t!=="drop")return n;const s=yield Promise.all(n.map(ay));return fi(Qc(s))}return fi(To(e.files).map(n=>Qr(n)))})}function fi(e){return e.filter(t=>Z0.indexOf(t.name)===-1)}function To(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const s=e[n];t.push(s)}return t}function ay(e){if(typeof e.webkitGetAsEntry!="function")return hi(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?Zc(t):hi(e,t)}function Qc(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?Qc(n):[n]],[])}function hi(e,t){return Or(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const a=yield e.getAsFileSystemHandle();if(a===null)throw new Error(`${e} is not a File`);if(a!==void 0){const i=yield a.getFile();return i.handle=a,Qr(i)}}const s=e.getAsFile();if(!s)throw new Error(`${e} is not a File`);return Qr(s,(n=t?.fullPath)!==null&&n!==void 0?n:void 0)})}function iy(e){return Or(this,void 0,void 0,function*(){return e.isDirectory?Zc(e):ly(e)})}function Zc(e){const t=e.createReader();return new Promise((n,s)=>{const o=[];function a(){t.readEntries(i=>Or(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(iy));o.push(c),a()}else try{const c=yield Promise.all(o);n(c)}catch(c){s(c)}}),i=>{s(i)})}a()})}function ly(e){return Or(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(s=>{const o=Qr(s,e.fullPath);t(o)},s=>{n(s)})})})}var Jn={},gi;function cy(){return gi||(gi=1,Jn.__esModule=!0,Jn.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",o=(e.type||"").toLowerCase(),a=o.replace(/\/.*$/,"");return n.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?s.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):o===c})}return!0}),Jn}var dy=cy();const Xs=nl(dy);function xi(e){return my(e)||py(e)||td(e)||uy()}function uy(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
262
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function py(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function my(e){if(Array.isArray(e))return Mo(e)}function yi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function vi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?yi(Object(n),!0).forEach(function(s){ed(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yi(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function ed(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hn(e,t){return gy(e)||hy(e,t)||td(e,t)||fy()}function fy(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
263
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function td(e,t){if(e){if(typeof e=="string")return Mo(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 Mo(e,t)}}function Mo(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function hy(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(d){a=!0,c=d}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function gy(e){if(Array.isArray(e))return e}var xy=typeof Xs=="function"?Xs:Xs.default,yy="file-invalid-type",vy="file-too-large",by="file-too-small",wy="too-many-files",ky=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=t.split(","),s=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:yy,message:"File type must be ".concat(s)}},bi=function(t){return{code:vy,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},wi=function(t){return{code:by,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},jy={code:wy,message:"Too many files"};function rd(e,t){var n=e.type==="application/x-moz-file"||xy(e,t);return[n,n?null:ky(t)]}function nd(e,t,n){if(_r(e.size))if(_r(t)&&_r(n)){if(e.size>n)return[!1,bi(n)];if(e.size<t)return[!1,wi(t)]}else{if(_r(t)&&e.size<t)return[!1,wi(t)];if(_r(n)&&e.size>n)return[!1,bi(n)]}return[!0,null]}function _r(e){return e!=null}function Sy(e){var t=e.files,n=e.accept,s=e.minSize,o=e.maxSize,a=e.multiple,i=e.maxFiles,c=e.validator;return!a&&t.length>1||a&&i>=1&&t.length>i?!1:t.every(function(d){var u=rd(d,n),p=hn(u,1),m=p[0],f=nd(d,s,o),h=hn(f,1),g=h[0],b=c?c(d):null;return m&&g&&!b})}function us(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Yn(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 ki(e){e.preventDefault()}function Ny(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Cy(e){return e.indexOf("Edge/")!==-1}function Ey(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Ny(e)||Cy(e)}function sr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),i=1;i<o;i++)a[i-1]=arguments[i];return t.some(function(c){return!us(s)&&c&&c.apply(void 0,[s].concat(a)),us(s)})}}function Ay(){return"showOpenFilePicker"in window}function _y(e){if(_r(e)){var t=Object.entries(e).filter(function(n){var s=hn(n,2),o=s[0],a=s[1],i=!0;return sd(o)||(console.warn('Skipped "'.concat(o,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(a)||!a.every(od))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,s){var o=hn(s,2),a=o[0],i=o[1];return vi(vi({},n),{},ed({},a,i))},{});return[{description:"Files",accept:t}]}return e}function Iy(e){if(_r(e))return Object.entries(e).reduce(function(t,n){var s=hn(n,2),o=s[0],a=s[1];return[].concat(xi(t),[o],xi(a))},[]).filter(function(t){return sd(t)||od(t)}).join(",")}function Ty(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function My(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function sd(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function od(e){return/^.*\.[\w]+$/.test(e)}var Dy=["children"],Py=["open"],Ry=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],Ly=["refKey","onChange","onClick"];function Oy(e){return By(e)||$y(e)||ad(e)||Fy()}function Fy(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
264
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $y(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function By(e){if(Array.isArray(e))return Do(e)}function Qs(e,t){return Uy(e)||Wy(e,t)||ad(e,t)||zy()}function zy(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
265
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ad(e,t){if(e){if(typeof e=="string")return Do(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 Do(e,t)}}function Do(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function Wy(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(d){a=!0,c=d}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function Uy(e){if(Array.isArray(e))return e}function ji(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function St(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ji(Object(n),!0).forEach(function(s){Po(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ji(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Po(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ps(e,t){if(e==null)return{};var n=Hy(e,t),s,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)s=a[o],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function Hy(e,t){if(e==null)return{};var n={},s=Object.keys(e),o,a;for(a=0;a<s.length;a++)o=s[a],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var ca=l.forwardRef(function(e,t){var n=e.children,s=ps(e,Dy),o=ld(s),a=o.open,i=ps(o,Py);return l.useImperativeHandle(t,function(){return{open:a}},[a]),Ct.createElement(l.Fragment,null,n(St(St({},i),{},{open:a})))});ca.displayName="Dropzone";var id={disabled:!1,getFilesFromEvent:ey,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};ca.defaultProps=id;ca.propTypes={children:ht.func,accept:ht.objectOf(ht.arrayOf(ht.string)),multiple:ht.bool,preventDropOnDocument:ht.bool,noClick:ht.bool,noKeyboard:ht.bool,noDrag:ht.bool,noDragEventsBubbling:ht.bool,minSize:ht.number,maxSize:ht.number,maxFiles:ht.number,disabled:ht.bool,getFilesFromEvent:ht.func,onFileDialogCancel:ht.func,onFileDialogOpen:ht.func,useFsAccessApi:ht.bool,autoFocus:ht.bool,onDragEnter:ht.func,onDragLeave:ht.func,onDragOver:ht.func,onDrop:ht.func,onDropAccepted:ht.func,onDropRejected:ht.func,onError:ht.func,validator:ht.func};var Ro={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function ld(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=St(St({},id),e),n=t.accept,s=t.disabled,o=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,c=t.multiple,d=t.maxFiles,u=t.onDragEnter,p=t.onDragLeave,m=t.onDragOver,f=t.onDrop,h=t.onDropAccepted,g=t.onDropRejected,b=t.onFileDialogCancel,v=t.onFileDialogOpen,j=t.useFsAccessApi,O=t.autoFocus,C=t.preventDropOnDocument,L=t.noClick,_=t.noKeyboard,R=t.noDrag,I=t.noDragEventsBubbling,k=t.onError,q=t.validator,G=l.useMemo(function(){return Iy(n)},[n]),re=l.useMemo(function(){return _y(n)},[n]),le=l.useMemo(function(){return typeof v=="function"?v:Si},[v]),K=l.useMemo(function(){return typeof b=="function"?b:Si},[b]),Z=l.useRef(null),U=l.useRef(null),de=l.useReducer(qy,Ro),ue=Qs(de,2),ce=ue[0],J=ue[1],_e=ce.isFocused,F=ce.isFileDialogActive,ee=l.useRef(typeof window<"u"&&window.isSecureContext&&j&&Ay()),ne=function(){!ee.current&&F&&setTimeout(function(){if(U.current){var V=U.current.files;V.length||(J({type:"closeDialog"}),K())}},300)};l.useEffect(function(){return window.addEventListener("focus",ne,!1),function(){window.removeEventListener("focus",ne,!1)}},[U,F,K,ee]);var xe=l.useRef([]),fe=function(V){Z.current&&Z.current.contains(V.target)||(V.preventDefault(),xe.current=[])};l.useEffect(function(){return C&&(document.addEventListener("dragover",ki,!1),document.addEventListener("drop",fe,!1)),function(){C&&(document.removeEventListener("dragover",ki),document.removeEventListener("drop",fe))}},[Z,C]),l.useEffect(function(){return!s&&O&&Z.current&&Z.current.focus(),function(){}},[Z,O,s]);var be=l.useCallback(function(A){k?k(A):console.error(A)},[k]),te=l.useCallback(function(A){A.preventDefault(),A.persist(),De(A),xe.current=[].concat(Oy(xe.current),[A.target]),Yn(A)&&Promise.resolve(o(A)).then(function(V){if(!(us(A)&&!I)){var y=V.length,x=y>0&&Sy({files:V,accept:G,minSize:i,maxSize:a,multiple:c,maxFiles:d,validator:q}),S=y>0&&!x;J({isDragAccept:x,isDragReject:S,isDragActive:!0,type:"setDraggedFiles"}),u&&u(A)}}).catch(function(V){return be(V)})},[o,u,be,I,G,i,a,c,d,q]),Se=l.useCallback(function(A){A.preventDefault(),A.persist(),De(A);var V=Yn(A);if(V&&A.dataTransfer)try{A.dataTransfer.dropEffect="copy"}catch{}return V&&m&&m(A),!1},[m,I]),$e=l.useCallback(function(A){A.preventDefault(),A.persist(),De(A);var V=xe.current.filter(function(x){return Z.current&&Z.current.contains(x)}),y=V.indexOf(A.target);y!==-1&&V.splice(y,1),xe.current=V,!(V.length>0)&&(J({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Yn(A)&&p&&p(A))},[Z,p,I]),he=l.useCallback(function(A,V){var y=[],x=[];A.forEach(function(S){var B=rd(S,G),D=Qs(B,2),Y=D[0],we=D[1],Ie=nd(S,i,a),Oe=Qs(Ie,2),dt=Oe[0],Ne=Oe[1],Re=q?q(S):null;if(Y&&dt&&!Re)y.push(S);else{var lt=[we,Ne];Re&&(lt=lt.concat(Re)),x.push({file:S,errors:lt.filter(function(gt){return gt})})}}),(!c&&y.length>1||c&&d>=1&&y.length>d)&&(y.forEach(function(S){x.push({file:S,errors:[jy]})}),y.splice(0)),J({acceptedFiles:y,fileRejections:x,isDragReject:x.length>0,type:"setFiles"}),f&&f(y,x,V),x.length>0&&g&&g(x,V),y.length>0&&h&&h(y,V)},[J,c,G,i,a,d,f,h,g,q]),nt=l.useCallback(function(A){A.preventDefault(),A.persist(),De(A),xe.current=[],Yn(A)&&Promise.resolve(o(A)).then(function(V){us(A)&&!I||he(V,A)}).catch(function(V){return be(V)}),J({type:"reset"})},[o,he,be,I]),Le=l.useCallback(function(){if(ee.current){J({type:"openDialog"}),le();var A={multiple:c,types:re};window.showOpenFilePicker(A).then(function(V){return o(V)}).then(function(V){he(V,null),J({type:"closeDialog"})}).catch(function(V){Ty(V)?(K(V),J({type:"closeDialog"})):My(V)?(ee.current=!1,U.current?(U.current.value=null,U.current.click()):be(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):be(V)});return}U.current&&(J({type:"openDialog"}),le(),U.current.value=null,U.current.click())},[J,le,K,j,he,be,re,c]),ke=l.useCallback(function(A){!Z.current||!Z.current.isEqualNode(A.target)||(A.key===" "||A.key==="Enter"||A.keyCode===32||A.keyCode===13)&&(A.preventDefault(),Le())},[Z,Le]),Ee=l.useCallback(function(){J({type:"focus"})},[]),Fe=l.useCallback(function(){J({type:"blur"})},[]),rt=l.useCallback(function(){L||(Ey()?setTimeout(Le,0):Le())},[L,Le]),He=function(V){return s?null:V},Xe=function(V){return _?null:He(V)},pe=function(V){return R?null:He(V)},De=function(V){I&&V.stopPropagation()},at=l.useMemo(function(){return function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},V=A.refKey,y=V===void 0?"ref":V,x=A.role,S=A.onKeyDown,B=A.onFocus,D=A.onBlur,Y=A.onClick,we=A.onDragEnter,Ie=A.onDragOver,Oe=A.onDragLeave,dt=A.onDrop,Ne=ps(A,Ry);return St(St(Po({onKeyDown:Xe(sr(S,ke)),onFocus:Xe(sr(B,Ee)),onBlur:Xe(sr(D,Fe)),onClick:He(sr(Y,rt)),onDragEnter:pe(sr(we,te)),onDragOver:pe(sr(Ie,Se)),onDragLeave:pe(sr(Oe,$e)),onDrop:pe(sr(dt,nt)),role:typeof x=="string"&&x!==""?x:"presentation"},y,Z),!s&&!_?{tabIndex:0}:{}),Ne)}},[Z,ke,Ee,Fe,rt,te,Se,$e,nt,_,R,s]),Ke=l.useCallback(function(A){A.stopPropagation()},[]),Be=l.useMemo(function(){return function(){var A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},V=A.refKey,y=V===void 0?"ref":V,x=A.onChange,S=A.onClick,B=ps(A,Ly),D=Po({accept:G,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:He(sr(x,nt)),onClick:He(sr(S,Ke)),tabIndex:-1},y,U);return St(St({},D),B)}},[U,n,c,nt,s]);return St(St({},ce),{},{isFocused:_e&&!s,getRootProps:at,getInputProps:Be,rootRef:Z,inputRef:U,open:He(Le)})}function qy(e,t){switch(t.type){case"focus":return St(St({},e),{},{isFocused:!0});case"blur":return St(St({},e),{},{isFocused:!1});case"openDialog":return St(St({},Ro),{},{isFileDialogActive:!0});case"closeDialog":return St(St({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return St(St({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return St(St({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"reset":return St({},Ro);default:return e}}function Si(){}const Ni={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"]}},Ci={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 Ei(e){return Ni[e]||Ni.claude}function Ai(e){return Ci[e]||Ci.claude}function Ky(e){return e==="claude"||e==="codex"}function Vy(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}let _i=!1;function Gy(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Jy(e){return new Promise((t,n)=>{if(!(e instanceof Blob)){n(new Error("无效的图片文件"));return}const s=new FileReader;s.onload=()=>t(typeof s.result=="string"?s.result:""),s.onerror=()=>n(s.error||new Error("读取图片失败")),s.readAsDataURL(e)})}async function Yy(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(n,s)=>{const o=await Jy(n);if(!o)throw new Error("图片编码失败");return{name:n?.name||`image-${s+1}.png`,data:o,size:Number(n?.size)||0,mimeType:n?.type||"application/octet-stream"}}))}function Xy(e){const t=String(e||"").trim();if(!t)return"";const n=t.split(/[\\/]/);return n[n.length-1]||t}function Qy(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:Xy(n)}:null}).filter(Boolean)}function Zy(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 s=`Mode ${t+1}`;return{id:n,name:String(e.name||e.label||n||s).trim()||s,description:typeof e.description=="string"?e.description:""}}function Zs(e=null){const t=e?.acpModes?.availableModes||e?.modes?.availableModes||e?.availableModes||[],n=Array.isArray(t)?t.map((o,a)=>Zy(o,a)).filter(Boolean):[],s=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:s}}function Ii(e){return String(e||"").trim().replace(/^\//,"").toLowerCase()}function ev(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 s=n.startsWith("/")?n:`/${n}`;return{...e,id:String(e.id||s||`acp-${t}`).trim(),name:s,description:typeof e.description=="string"?e.description:"",type:"acp",source:"acp"}}function tv(e=null){const t=e?.acpAvailableCommands||e?.availableCommands||e?.acpCommands||[];return Array.isArray(t)?t.map((n,s)=>ev(n,s)).filter(Boolean):[]}function rv(e=[],t=[]){const n=Array.isArray(t)?t:[],s=Array.isArray(e)?e:[],o=new Set(n.map(i=>Ii(i?.name)).filter(Boolean)),a=s.filter(i=>!o.has(Ii(i?.name)));return[...n,...a]}function nv({selectedProject:e,selectedSession:t,selectedProjectRef:n,currentSessionId:s,canAbortSession:o,isLoading:a,setChatMessages:i,setCanAbortSession:c,setRuntimePhase:d,setClaudeStatus:u,pendingPermissionRequests:p,setPendingPermissionRequests:m,sendMessage:f,onSessionActive:h,onInputFocusChange:g,onShowSettings:b,onFileOpen:v,appendSessionConversationEvent:j,startLocalRunGuard:O,pendingViewSessionRef:C,scrollToBottom:L,setIsUserScrolledUp:_,tokenBudget:R,chatMessages:I,setSessionMessages:k,resetRuntimeForNewChat:q,urlContext:G,urlPrompt:re,integrationClientId:le,latestIntegrationMessage:K,sendIntegrationMessage:Z,sendByCtrlEnter:U}){const{t:de}=Et("chat"),[ue,ce]=l.useState(()=>typeof window<"u"&&e?.name&&jt.getItem(`draft_input_${e.name}`)||""),[J,_e]=l.useState(!1),[F,ee]=l.useState([]),[ne,xe]=l.useState(new Map),[fe,be]=l.useState(new Map),[te,Se]=l.useState(!1),[$e,he]=l.useState([]),[nt,Le]=l.useState([]),[ke,Ee]=l.useState([]),[Fe,rt]=l.useState(-1),[He,Xe]=l.useState(0),[pe,De]=l.useState(-1),[at,Ke]=l.useState(!1),[Be,A]=l.useState([]),[V,y]=l.useState([]),[x,S]=l.useState([]),[B,D]=l.useState(""),[Y,we]=l.useState(!1),[Ie,Oe]=l.useState(-1),[dt,Ne]=l.useState(-1),[Re,lt]=l.useState(()=>{const w=Vt(localStorage.getItem("selected-provider"));return Ei(w).defaultMode}),gt=l.useMemo(()=>Zs(t),[t]),[It,pt]=l.useState(()=>gt.currentModeId),[Nt,bt]=l.useState("none"),[ye,X]=l.useState(()=>Vt(localStorage.getItem("selected-provider"))),[ie,oe]=l.useState(()=>Kn("claude")),[Je,ct]=l.useState(()=>Kn("codex")),[wt,Pe]=l.useState(()=>Kn("gemini")),[M,W]=l.useState(()=>Kn("opencode")),[Ce,st]=l.useState({}),[kt,E]=l.useState({}),[je,T]=l.useState({}),[P,ae]=l.useState({}),[Ve,xt]=l.useState({}),[ot,H]=l.useState({}),N=l.useMemo(()=>ti(G),[G]),[se,Te]=l.useState(N),[ge,Qe]=l.useState(N),[et,vt]=l.useState(!1),qe=l.useRef(null),mt=l.useRef(null),Ze=l.useRef(null),Ae=l.useRef(null),Pt=l.useRef(null),Ht=l.useRef(null),ur=l.useRef(N),Tt=l.useRef(!1),qt=l.useRef(null),ha=l.useRef(ye),pr=l.useMemo(()=>Ei(ye),[ye]),br=l.useMemo(()=>rv(Be,V),[V,Be]),Nr=l.useMemo(()=>Ai(ye),[ye]),Nn=ye==="claude"?ie:ye==="codex"?Je:ye==="gemini"?wt:M,ga=l.useMemo(()=>Kx(ye).OPTIONS,[ye]),As=l.useMemo(()=>(Ce[ye]||[]).map(w=>({value:w,label:w})),[Ce,ye]),Cr=t?.__provider===ye&&Xx(ye,t?.model)?t.model.trim():"",Rt=Cr||Nn,Cn=l.useMemo(()=>{const w=As.length>0?As:ga;return!Cr||w.some($=>$.value===Cr)?w:[{value:Cr,label:Cr},...w]},[As,ga,Cr]),Pd=Cn.find(w=>w.value===Rt)?.label||Rt||de("providerSelection.selectModel"),Rd=!!Cr,Ld=ye==="opencode"&&!!je.opencode,_s=l.useCallback((w,{short:$=!1}={})=>{let z=de("codex.modes.default");return w==="acceptEdits"?z=de("codex.modes.acceptEdits"):w==="bypassPermissions"?z=de("codex.modes.bypassPermissions"):w==="plan"&&(z=de("codex.modes.plan")),$?z.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):z},[de]),Od=l.useMemo(()=>_s(Re,{short:!0}),[_s,Re]),Fd=l.useMemo(()=>de("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[de]),Is=l.useCallback(async(w,{force:$=!1}={})=>{if(!Hx.includes(w))return null;xt(z=>({...z,[w]:!0})),H(z=>({...z,[w]:null})),ae(z=>({...z,[w]:{status:Ux}}));try{const Q=await me(`/api/cli/providers/${w}/installation-status${$?"?force=true":""}`),Me=await Q.json().catch(()=>({}));if(!Q.ok||Me?.success!==!0)throw new Error(Me?.error||`Failed to check ${w} installation`);const Ye=Me.installed?Wx:Ks;return ae(ut=>({...ut,[w]:{status:Ye,command:Me.command||null,resolvedPath:Me.resolvedPath||null,reason:Me.reason||null,installHint:Me.installHint||null,checkedAt:Me.checkedAt||null,cacheHit:!!Me.cacheHit}})),Ye}catch(z){return ae(Q=>({...Q,[w]:{status:qn}})),H(Q=>({...Q,[w]:z.message})),qn}finally{xt(z=>({...z,[w]:!1}))}},[H,xt,ae]),$d=l.useCallback(w=>{if(!w)return;const $=Vt(w);X($),localStorage.setItem("selected-provider",$),Is($)},[Is]);l.useEffect(()=>{const w=Cn.map($=>$.value);!Nn||w.includes(Nn)||(ye==="claude"?oe(""):ye==="codex"?ct(""):ye==="gemini"?Pe(""):ye==="opencode"&&W(""),Gx(ye))},[ye,Nn,Cn]),l.useEffect(()=>{if(!e)return;const w=e.fullPath||e.path;if(!w)return;const $=`runtime-models:v2:${ye}:${w}`,z=al(jt.getItem($)),Q=Array.isArray(z?.models)?z.models:[],Me=typeof z?.currentModel=="string"?z.currentModel.trim():"",Ye=Number(z?.timestamp||0);if(Q.length>0&&Date.now()-Ye<qx){st(ft=>({...ft,[ye]:Q})),Me&&E(ft=>({...ft,[ye]:{...ft?.[ye]||{},currentModel:Me}}));return}let Mt=!1;return T(ft=>({...ft,[ye]:!0})),it.providerDiscovery(ye,w).then(async ft=>{if(!ft.ok)throw new Error(`HTTP ${ft.status}`);return ft.json()}).then(ft=>{if(Mt)return;const Bt=Array.isArray(ft?.models)?ft.models.map(wr=>wr.id):[],rr=typeof ft?.currentModel=="string"?ft.currentModel.trim():"";E(wr=>({...wr,[ye]:ft})),st(wr=>({...wr,[ye]:Bt})),Bt.length>0&&jt.setItem($,JSON.stringify({models:Bt,currentModel:rr||"",timestamp:Date.now()}))}).catch(()=>{Mt||st(ft=>({...ft,[ye]:Q}))}).finally(()=>{Mt||T(ft=>({...ft,[ye]:!1}))}),()=>{Mt=!0}},[ye,e]),l.useEffect(()=>{ur.current=ge},[ge]);const xa=l.useRef(_i);l.useEffect(()=>{if(xa.current)return;const w=So(re);w&&(ce(w),Tt.current=!0,xa.current=!0,_i=!0)},[re]),l.useEffect(()=>{Te(N),Qe(N),vt(!1)},[N]);const Qt=l.useCallback((w,$,z={})=>{!$||typeof Z!="function"||Z({type:w,requestId:$,payload:{...z,clientId:le||null}})},[le,Z]),ya=l.useCallback((w,$=null)=>{if(typeof w?.context!="object"||w.context==null||Array.isArray(w.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),Qt("integration.error",$,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(Ix(w.mode)===jo){const Me=_x(ur.current,w.context);if(!Me){console.warn("[DynamicContext] Ignored invalid append context payload."),Qt("integration.error",$,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Te(Me),Qe(Me),vt(!1),Qt("integration.ack",$,{accepted:!0,applied:!0});return}const Q=ti(w.context);if(!Q){Qt("integration.error",$,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Te(Q),Qe(Q),vt(!1),Qt("integration.ack",$,{accepted:!0,applied:!0})},[Qt]),va=l.useCallback((w,$=null)=>{if(typeof w?.prompt!="string"){Qt("integration.error",$,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const z=So(w.prompt);if(ce(z),Tt.current=!0,w.autoSend===!0&&z&&n.current&&!a&&Ht.current){const Q={preventDefault:()=>{}};Ht.current(Q,z)}Qt("integration.ack",$,{accepted:!0,applied:!0})},[a,n,Qt]),ba=l.useCallback((w=null)=>{Qt("integration.ack",w,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,Qt]);l.useEffect(()=>{if(!K?.__messageSeq)return;const $=K?.type;if($==="integration.context.update"){ya(K.payload||{},K.requestId||null);return}if($==="integration.prompt.update"){va(K.payload||{},K.requestId||null);return}$==="integration.ping"&&ba(K.requestId||null)},[ya,va,K,ba]);const sn=l.useMemo(()=>et||!ge||!Sx(ge)?null:ge,[et,ge]),Bd=l.useMemo(()=>sn?.selectedElements?.slice(0,Qa)||[],[sn]),zd=l.useMemo(()=>sn?.selectedElements?.slice(Qa)||[],[sn]),Wd=l.useCallback(()=>{Qe(w=>!w||!cr(w.systemContext)?w:{...w,systemContext:""})},[]),Ud=l.useCallback(()=>{Qe(w=>!w||!cr(Xr(w.currentFile))?w:{...w,currentFile:{path:"",displayName:""}})},[]),Hd=l.useCallback(w=>{Qe($=>{if(!$||!Array.isArray($.selectedElements)||$.selectedElements.length===0)return $;const z=$.selectedElements.findIndex(Q=>Q.tag===w.tag&&Q.selector===w.selector&&Q.label===w.label);return z<0?$:{...$,selectedElements:$.selectedElements.filter((Q,Me)=>Me!==z)}})},[]);l.useEffect(()=>{if(t?.id){const w=localStorage.getItem(`permissionMode-${t.id}`);w&&pr.modes.includes(w)?lt(w):lt(pr.defaultMode)}},[t?.id,pr]),l.useEffect(()=>{pr.modes.includes(Re)||lt(pr.defaultMode)},[Re,pr]),l.useEffect(()=>{if(!Nr.enabled){Nt!==Nr.defaultMode&&bt(Nr.defaultMode);return}Nr.modes.includes(Nt)||bt(Nr.defaultMode)},[Nr,Nt]),l.useEffect(()=>{if(t&&t.__provider&&t.__provider!==ye){const w=Vt(t.__provider);X(w),localStorage.setItem("selected-provider",w)}if(t?.id&&t?.__provider)try{const w=localStorage.getItem("session-provider-map"),$=w?JSON.parse(w):{};$[t.id]!==t.__provider&&($[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify($)))}catch{}},[ye,t]),l.useEffect(()=>{ha.current!==ye&&(m([]),ha.current=ye)},[ye,m]),l.useEffect(()=>{m(w=>w.filter($=>!$.sessionId||$.sessionId===t?.id))},[t?.id,m]),l.useEffect(()=>{const w=Zs(t),$=new Set(w.availableModes.map(z=>z.id));pt(z=>w.currentModeId&&$.has(w.currentModeId)?w.currentModeId:z&&$.has(z)?z:"")},[t]),l.useEffect(()=>{y(tv(t))},[t]),l.useEffect(()=>{(async()=>{if(e)try{const $=await me("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!$.ok)throw new Error("Failed to fetch commands");const z=await $.json(),Q=[...(z.builtIn||[]).map(ut=>({...ut,type:"built-in"})),...(z.custom||[]).map(ut=>({...ut,type:"custom"}))];A(Q);const Me=`command_history_${e.name}`,Ye=jt.getItem(Me);if(Ye)try{const ut=JSON.parse(Ye),Mt=[...Q].sort((ft,Bt)=>{const rr=ut[ft.name]||0;return(ut[Bt.name]||0)-rr});A(Mt)}catch(ut){console.error("Error parsing command history:",ut)}}catch($){console.error("Error fetching slash commands:",$),A([])}})()},[e]);const Ts=l.useMemo(()=>br.length?new nn(br,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[br]);l.useEffect(()=>{if(!B){S(br);return}if(!Ts){S([]);return}const w=Ts.search(B);S(w.map($=>$.item))},[B,br,Ts]);const qd=l.useMemo(()=>{if(!e||br.length===0)return[];const w=`command_history_${e.name}`,$=jt.getItem(w);if(!$)return[];try{const z=JSON.parse($);return br.map(Q=>({...Q,usageCount:z[Q.name]||0})).filter(Q=>Q.usageCount>0).sort((Q,Me)=>Me.usageCount-Q.usageCount).slice(0,5)}catch(z){return console.error("Error parsing command history:",z),[]}},[br,e]),wa=l.useCallback(w=>{const{action:$,data:z}=w;switch($){case"clear":i([]),k([]);break;case"help":i(Q=>[...Q,{role:"assistant",content:z.content,timestamp:Date.now()}]);break;case"model":{const Q=Object.entries(z.available||{}).filter(([,Ye])=>Array.isArray(Ye)&&Ye.length>0).map(([Ye,ut])=>`**${Ye.charAt(0).toUpperCase()+Ye.slice(1)}**: ${ut.join(", ")}`).join(`
|
|
266
|
+
|
|
267
|
+
`),Me=z.current.provider==="opencode"?z.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";i(Ye=>[...Ye,{role:"assistant",content:`**Current Model**: ${z.current.model}
|
|
268
|
+
|
|
269
|
+
**Available Models**:
|
|
270
|
+
|
|
271
|
+
${Q}${Me?`
|
|
272
|
+
|
|
273
|
+
${Me}`:""}`,timestamp:Date.now()}]);break}case"cost":{const Q=`**Token Usage**: ${z.tokenUsage.used.toLocaleString()} / ${z.tokenUsage.total.toLocaleString()} (${z.tokenUsage.percentage}%)
|
|
274
|
+
|
|
275
|
+
**Estimated Cost**:
|
|
276
|
+
- Input: $${z.cost.input}
|
|
277
|
+
- Output: $${z.cost.output}
|
|
278
|
+
- **Total**: $${z.cost.total}
|
|
279
|
+
|
|
280
|
+
**Model**: ${z.model}`;i(Me=>[...Me,{role:"assistant",content:Q,timestamp:Date.now()}]);break}case"status":{const Q=`**System Status**
|
|
281
|
+
|
|
282
|
+
- Version: ${z.version}
|
|
283
|
+
- Uptime: ${z.uptime}
|
|
284
|
+
- Model: ${z.model}
|
|
285
|
+
- Provider: ${z.provider}
|
|
286
|
+
- Node.js: ${z.nodeVersion}
|
|
287
|
+
- Platform: ${z.platform}`;i(Me=>[...Me,{role:"assistant",content:Q,timestamp:Date.now()}]);break}case"memory":z.error?i(Q=>[...Q,{role:"assistant",content:`⚠️ ${z.message}`,timestamp:Date.now()}]):(i(Q=>[...Q,{role:"assistant",content:`📝 ${z.message}
|
|
288
|
+
|
|
289
|
+
Path: \`${z.path}\``,timestamp:Date.now()}]),z.exists&&v&&v(z.path));break;case"config":b&&b();break;case"rewind":z.error?i(Q=>[...Q,{role:"assistant",content:`⚠️ ${z.message}`,timestamp:Date.now()}]):(i(Q=>Q.slice(0,-z.steps*2)),i(Q=>[...Q,{role:"assistant",content:`⏪ ${z.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",$)}},[v,b,i,k]),ka=l.useCallback(async w=>{const{content:$,hasBashCommands:z}=w;if(z&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){i(Me=>[...Me,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}ce($),setTimeout(()=>{if(Ht.current){const Q={preventDefault:()=>{}};Ht.current(Q)}},50)},[i]),En=l.useCallback(async w=>{if(!(!w||!e))try{const $=ue.match(new RegExp(`${w.name}\\s*(.*)`)),z=$&&$[1]?$[1].trim().split(/\s+/):[],Q={projectPath:e.path,projectName:e.name,sessionId:s,provider:ye,...Rt?{model:Rt}:{},tokenUsage:R},Me=await me("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:w.name,commandPath:w.path,args:z,context:Q})});if(!Me.ok)throw new Error("Failed to execute command");const Ye=await Me.json();Ye.type==="builtin"?wa(Ye):Ye.type==="custom"&&await ka(Ye,z),ce(""),Ke(!1),Ne(-1),D(""),Oe(-1)}catch($){console.error("Error executing command:",$),i(z=>[...z,{role:"assistant",content:`Error executing command: ${$.message}`,timestamp:Date.now()}])}},[Rt,s,wa,ka,ue,ye,e,i,R]),Kd=l.useCallback(w=>{const $=String(w||"").trim();if(!$||$===It)return;pt($);const z=t?.id||s;if(!z)return;const Q=t?.__provider||ye||"claude";f({type:"set-session-mode",provider:Q,sessionId:z,modeId:$})},[It,s,ye,t?.__provider,t?.id,f]),An=l.useCallback(w=>{if(!w||!e?.name)return;const $=`command_history_${e.name}`,z=jt.getItem($);let Q={};try{Q=z?JSON.parse(z):{}}catch(Me){console.error("Error parsing command history:",Me)}Q[w.name]=(Q[w.name]||0)+1,jt.setItem($,JSON.stringify(Q))},[e?.name]),Vd=l.useCallback((w,$,z)=>{if(!(!w||!e)){if(z){Oe($);return}if(An(w),w?.source==="acp"){const Q=String(w.name||"").trim(),Me=Q.startsWith("/")?`${Q} `:`/${Q} `;ce(Me),Ke(!1),Ne(-1),D(""),Oe(-1);return}En(w)}},[En,An,e]),Ms=l.useCallback(w=>{if(!w)return;const $=w?.source==="acp",z=String(w.name||"").trim(),Q=$&&z&&!z.startsWith("/")?`/${z}`:z,Me=ue.slice(0,dt),Ye=ue.slice(dt),ut=Ye.indexOf(" "),Mt=ut!==-1?Ye.slice(ut):"",ft=`${Me}${Q} ${Mt}`;ce(ft),Ke(!1),Ne(-1),D(""),Oe(-1),qt.current&&clearTimeout(qt.current),An(w),$||En(w)},[En,An,ue,dt]);l.useEffect(()=>{e&&it.getFiles(e.name).then(async w=>w.ok?w.json():[]).then(w=>{he(Rc(w))}).catch(w=>{console.error("Error fetching files:",w)})},[e]),l.useEffect(()=>{const w=ue.slice(0,He),$=w.lastIndexOf("@");if($!==-1){const z=w.slice($+1);if(z.includes(" "))Se(!1),De(-1);else{De($),Se(!0);const Q=$e.filter(Me=>Me.name.toLowerCase().includes(z.toLowerCase())||Me.path.toLowerCase().includes(z.toLowerCase())).slice(0,10);Ee(Q),rt(-1)}}else Se(!1),De(-1)},[ue,He,$e]);const on=l.useMemo(()=>!ue||nt.length===0?[]:nt.filter(w=>ue.includes(w)),[nt,ue]),an=l.useMemo(()=>on.length===0?[]:Array.from(new Set(on)).sort((w,$)=>$.length-w.length),[on]),Ds=l.useMemo(()=>an.length===0?null:new RegExp(`(${an.map(vx).join("|")})`,"g"),[an]),ja=l.useMemo(()=>new Set(an),[an]),Gd=l.useCallback(w=>w?Ds?w.split(Ds).map((z,Q)=>ja.has(z)?r.jsx("span",{className:"bg-primary/20 -ml-0.5 dark:bg-primary/25 px-0.5 rounded-md box-decoration-clone text-transparent",children:z},`mention-${Q}`):r.jsx("span",{children:z},`text-${Q}`)):w:"",[Ds,ja]),_n=l.useCallback(w=>{const $=w.filter(z=>{try{if(!z||typeof z!="object"||!z.type||!z.type.startsWith("image/"))return!1;if(!z.size||z.size>5242880){const Q=z.name||"Unknown file";return be(Me=>{const Ye=new Map(Me);return Ye.set(Q,"File too large (max 5MB)"),Ye}),!1}return!0}catch(Q){return console.error("Error validating file:",Q,z),!1}});$.length>0&&ee(z=>[...z,...$].slice(0,5))},[]),Jd=l.useCallback(w=>{const $=Array.from(w.clipboardData.items);for(const z of $)if(z.type.startsWith("image/")){const Q=z.getAsFile();Q&&_n([Q])}if($.length===0&&w.clipboardData.files.length>0){const Q=Array.from(w.clipboardData.files).filter(Me=>Me.type.startsWith("image/"));Q.length>0&&_n(Q)}},[_n]),{getRootProps:Yd,getInputProps:Xd,isDragActive:Qd,open:Zd}=ld({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:_n,noClick:!0,noKeyboard:!0}),Br=l.useCallback(async(w,$=null)=>{w.preventDefault();const z=typeof $=="string"?$:ue,Q=t?.__provider||ye||"claude";if((P[Q]?.status||qn)===Ks||!z.trim()||a||!e)return;let Ye=z;const ut=Ai(Q),Mt=ut.enabled?vp.find(_t=>_t.id===Nt):null;ut.strategy==="prompt-prefix"&&Mt?.prefix&&(Ye=`${Mt.prefix}: ${z}`);const ft=!et&&jx(ge)?Tx(ge):null;ft&&(Ye=Mx(ft,Ye)),d("queued"),u(aa({phaseText:de("activity.stage.generatingReply"),detailText:de("activity.detail.preparingReply"),canAbort:!0}));let Bt=[];if(F.length>0){if(!Ky(Q)){d("idle"),c(!1),u(null),i(_t=>[..._t,{type:"error",content:`${Q} 当前不支持图片输入`,timestamp:new Date}]);return}try{Bt=await Yy(F)}catch(_t){console.error("Image preparation failed:",_t),d("idle"),c(!1),u(null),i(Tn=>[...Tn,{type:"error",content:`图片处理失败:${_t.message}`,timestamp:new Date}]);return}}const rr=Qy(on),wr=[...Bt.map(_t=>({type:"image",data:_t.data,mimeType:_t.mimeType,name:_t.name})),...rr],Wr=Gy(),Ea={type:"user",content:z,provider:Q,images:Bt,contentBlocks:rr,timestamp:new Date,clientRequestId:Wr};i(_t=>[..._t,Ea]),_(!1),setTimeout(()=>L(),100);const Dt=s||t?.id;O(Dt||t?.id||null),Dt&&j(Lt({kind:"user_message",provider:Q,sessionId:Dt,timestamp:Ea.timestamp,payload:{text:z,contentBlocks:wr},extensions:{clientRequestId:Wr,optimistic:!0}}));const hu=Dt||`new-session-${Date.now()}`;!Dt&&!t?.id&&(C.current={sessionId:null,startedAt:Date.now()}),h&&h(hu);const gu=(()=>{try{const _t=ye==="codex"?"codex-settings":"claude-settings",Tn=jt.getItem(_t);if(Tn)return JSON.parse(Tn)}catch(_t){console.error("Error loading tools settings:",_t)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(Q==="codex"){const _t=ut.enabled&&ut.strategy==="native-effort"?Vy(Nt):void 0;f({type:"codex-command",clientRequestId:Wr,command:Ye,sessionId:Dt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Dt,resume:!!Dt,permissionMode:Re==="plan"?"default":Re,...Rt?{model:Rt}:{},..._t?{modelReasoningEffort:_t}:{},images:Bt,resourceLinks:rr}})}else f(Q==="gemini"?{type:"gemini-command",clientRequestId:Wr,command:Ye,sessionId:Dt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Dt,resume:!!Dt,permissionMode:Re==="plan"?"default":Re,...Rt?{model:Rt}:{},images:Bt,resourceLinks:rr}}:Q==="opencode"?{type:"opencode-command",clientRequestId:Wr,command:Ye,sessionId:Dt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Dt,resume:!!Dt,permissionMode:Re==="plan"?"default":Re,...Rt?{model:Rt}:{},images:Bt,resourceLinks:rr}}:{type:"claude-command",clientRequestId:Wr,command:Ye,options:{projectPath:e.path,cwd:e.fullPath,sessionId:Dt,resume:!!Dt,toolsSettings:gu,permissionMode:Re,...Rt?{model:Rt}:{},images:Bt,resourceLinks:rr}});ft&&vt(!0),ce(""),ee([]),xe(new Map),be(new Map),we(!1),bt("none"),qe.current&&(qe.current.style.height="auto"),e&&jt.removeItem(`draft_input_${e.name}`)},[on,j,F,Rt,s,et,ue,a,h,ge,C,Re,ye,P,L,e,t,f,c,i,u,_,d,O,de,Nt]);l.useEffect(()=>{Ht.current=Br},[Br]);const eu=l.useCallback(w=>!w||ye!=="claude"?{success:!1}:r0(w.entry),[ye]),tu=l.useCallback((w,$)=>{const Q=(Array.isArray(w)?w:[w]).filter(Boolean);Q.length!==0&&(Q.forEach(Me=>{f({type:"permission-response",requestId:Me,optionId:$?.optionId,outcome:$?.outcome,cancelled:!!$?.cancelled,allow:!!$?.allow,updatedInput:$?.updatedInput,message:$?.message,rememberEntry:$?.rememberEntry})}),m(Me=>{const Ye=Me.filter(ut=>!Q.includes(ut.requestId));return Ye.length===0&&u(null),Ye}))},[f,u,m]),In=l.useCallback(w=>{const $=ue.slice(0,pe),z=ue.slice(pe),Q=z.indexOf(" "),Me=Q!==-1?z.slice(Q):"",Ye=`${$}${w.path} ${Me}`,ut=$.length+w.path.length+1;qe.current&&!qe.current.matches(":focus")&&qe.current.focus(),ce(Ye),Xe(ut),Le(Mt=>Mt.includes(w.path)?Mt:[...Mt,w.path]),Se(!1),De(-1),qe.current&&requestAnimationFrame(()=>{qe.current&&(qe.current.setSelectionRange(ut,ut),qe.current.matches(":focus")||qe.current.focus())})},[pe,ue]),ru=l.useCallback(w=>{const $=w.target.value,z=w.target.selectionStart;if(ce($),Xe(z),!$.trim()){w.target.style.height="auto",we(!1),Ke(!1),Ne(-1),D("");return}const Q=$.slice(0,z);if((Q.match(/```/g)||[]).length%2===1){Ke(!1),Ne(-1),D("");return}const Ye=Q.match(/(^|\s)\/(\S*)$/);if(Ye){const ut=Ye.index+Ye[1].length,Mt=Ye[2];Ne(ut),Ke(!0),Oe(-1),qt.current&&clearTimeout(qt.current),qt.current=setTimeout(()=>{D(Mt)},150)}else Ke(!1),Ne(-1),D(""),qt.current&&clearTimeout(qt.current)},[]),Ps=l.useCallback(w=>{!Ze.current||!w||(Ze.current.scrollTop=w.scrollTop,Ze.current.scrollLeft=w.scrollLeft)},[]),nu=l.useCallback(w=>{Xe(w.target.selectionStart)},[]),su=l.useCallback(w=>{w.target.style.height="auto",w.target.style.height=`${w.target.scrollHeight}px`,Xe(w.target.selectionStart),Ps(w.target);const $=parseInt(window.getComputedStyle(w.target).lineHeight,10),z=w.target.scrollHeight>$*2;we(z)},[Ps]),ou=l.useCallback(w=>{if(at&&x.length>0){if(w.key==="ArrowDown"){w.preventDefault(),Oe($=>$<x.length-1?$+1:0);return}if(w.key==="ArrowUp"){w.preventDefault(),Oe($=>$>0?$-1:x.length-1);return}if(w.key==="Tab"||w.key==="Enter"){w.preventDefault(),Ie>=0?Ms(x[Ie]):x.length>0&&Ms(x[0]);return}if(w.key==="Escape"){w.preventDefault(),Ke(!1),Ne(-1),D(""),Oe(-1),qt.current&&clearTimeout(qt.current);return}}if(te&&ke.length>0){if(w.key==="ArrowDown"){w.preventDefault(),rt($=>$<ke.length-1?$+1:0);return}if(w.key==="ArrowUp"){w.preventDefault(),rt($=>$>0?$-1:ke.length-1);return}if(w.key==="Tab"||w.key==="Enter"){w.preventDefault(),Fe>=0?In(ke[Fe]):ke.length>0&&In(ke[0]);return}if(w.key==="Escape"){w.preventDefault(),Se(!1);return}}if(w.key==="Tab"&&!te&&!at){w.preventDefault();const $=pr.modes,Q=($.indexOf(Re)+1)%$.length,Me=$[Q];lt(Me),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,Me);return}if(w.key==="Enter"){if(w.nativeEvent.isComposing)return;(w.ctrlKey||w.metaKey)&&!w.shiftKey?(w.preventDefault(),Br(w)):!w.shiftKey&&!w.ctrlKey&&!w.metaKey&&(U||(w.preventDefault(),Br(w)))}},[x,ke,Br,Re,pr.modes,Ms,In,Ie,Fe,t?.id,U,at,te]),zr=t?.__provider||ye||"claude",Rs=P[zr],Sa=Rs?.status||qn,Na=Sa===Ks,au=Rs?.reason||ot[zr]||null,iu=Rs?.installHint||null,lu=!!Ve[zr],cu=a||Na,Ca=zr==="opencode"?"OpenCode":de(`messageTypes.${zr}`),du=de("input.providerNotInstalledWithName",{provider:Ca}),uu=l.useMemo(()=>Zs(t),[t]);l.useEffect(()=>{e&&ue!==""?jt.setItem(`draft_input_${e.name}`,ue):e&&ue===""&&jt.removeItem(`draft_input_${e.name}`)},[ue,e]),l.useEffect(()=>{if(e){if(Tt.current){Tt.current=!1;return}const w=jt.getItem(`draft_input_${e.name}`)||"";w!==ue&&ce(w)}},[ue,e?.name]),l.useEffect(()=>{g&&g(J)},[J,g]),l.useEffect(()=>{if(qe.current){qe.current.style.height="auto",qe.current.style.height=`${qe.current.scrollHeight}px`;const w=parseInt(window.getComputedStyle(qe.current).lineHeight,10);we(qe.current.scrollHeight>w*2)}},[]),l.useEffect(()=>{qe.current&&!ue.trim()&&(qe.current.style.height="auto",we(!1))},[ue]);const pu=l.useCallback(w=>{ee($=>$.filter((z,Q)=>Q!==w))},[]),mu=l.useCallback(w=>{ye==="claude"?oe(w):ye==="codex"?ct(w):ye==="gemini"?Pe(w):ye==="opencode"&&W(w),Vx(ye,w)},[ye]);l.useCallback(()=>{s&&o&&f({type:"abort-session",sessionId:s,provider:ye})},[o,s,ye,f]);const fu=l.useCallback(()=>{ce(""),ee([]),xe(new Map),be(new Map),we(!1),bt("none"),Ke(!1),Se(!1),D(""),Ne(-1),Oe(-1),rt(-1),e?.name&&jt.removeItem(`draft_input_${e.name}`),typeof q=="function"&&q()},[q,e?.name]);return{input:ue,setInput:ce,provider:ye,setProvider:X,handleProviderSelection:$d,permissionMode:Re,setPermissionMode:lt,acpModes:uu.availableModes,acpModeId:It,handleAcpModeChange:Kd,selectedPermissionShortLabel:Od,permissionDropdownTitle:Fd,providerModeConfig:pr,getPermissionModeLabel:_s,providerThinkingConfig:Nr,thinkingMode:Nt,setThinkingMode:bt,currentModel:Rt,modelOptions:Cn,selectedModelLabel:Pd,isModelSelectionLocked:Rd,isOpencodeModelLoading:Ld,setProviderModel:mu,textareaRef:qe,inputContainerRef:mt,inputHighlightRef:Ze,modelSelectorRef:Ae,permissionSelectorRef:Pt,showFileDropdown:te,filteredFiles:ke,selectedFileIndex:Fe,selectFile:In,showCommandMenu:at,filteredCommands:x,selectedCommandIndex:Ie,handleCommandSelect:Vd,commandQuery:B,frequentCommands:qd,slashPosition:dt,setShowCommandMenu:Ke,setSelectedCommandIndex:Oe,setSlashPosition:Ne,setCommandQuery:D,getRootProps:Yd,getInputProps:Xd,isDragActive:Qd,openImagePicker:Zd,attachedImages:F,uploadingImages:ne,imageErrors:fe,removeAttachedImage:pu,visibleDynamicContext:sn,visibleSelectedElements:Bd,hiddenSelectedElements:zd,handleDismissSystemContext:Wd,handleDismissCurrentFile:Ud,handleDismissSelectedElement:Hd,renderInputWithMentions:Gd,handleInputChange:ru,handleTextareaClick:nu,handleKeyDown:ou,handlePaste:Jd,syncInputOverlayScroll:Ps,handleTextareaInput:su,activeInputProvider:zr,activeInputProviderLabel:Ca,activeProviderInstallState:Sa,isActiveProviderNotInstalled:Na,unavailablePlaceholder:du,isInputDisabled:cu,activeProviderInstallReason:au,activeProviderInstallHint:iu,isCheckingProviderInstallation:lu,checkProviderInstallation:Is,providerCheckLoadingByName:Ve,isInputFocused:J,setIsInputFocused:_e,isTextareaExpanded:Y,tokenBudget:R,handleSubmit:Br,handleSubmitRef:Ht,handleGrantToolPermission:eu,handlePermissionDecision:tu,dynamicContext:se,pendingDynamicContext:ge,setPendingDynamicContext:Qe,dynamicContextSent:et,setDynamicContextSent:vt,resetComposerForNewChat:fu}}function sv({selectedProject:e,selectedSession:t,ws:n,sendMessage:s,latestMessage:o,onFileOpen:a,onInputFocusChange:i,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:p,processingSessions:m,onReplaceTemporarySession:f,onNavigateToSession:h,onShowSettings:g,autoExpandTools:b,showRawParameters:v,showThinking:j,autoScrollToBottom:O,sendByCtrlEnter:C,externalMessageUpdate:L,urlContext:_,urlPrompt:R,integrationClientId:I,latestIntegrationMessage:k,sendIntegrationMessage:q,newSessionResetNonce:G=0}){const{t:re}=Et("chat"),le=l.useMemo(()=>typeof window<"u"&&e?.name?e0(e.name,t?.id||null):[],[e?.name,t?.id]),[K,Z]=l.useReducer(lx,le,ix),[U,de]=l.useState(t?.id||null),[ue,ce]=l.useState(!1),[J,_e]=l.useState(null),[F,ee]=l.useState(null),[ne,xe]=l.useState([]),fe=l.useRef(e),be=l.useRef(K.messages),te=l.useRef(K.isLoading),Se=l.useRef({sessionId:null,startedAt:0}),$e=l.useRef(null),he=l.useRef(G),nt=l.useRef(""),Le=l.useRef(null),ke=K.messages,Ee=K.phase,Fe=K.isLoading,rt=K.canAbortSession,He=K.pendingPermissionRequests;l.useEffect(()=>{fe.current=e},[e]),l.useEffect(()=>{be.current=ke},[ke]),l.useEffect(()=>{te.current=Fe},[Fe]);const Xe=l.useCallback(Ne=>{Z({type:"replace_messages",value:Ne})},[]),pe=l.useCallback(Ne=>{Z({type:"replace_permissions",value:Ne})},[]),De=l.useCallback(Ne=>{Z({type:"set_loading",value:Ne})},[]),at=l.useCallback(Ne=>{Z({type:"set_can_abort",value:Ne})},[]),Ke=l.useCallback((Ne,Re)=>{Z({type:"set_phase",phase:Ne,overrides:Re})},[]),Be=l.useCallback((Ne,Re)=>{Z({type:"apply_conversation_event",event:Ne,provider:Re})},[]),A=l.useCallback(Ne=>{Se.current={sessionId:Ne||null,startedAt:Date.now()}},[]),V=l.useCallback(Ne=>{!Ne||!Se.current.startedAt||(Se.current={...Se.current,sessionId:Ne})},[]),y=l.useCallback((Ne=null)=>{const Re=Se.current;Re.startedAt&&(Ne&&Re.sessionId&&Re.sessionId!==Ne||(Se.current={sessionId:null,startedAt:0}))},[]),x=l.useCallback(()=>{Le.current&&(clearTimeout(Le.current),Le.current=null),nt.current=""},[]),S=l.useCallback((Ne,Re=null)=>{if(Re&&Re!=="session-status")return!1;const lt=Se.current;return!!(lt.startedAt&&Ne&<.sessionId===Ne&&Date.now()-lt.startedAt<15e3&&(Ee===ve.CONNECTING||Ee===ve.QUEUED||Ee===ve.STREAMING||Ee===ve.AWAITING_APPROVAL||Ee===ve.COMPLETED||Ee===ve.ABORTED||Ee===ve.ERRORED))},[Ee]),B=l.useCallback((Ne=null)=>{const Re=fe.current?.name||e?.name||"";Re&&zc(Re,Ne,be.current)},[e?.name]),D=o0({selectedProject:e,selectedProjectRef:fe,selectedSession:t,currentSessionId:U,setCurrentSessionId:de,provider:t?.__provider||null,runtimePhase:Ee,isLoading:Fe,isLoadingRef:te,processingSessions:m,autoScrollToBottom:O,externalMessageUpdate:L,ws:n,sendMessage:s,chatMessages:ke,setChatMessages:Xe,setIsLoading:De,setCanAbortSession:at,setRuntimePhase:Ke,setClaudeStatus:_e,setPendingPermissionRequests:pe,resetStreamingState:x,clearLocalRunGuard:y,localRunGuardRef:Se,pendingViewSessionRef:$e,isSystemSessionChange:ue,setIsSystemSessionChange:ce,onSessionInactive:d,onSessionNotProcessing:p,onSessionProcessing:u}),Y=l.useMemo(()=>Zg(D.sessionMessages),[D.sessionMessages]);l.useEffect(()=>{ee(Y.modeState||null),xe(Array.isArray(Y.availableCommands)?Y.availableCommands:[])},[Y.availableCommands,Y.modeState]);const we=l.useMemo(()=>{if(!t&&!U)return t;const Ne=t?{...t}:{};return!Ne.id&&U&&(Ne.id=U),Ne.acpModes=F,Ne.acpAvailableCommands=ne,Ne},[ne,F,U,t]),Ie=nv({selectedProject:e,selectedSession:we,selectedProjectRef:fe,currentSessionId:U,canAbortSession:rt,isLoading:Fe,setChatMessages:Xe,setCanAbortSession:at,setRuntimePhase:Ke,setClaudeStatus:_e,pendingPermissionRequests:He,setPendingPermissionRequests:pe,sendMessage:s,onSessionActive:c,onInputFocusChange:i,onShowSettings:g,onFileOpen:a,appendSessionConversationEvent:D.appendSessionConversationEvent,startLocalRunGuard:A,pendingViewSessionRef:$e,scrollToBottom:D.scrollToBottom,setIsUserScrolledUp:D.setIsUserScrolledUp,tokenBudget:D.tokenBudget,chatMessages:ke,setSessionMessages:D.setSessionMessages,resetRuntimeForNewChat:D.resetSessionHistoryForNewChat,urlContext:_,urlPrompt:R,integrationClientId:I,latestIntegrationMessage:k,sendIntegrationMessage:q,sendByCtrlEnter:C});i0({latestMessage:o,provider:Ie.provider,claudeStatus:J,selectedProject:e,selectedSession:t,currentSessionId:U,setCurrentSessionId:de,isLoading:Fe,runtimePhase:Ee,sendMessage:s,persistCurrentChatCache:B,setIsSystemSessionChange:ce,setPendingPermissionRequests:pe,setIsLoading:De,setCanAbortSession:at,setClaudeStatus:_e,setChatMessages:Xe,setTokenBudget:D.setTokenBudget,setAcpSessionModeState:ee,setAcpAvailableCommands:xe,applyRealtimeConversationEvent:Be,streamBufferRef:nt,streamTimerRef:Le,clearLocalRunGuard:y,syncLocalRunGuardSession:V,shouldIgnoreStaleIdleSignal:S,pendingViewSessionRef:$e,appendSessionConversationEvent:D.appendSessionConversationEvent,recoverAndSettleSessionRuntime:D.recoverAndSettleSessionRuntime,recoverTerminalSessionPhase:D.recoverTerminalSessionPhase,inferRuntimePhaseFromSessionEvents:D.inferRuntimePhaseFromSessionEvents,inferTerminalPhaseFromSessionEvents:D.inferTerminalPhaseFromSessionEvents,scheduleSessionStatusRecovery:D.scheduleSessionStatusRecovery,sessionMessages:D.sessionMessages,setSessionMessages:D.setSessionMessages,loadSessionMessages:D.loadSessionMessages,onSessionInactive:d,onSessionNotProcessing:p,onSessionProcessing:u,onReplaceTemporarySession:f,onNavigateToSession:h,t:re,setRuntimePhase:Ke}),l.useEffect(()=>{he.current!==G&&(he.current=G,!t&&(x(),y(),Ie.resetComposerForNewChat()))},[y,Ie.resetComposerForNewChat,G,x,t]);const Oe=Ug({status:J,messages:ke,pendingPermissionRequests:He,t:re}),dt=Fe&&!!Oe;return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
290
|
+
details[open] .details-chevron {
|
|
291
|
+
transform: rotate(180deg);
|
|
292
|
+
}
|
|
293
|
+
`}),r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx(yx,{selectedProject:e,selectedSession:t,currentSessionId:U,provider:Ie.provider,chatMessages:ke,threadMessages:D.threadMessages,isLoading:Fe,isLoadingSessionMessages:D.isLoadingSessionMessages,isLoadingMoreMessages:D.isLoadingMoreMessages,hasMoreMessages:D.hasMoreMessages,totalMessages:D.totalMessages,sessionMessages:D.sessionMessages,visibleMessageCount:D.visibleMessageCount,pendingPermissionRequests:He,scrollContainerRef:D.scrollContainerRef,messagesEndRef:D.messagesEndRef,onScroll:D.handleScroll,onLoadEarlierSessionMessages:()=>D.loadOlderMessages(),onLoadEarlierMessages:D.loadEarlierMessages,onProviderSelection:Ie.handleProviderSelection,onFileOpen:a,onShowSettings:g,onGrantToolPermission:Ie.handleGrantToolPermission,onPermissionDecision:Ie.handlePermissionDecision,autoExpandTools:b,showRawParameters:v}),r.jsx(Ox,{composer:Ie,statusPresentation:Oe,shouldShowClaudeStatus:dt,isLoading:Fe,chatMessages:ke,sendByCtrlEnter:C})]})]})}const ov=Ct.memo(sv);class At{constructor(t,n,s,o){this.fromA=t,this.toA=n,this.fromB=s,this.toB=o}offset(t,n=t){return new At(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}}function Rr(e,t,n,s,o,a){if(e==s)return[];let i=ua(e,t,n,s,o,a),c=pa(e,t+i,n,s,o+i,a);t+=i,n-=c,o+=i,a-=c;let d=n-t,u=a-o;if(!d||!u)return[new At(t,n,o,a)];if(d>u){let m=e.slice(t,n).indexOf(s.slice(o,a));if(m>-1)return[new At(t,t+m,o,o),new At(t+m+u,n,a,a)]}else if(u>d){let m=s.slice(o,a).indexOf(e.slice(t,n));if(m>-1)return[new At(t,t,o,o+m),new At(n,n,o+m+d,a)]}if(d==1||u==1)return[new At(t,n,o,a)];let p=ud(e,t,n,s,o,a);if(p){let[m,f,h]=p;return Rr(e,t,m,s,o,f).concat(Rr(e,m+h,n,s,f+h,a))}return av(e,t,n,s,o,a)}let dn=1e9,un=0,da=!1;function av(e,t,n,s,o,a){let i=n-t,c=a-o;if(dn<1e9&&Math.min(i,c)>dn*16||un>0&&Date.now()>un)return Math.min(i,c)>dn*64?[new At(t,n,o,a)]:Ti(e,t,n,s,o,a);let d=Math.ceil((i+c)/2);eo.reset(d),to.reset(d);let u=(h,g)=>e.charCodeAt(t+h)==s.charCodeAt(o+g),p=(h,g)=>e.charCodeAt(n-h-1)==s.charCodeAt(a-g-1),m=(i-c)%2!=0?to:null,f=m?null:eo;for(let h=0;h<d;h++){if(h>dn||un>0&&!(h&63)&&Date.now()>un)return Ti(e,t,n,s,o,a);let g=eo.advance(h,i,c,d,m,!1,u)||to.advance(h,i,c,d,f,!0,p);if(g)return iv(e,t,n,t+g[0],s,o,a,o+g[1])}return[new At(t,n,o,a)]}class cd{constructor(){this.vec=[]}reset(t){this.len=t<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[t+1]=0,this.start=this.end=0}advance(t,n,s,o,a,i,c){for(let d=-t+this.start;d<=t-this.end;d+=2){let u=o+d,p=d==-t||d!=t&&this.vec[u-1]<this.vec[u+1]?this.vec[u+1]:this.vec[u-1]+1,m=p-d;for(;p<n&&m<s&&c(p,m);)p++,m++;if(this.vec[u]=p,p>n)this.end+=2;else if(m>s)this.start+=2;else if(a){let f=o+(n-s)-d;if(f>=0&&f<this.len&&a.vec[f]!=-1)if(i){let h=a.vec[f];if(h>=n-p)return[h,o+h-f]}else{let h=n-a.vec[f];if(p>=h)return[p,m]}}}return null}}const eo=new cd,to=new cd;function iv(e,t,n,s,o,a,i,c){let d=!1;return!Zr(e,s)&&++s==n&&(d=!0),!Zr(o,c)&&++c==i&&(d=!0),d?[new At(t,n,a,i)]:Rr(e,t,s,o,a,c).concat(Rr(e,s,n,o,c,i))}function dd(e,t){let n=1,s=Math.min(e,t);for(;n<s;)n=n<<1;return n}function ua(e,t,n,s,o,a){if(t==n||t==a||e.charCodeAt(t)!=s.charCodeAt(o))return 0;let i=dd(n-t,a-o);for(let c=t,d=o;;){let u=c+i,p=d+i;if(u>n||p>a||e.slice(c,u)!=s.slice(d,p)){if(i==1)return c-t-(Zr(e,c)?0:1);i=i>>1}else{if(u==n||p==a)return u-t;c=u,d=p}}}function pa(e,t,n,s,o,a){if(t==n||o==a||e.charCodeAt(n-1)!=s.charCodeAt(a-1))return 0;let i=dd(n-t,a-o);for(let c=n,d=a;;){let u=c-i,p=d-i;if(u<t||p<o||e.slice(u,c)!=s.slice(p,d)){if(i==1)return n-c-(Zr(e,c)?0:1);i=i>>1}else{if(u==t||p==o)return n-u;c=u,d=p}}}function Lo(e,t,n,s,o,a,i,c){let d=s.slice(o,a),u=null;for(;;){if(u||i<c)return u;for(let p=t+i;;){Zr(e,p)||p++;let m=p+i;if(Zr(e,m)||(m+=m==p+1?1:-1),m>=n)break;let f=e.slice(p,m),h=-1;for(;(h=d.indexOf(f,h+1))!=-1;){let g=ua(e,m,n,s,o+h+f.length,a),b=pa(e,t,p,s,o,o+h),v=f.length+g+b;(!u||u[2]<v)&&(u=[p-b,o+h-b,v])}p=m}if(c<0)return u;i=i>>1}}function ud(e,t,n,s,o,a){let i=n-t,c=a-o;if(i<c){let d=ud(s,o,a,e,t,n);return d&&[d[1],d[0],d[2]]}return i<4||c*2<i?null:Lo(e,t,n,s,o,a,Math.floor(i/4),-1)}function Ti(e,t,n,s,o,a){da=!0;let i=n-t,c=a-o,d;if(i<c){let f=Lo(s,o,a,e,t,n,Math.floor(i/6),50);d=f&&[f[1],f[0],f[2]]}else d=Lo(e,t,n,s,o,a,Math.floor(c/6),50);if(!d)return[new At(t,n,o,a)];let[u,p,m]=d;return Rr(e,t,u,s,o,p).concat(Rr(e,u+m,n,s,p+m,a))}function pd(e,t){for(let n=1;n<e.length;n++){let s=e[n-1],o=e[n];s.toA>o.fromA-t&&s.toB>o.fromB-t&&(e[n-1]=new At(s.fromA,o.toA,s.fromB,o.toB),e.splice(n--,1))}}function lv(e,t,n){for(;;){pd(n,1);let s=!1;for(let o=0;o<n.length;o++){let a=n[o],i,c;(i=ua(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new At(a.fromA+i,a.toA,a.fromB+i,a.toB)),(c=pa(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new At(a.fromA,a.toA-c,a.fromB,a.toB-c));let d=a.toA-a.fromA,u=a.toB-a.fromB;if(d&&u)continue;let p=a.fromA-(o?n[o-1].toA:0),m=(o<n.length-1?n[o+1].fromA:e.length)-a.toA;if(!p||!m)continue;let f=d?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);p<=f.length&&e.slice(a.fromA-p,a.fromA)==f.slice(f.length-p)?(n[o]=new At(a.fromA-p,a.toA-p,a.fromB-p,a.toB-p),s=!0):m<=f.length&&e.slice(a.toA,a.toA+m)==f.slice(0,m)&&(n[o]=new At(a.fromA+m,a.toA+m,a.fromB+m,a.toB+m),s=!0)}if(!s)break}return n}function cv(e,t,n){for(let s=0,o=0;o<e.length;o++){let a=e[o],i=a.toA-a.fromA,c=a.toB-a.fromB;if(i&&c||i>3||c>3){let d=o==e.length-1?t.length:e[o+1].fromA,u=a.fromA-s,p=d-a.toA,m=Di(t,a.fromA,u),f=Mi(t,a.toA,p),h=a.fromA-m,g=f-a.toA;if((!i||!c)&&h&&g){let b=Math.max(i,c),[v,j,O]=i?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];b>h&&t.slice(m,a.fromA)==v.slice(O-h,O)?(a=e[o]=new At(m,m+i,a.fromB-h,a.toB-h),m=a.fromA,f=Mi(t,a.toA,d-a.toA)):b>g&&t.slice(a.toA,f)==v.slice(j,j+g)&&(a=e[o]=new At(f-i,f,a.fromB+g,a.toB+g),f=a.toA,m=Di(t,a.fromA,a.fromA-s)),h=a.fromA-m,g=f-a.toA}if(h||g)a=e[o]=new At(a.fromA-h,a.toA+g,a.fromB-h,a.toB+g);else if(i){if(!c){let b=Ri(t,a.fromA,a.toA),v,j=b<0?-1:Pi(t,a.toA,a.fromA);b>-1&&(v=b-a.fromA)<=p&&t.slice(a.fromA,b)==t.slice(a.toA,a.toA+v)?a=e[o]=a.offset(v):j>-1&&(v=a.toA-j)<=u&&t.slice(a.fromA-v,a.fromA)==t.slice(j,a.toA)&&(a=e[o]=a.offset(-v))}}else{let b=Ri(n,a.fromB,a.toB),v,j=b<0?-1:Pi(n,a.toB,a.fromB);b>-1&&(v=b-a.fromB)<=p&&n.slice(a.fromB,b)==n.slice(a.toB,a.toB+v)?a=e[o]=a.offset(v):j>-1&&(v=a.toB-j)<=u&&n.slice(a.fromB-v,a.fromB)==n.slice(j,a.toB)&&(a=e[o]=a.offset(-v))}}s=a.toA}return pd(e,3),e}let Pr;try{Pr=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function md(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function fd(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?md(n)?1:0:Pr?!xd(n)||t==e.length-1?Pr.test(String.fromCharCode(n))?1:0:Pr.test(e.slice(t,t+2))?2:0:0}function hd(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?md(n)?1:0:Pr?!yd(n)||t==1?Pr.test(String.fromCharCode(n))?1:0:Pr.test(e.slice(t-2,t))?2:0:0}const gd=8;function Mi(e,t,n){if(t==e.length||!hd(e,t))return t;for(let s=t,o=t+n,a=0;a<gd;a++){let i=fd(e,s);if(!i||s+i>o)return s;s+=i}return t}function Di(e,t,n){if(!t||!fd(e,t))return t;for(let s=t,o=t-n,a=0;a<gd;a++){let i=hd(e,s);if(!i||s-i<o)return s;s-=i}return t}function Pi(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Ri(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}const xd=e=>e>=55296&&e<=56319,yd=e=>e>=56320&&e<=57343;function Zr(e,t){return!t||t==e.length||!xd(e.charCodeAt(t-1))||!yd(e.charCodeAt(t))}function dv(e,t,n){var s;return dn=((s=n?.scanLimit)!==null&&s!==void 0?s:1e9)>>1,un=n?.timeout?Date.now()+n.timeout:0,da=!1,lv(e,t,Rr(e,0,e.length,t,0,t.length))}function vd(){return!da}function bd(e,t,n){return cv(dv(e,t,n),e,t)}const xr=ms.define({combine:e=>e[0]}),uv=$o.define(),wd=ms.define(),Jt=gn.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(uv)&&(e=n.value);for(let n of t.state.facet(wd))e=n(e,t);return e}});function ro(e){let t=e.field(Jt,!1);if(!t)return null;let n=e.facet(xr);return{chunks:t,side:n?n.side:null}}class Kr{constructor(t,n,s,o,a,i=!0){this.changes=t,this.fromA=n,this.toA=s,this.fromB=o,this.toB=a,this.precise=i}offset(t,n){return t||n?new Kr(this.changes,this.fromA+t,this.toA+t,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(t,n,s){let o=bd(t.toString(),n.toString(),s);return kd(o,t,n,0,0,vd())}static updateA(t,n,s,o,a){return Bi($i(t,o,!0,s.length),t,n,s,a)}static updateB(t,n,s,o,a){return Bi($i(t,o,!1,n.length),t,n,s,a)}}function Li(e,t,n,s){let o=n.lineAt(e),a=s.lineAt(t);return o.to==e&&a.to==t&&e<n.length&&t<s.length?[e+1,t+1]:[o.from,a.from]}function Oi(e,t,n,s){let o=n.lineAt(e),a=s.lineAt(t);return o.from==e&&a.from==t?[e,t]:[o.to+1,a.to+1]}function kd(e,t,n,s,o,a){let i=[];for(let c=0;c<e.length;c++){let d=e[c],[u,p]=Li(d.fromA+s,d.fromB+o,t,n),[m,f]=Oi(d.toA+s,d.toB+o,t,n),h=[d.offset(-u+s,-p+o)];for(;c<e.length-1;){let g=e[c+1],[b,v]=Li(g.fromA+s,g.fromB+o,t,n);if(b>m+1&&v>f+1)break;h.push(g.offset(-u+s,-p+o)),[m,f]=Oi(g.toA+s,g.toB+o,t,n),c++}i.push(new Kr(h,u,Math.max(u,m),p,Math.max(p,f),a))}return i}const Xn=1e3;function Fi(e,t,n,s){let o=0,a=e.length;for(;;){if(o==a){let p=0,m=0;o&&({toA:p,toB:m}=e[o-1]);let f=t-(n?p:m);return[p+f,m+f]}let i=o+a>>1,c=e[i],[d,u]=n?[c.fromA,c.toA]:[c.fromB,c.toB];if(d>t)a=i;else if(u<=t)o=i+1;else return s?[c.fromA,c.fromB]:[c.toA,c.toB]}}function $i(e,t,n,s){let o=[];return t.iterChangedRanges((a,i,c,d)=>{let u=0,p=n?t.length:s,m=0,f=n?s:t.length;a>Xn&&([u,m]=Fi(e,a-Xn,n,!0)),i<t.length-Xn&&([p,f]=Fi(e,i+Xn,n,!1));let h=d-c-(i-a),g,[b,v]=n?[h,0]:[0,h];o.length&&(g=o[o.length-1]).toA>=u?o[o.length-1]={fromA:g.fromA,fromB:g.fromB,toA:p,toB:f,diffA:g.diffA+b,diffB:g.diffB+v}:o.push({fromA:u,toA:p,fromB:m,toB:f,diffA:b,diffB:v})}),o}function Bi(e,t,n,s,o){if(!e.length)return t;let a=[];for(let i=0,c=0,d=0,u=0;;i++){let p=i==e.length?null:e[i],m=p?p.fromA+c:n.length,f=p?p.fromB+d:s.length;for(;u<t.length;){let v=t[u];if(v.toA+c>m||v.toB+d>f)break;a.push(v.offset(c,d)),u++}if(!p)break;let h=p.toA+c+p.diffA,g=p.toB+d+p.diffB,b=bd(n.sliceString(m,h),s.sliceString(f,g),o);for(let v of kd(b,n,s,m,f,vd()))a.push(v);for(c+=p.diffA,d+=p.diffB;u<t.length;){let v=t[u];if(v.fromA+c>h&&v.fromB+d>g)break;u++}}return a}const pv={scanLimit:500},jd=fs.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=Ui(e))}update(e){(e.docChanged||e.viewportChanged||mv(e.startState,e.state)||fv(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=Ui(e.view))}},{decorations:e=>e.deco});function mv(e,t){return e.field(Jt,!1)!=t.field(Jt,!1)}function fv(e,t){return e.facet(xr)!=t.facet(xr)}const zi=yr.line({class:"cm-changedLine"}),Sd=yr.mark({class:"cm-changedText"}),hv=yr.mark({tagName:"ins",class:"cm-insertedLine"}),gv=yr.mark({tagName:"del",class:"cm-deletedLine"}),Wi=new class extends Bo{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function xv(e,t,n,s,o,a){let i=n?e.fromA:e.fromB,c=n?e.toA:e.toB,d=0;if(i!=c){o.add(i,i,zi),o.add(i,c,n?gv:hv),a&&a.add(i,i,Wi);for(let u=t.iterRange(i,c-1),p=i;!u.next().done;){if(u.lineBreak){p++,o.add(p,p,zi),a&&a.add(p,p,Wi);continue}let m=p+u.value.length;if(s)for(;d<e.changes.length;){let f=e.changes[d],h=i+(n?f.fromA:f.fromB),g=i+(n?f.toA:f.toB),b=Math.max(p,h),v=Math.min(m,g);if(b<v&&o.add(b,v,Sd),g<m)d++;else break}p=m}}}function Ui(e){let t=e.state.field(Jt),{side:n,highlightChanges:s,markGutter:o,overrideChunk:a}=e.state.facet(xr),i=n=="a",c=new ts,d=o?new ts:null,{from:u,to:p}=e.viewport;for(let m of t){if((i?m.fromA:m.fromB)>=p)break;(i?m.toA:m.toB)>u&&(!a||!a(e.state,m,c,d))&&xv(m,e.state.doc,i,s,c,d)}return{deco:c.finish(),gutter:d&&d.finish()}}const Oo=$o.define({map:(e,t)=>t.mapPos(e)});class yv extends zo{constructor(t){super(),this.lines=t}eq(t){return this.lines==t.lines}toDOM(t){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=t.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",s=>{let o=t.posAtDOM(s.target);t.dispatch({effects:Oo.of(o)});let{side:a,sibling:i}=t.state.facet(xr);i&&i().dispatch({effects:Oo.of(vv(o,t.state.field(Jt),a=="a"))})}),n}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function vv(e,t,n){let s=0,o=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(n?i.fromA:i.fromB)>=e)return o+(e-s);[s,o]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const bv=gn.define({create(e){return yr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Oo)&&(e=e.update({filter:s=>s!=n.value}));return e},provide:e=>tr.decorations.from(e)});function wv({margin:e=3,minSize:t=4}){return bv.init(n=>kv(n,e,t))}function kv(e,t,n){let s=new ts,o=e.facet(xr).side=="a",a=e.field(Jt),i=1;for(let c=0;;c++){let d=c<a.length?a[c]:null,u=c?i+t:1,p=d?e.doc.lineAt(o?d.fromA:d.fromB).number-1-t:e.doc.lines,m=p-u+1;if(m>=n&&s.add(e.doc.line(u).from,e.doc.line(p).to,yr.replace({widget:new yv(m),block:!0})),!d)break;i=e.doc.lineAt(Math.min(e.doc.length,o?d.toA:d.toB)).number}return s.finish()}const jv=tr.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),Sv=new class extends Bo{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Nv=el.low(xu({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(jd))===null||t===void 0?void 0:t.gutter)||vu.empty},widgetMarker:(e,t)=>t instanceof Nd?Sv:null}));function Cv(e){var t;let n=typeof e.original=="string"?Zi.of(e.original.split(/\r?\n/)):e.original,s=e.diffConfig||pv;return[el.low(jd),Iv,jv,tr.editorAttributes.of({class:"cm-merge-b"}),wd.of((o,a)=>{let i=a.effects.find(c=>c.is(ma));return i&&(o=Kr.updateA(o,i.value.doc,a.startState.doc,i.value.changes,s)),a.docChanged&&(o=Kr.updateB(o,a.state.field(en),a.newDoc,a.changes,s)),o}),xr.of({highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1,syntaxHighlightDeletions:e.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(t=e.mergeControls)!==null&&t!==void 0?t:!0,overrideChunk:e.allowInlineDiffs?Pv:void 0,side:"b"}),en.init(()=>n),e.gutter!==!1?Nv:[],e.collapseUnchanged?wv(e.collapseUnchanged):[],Jt.init(o=>Kr.build(n,o.doc,s))]}const ma=$o.define(),en=gn.define({create:()=>Zi.empty,update(e,t){for(let n of t.effects)n.is(ma)&&(e=n.value.doc);return e}}),Hi=new WeakMap;class Nd extends zo{constructor(t){super(),this.buildDOM=t,this.dom=null}eq(t){return this.dom==t.dom}toDOM(t){return this.dom||(this.dom=this.buildDOM(t))}}function Ev(e,t,n){let s=Hi.get(t.changes);if(s)return s;let o=i=>{let{highlightChanges:c,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:u,mergeControls:p}=e.facet(xr),m=document.createElement("div");if(m.className="cm-deletedChunk",p){let L=m.appendChild(document.createElement("div"));L.className="cm-chunkButtons";let _=I=>{I.preventDefault(),Av(i,i.posAtDOM(m))},R=I=>{I.preventDefault(),_v(i,i.posAtDOM(m))};if(typeof p=="function")L.appendChild(p("accept",_)),L.appendChild(p("reject",R));else{let I=L.appendChild(document.createElement("button"));I.name="accept",I.textContent=e.phrase("Accept"),I.onmousedown=_;let k=L.appendChild(document.createElement("button"));k.name="reject",k.textContent=e.phrase("Reject"),k.onmousedown=R}}if(n||t.fromA>=t.toA)return m;let f=i.state.field(en).sliceString(t.fromA,t.endA),h=d&&e.facet(tl),g=O(),b=t.changes,v=0,j=!1;function O(){let L=m.appendChild(document.createElement("div"));return L.className="cm-deletedLine",L.appendChild(document.createElement("del"))}function C(L,_,R){for(let I=L;I<_;){if(f.charAt(I)==`
|
|
294
|
+
`){g.firstChild||g.appendChild(document.createElement("br")),g=O(),I++;continue}let k=_,q=R+(j?" cm-deletedText":""),G=!1,re=f.indexOf(`
|
|
295
|
+
`,I);if(re>-1&&re<_&&(k=re),c&&v<b.length){let le=Math.max(0,j?b[v].toA:b[v].fromA);le<=k&&(k=le,j&&v++,G=!0)}if(k>I){let le=document.createTextNode(f.slice(I,k));if(q){let K=g.appendChild(document.createElement("span"));K.className=q,K.appendChild(le)}else g.appendChild(le);I=k}G&&(j=!j)}}if(h&&t.toA-t.fromA<=u){let L=h.parser.parse(f),_=0;oo(L,{style:R=>rl(e,R)},(R,I,k)=>{R>_&&C(_,R,""),C(R,I,k),_=I}),C(_,f.length,"")}else C(0,f.length,"");return g.firstChild||g.appendChild(document.createElement("br")),m},a=yr.widget({block:!0,side:-1,widget:new Nd(o)});return Hi.set(t.changes,a),a}function Av(e,t){let{state:n}=e,s=t??n.selection.main.head,o=e.state.field(Jt).find(d=>d.fromB<=s&&d.endB>=s);if(!o)return!1;let a=e.state.sliceDoc(o.fromB,Math.max(o.fromB,o.toB-1)),i=e.state.field(en);o.fromB!=o.toB&&o.toA<=i.length&&(a+=e.state.lineBreak);let c=yu.of({from:o.fromA,to:Math.min(i.length,o.toA),insert:a},i.length);return e.dispatch({effects:ma.of({doc:c.apply(i),changes:c}),userEvent:"accept"}),!0}function _v(e,t){let{state:n}=e,s=t??n.selection.main.head,o=n.field(Jt).find(c=>c.fromB<=s&&c.endB>=s);if(!o)return!1;let i=n.field(en).sliceString(o.fromA,Math.max(o.fromA,o.toA-1));return o.fromA!=o.toA&&o.toB<=n.doc.length&&(i+=n.lineBreak),e.dispatch({changes:{from:o.fromB,to:Math.min(n.doc.length,o.toB),insert:i},userEvent:"revert"}),!0}function qi(e){let t=new ts;for(let n of e.field(Jt)){let s=e.facet(xr).overrideChunk&&Cd(e,n);t.add(n.fromB,n.fromB,Ev(e,n,!!s))}return t.finish()}const Iv=gn.define({create:e=>qi(e),update(e,t){return t.state.field(Jt,!1)!=t.startState.field(Jt,!1)?qi(t.state):e},provide:e=>tr.decorations.from(e)}),Ki=new WeakMap;function Cd(e,t){let n=Ki.get(t);if(n!==void 0)return n;n=null;let s=e.field(en),o=e.doc,a=s.lineAt(t.endA).number-s.lineAt(t.fromA).number+1,i=o.lineAt(t.endB).number-o.lineAt(t.fromB).number+1;e:if(a==i&&a<10){let c=[],d=0,u=t.fromA,p=t.fromB;for(let m of t.changes){if(m.fromA<m.toA){d+=m.toA-m.fromA;let f=s.sliceString(u+m.fromA,u+m.toA);if(/\n/.test(f))break e;c.push(yr.widget({widget:new Tv(f),side:-1}).range(p+m.fromB))}m.fromB<m.toB&&c.push(Sd.range(p+m.fromB,p+m.toB))}d<t.endA-t.fromA-a*2&&(n=c)}return Ki.set(t,n),n}class Tv extends zo{constructor(t){super(),this.text=t}eq(t){return this.text==t.text}toDOM(t){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const Mv=new class extends Bo{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},Dv=yr.line({class:"cm-inlineChangedLine"});function Pv(e,t,n,s){let o=Cd(e,t),a=0;if(!o)return!1;for(let i=e.doc.lineAt(t.fromB);;){for(s&&s.add(i.from,i.from,Mv),n.add(i.from,i.from,Dv);a<o.length&&o[a].to<=i.to;){let c=o[a++];n.add(c.from,c.to,c.value)}if(i.to>=t.endB)break;i=e.doc.lineAt(i.to+1)}return!0}var Rv=function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n};const Ft=ms.define({combine:e=>{const t=[];for(let n of e){if(!n)continue;const{create:s,gutters:o}=n,a=Rv(n,["create","gutters"]);t.push(Object.assign(Object.assign({},a),{enabled:!0,gutters:o?o.filter(i=>Object.keys(i).length>0):void 0}))}return bu(t,{enabled:t.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),zt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},Lv=tr.theme({".cm-minimap-overlay-container":{position:"absolute",top:0,height:"100%",width:"100%","&.cm-minimap-overlay-mouse-over":{opacity:0,transition:"visibility 0s linear 300ms, opacity 300ms"},"&.cm-minimap-overlay-mouse-over:hover":{opacity:1,transition:"visibility 0s linear 0ms, opacity 300ms"},"&.cm-minimap-overlay-off":{display:"none"},"& .cm-minimap-overlay":{background:"rgb(121, 121, 121)",opacity:"0.2",position:"absolute",right:0,top:0,width:"100%",transition:"top 0s ease-in 0ms","&:hover":{opacity:"0.3"}},"&.cm-minimap-overlay-active":{opacity:1,visibility:"visible",transition:"visibility 0s linear 0ms, opacity 300ms","& .cm-minimap-overlay":{opacity:"0.4"}}}}),kr=zt.PixelMultiplier*zt.SizeRatio,Ov=fs.fromClass(class{constructor(e){this.view=e,this._isDragging=!1,e.state.facet(Ft).enabled&&this.create(e)}create(e){this.container=Vr("div",{class:"cm-minimap-overlay-container"}),this.dom=Vr("div",{class:"cm-minimap-overlay"}),this.container.appendChild(this.dom),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),window.addEventListener("mousemove",this.onMouseMove.bind(this));const t=e.dom.querySelector(".cm-minimap-inner");t&&t.appendChild(this.container),this.computeShowOverlay(),this.computeHeight(),this.computeTop()}remove(){this.container&&(this.container.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),this.container.remove())}update(e){const t=e.startState.facet(Ft).enabled,n=e.state.facet(Ft).enabled;if(t&&!n){this.remove();return}!t&&n&&this.create(e.view),n&&(this.computeShowOverlay(),e.geometryChanged&&(this.computeHeight(),this.computeTop()))}computeHeight(){if(!this.dom)return;const e=this.view.dom.clientHeight/kr;this.dom.style.height=e+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:e,scrollHeight:t,scrollTop:n}=this.view.scrollDOM,s=t-e,o=n/kr,a=e/kr,i=e-a;let c=n/s;isNaN(c)&&(c=0);const d=i*c,u=Math.min(d,o);this.dom.style.top=u+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:e}=this.view.state.facet(Ft);e==="mouse-over"?this.container.classList.add("cm-minimap-overlay-mouse-over"):this.container.classList.remove("cm-minimap-overlay-mouse-over");const{clientHeight:t,scrollHeight:n}=this.view.scrollDOM;t===n?this.container.classList.add("cm-minimap-overlay-off"):this.container.classList.remove("cm-minimap-overlay-off")}onMouseDown(e){if(!this.container||e.button===2)return;const{clientY:t,target:n}=e;if(n===this.dom){this._dragStartY=e.clientY,this._isDragging=!0,this.container.classList.add("cm-minimap-overlay-active");return}const{clientHeight:s,scrollHeight:o,scrollTop:a}=this.view.scrollDOM,i=n.getBoundingClientRect().top,c=(t-i)*kr,d=a/(o-s),p=(s*kr-s)*d,m=Math.max(0,a-p);this.view.scrollDOM.scrollTop=m+c-s/2}onMouseUp(e){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(e){if(!this._isDragging||!this.dom)return;if(e.preventDefault(),e.stopPropagation(),!this._dragStartY){this._dragStartY=e.clientY;return}const t=e.clientY-this._dragStartY,n=t<0,s=t>0;this._dragStartY=e.clientY;const o=this.dom.getBoundingClientRect().height,a=this.dom.getBoundingClientRect().y,i=a+o,c=parseFloat(this.dom.style.top),d=this.view.scrollDOM.scrollTop,u=this.view.scrollDOM.clientHeight,p=this.view.scrollDOM.scrollHeight,m=d===0,f=Math.round(d)>=Math.round(p-u);if(m&&n||m&&e.clientY<a||f&&s||f&&e.clientY>i)return;const h=this.view.scrollDOM.scrollHeight,g=this.view.scrollDOM.clientHeight,b=(h-g)/kr,v=g-g/kr,j=c+t,O=j/v,C=(h-g)*O,L=j*kr;this.view.scrollDOM.scrollTop=Math.max(C,L);const _=Math.min(Math.max(0,j),Math.min(v,b));this.dom.style.top=_+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),Fv=[Lv,Ov];class fa{constructor(t){this.map=new Map,this.view=t}get(t){return this.map.get(t)}set(t,n){this.map.set(t,n)}}function Vi(e){var t;if(!e.facet(Ft).enabled)return[];const n=[],s=e.doc.iterLines(),o=wu(e).iter();let a=0;for(s.next();!s.done;){const i=s.value;let c=a,d=c+i.length;for(;o.value&&o.to<c;)o.next();const{from:u,to:p}=o,m=c>=u&&c<p,f=d>u&&d<=p;if(m){let h=(t=n.pop())!==null&&t!==void 0?t:[],g=h.pop();g&&g.folded&&(g.to=p),g&&h.push(g),(!g||!g.folded)&&h.push({from:u,to:p,folded:!0}),f||h.push({from:p,to:d,folded:!1}),n.push(h)}else f?n.push([{from:c,to:u,folded:!1},{from:u,to:p,folded:!0}]):n.push([{from:c,to:d,folded:!1}]);a=d+1,s.next()}return n}const tn=gn.define({create:e=>Vi(e),update:(e,t)=>Cs([t])||t.docChanged?Vi(t.state):e});function Cs(e){return e.find(t=>t.effects.find(n=>n.is(ku)||n.is(ju)))}class $v extends fa{constructor(t){super(t),this.count=void 0}shouldUpdate(t){if(!t.state.facet(Ft).enabled)return!1;if(t.docChanged)return!0;for(const n of t.transactions)for(const s of n.effects)if(s.is(Su))return!0;return!!(Cs(t.transactions)||this.count===void 0)}update(t){if(!this.shouldUpdate(t))return;this.map.clear();const n=t.state.field(tn);this.count=Nu(t.state),Cu(t.state,(s,o,a)=>{const i=this.findLine(o,n),c=this.findLine(a,n);let d=s.severity;for(let u=i;u<=c;u++){const p=this.get(u);p&&(d=[d,p].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(u,d)}})}drawLine(t,n){const{context:s,lineHeight:o,offsetX:a,offsetY:i}=t,c=this.get(n);c&&(s.globalAlpha=.65,s.beginPath(),s.rect(a,i,s.canvas.width-a,o),s.fillStyle=this.color(c),s.fill())}findLine(t,n){return n.findIndex(o=>{const a=o.slice(0,1)[0],i=o.slice(-1)[0];return!a||!i?!1:a.from<=t&&t<=i.to})+1}color(t){return t==="error"?"#d11":t==="warning"?"orange":"#999"}sort(t,n){return this.score(n)-this.score(t)}score(t){switch(t){case"error":return 3;case"warning":return 2;default:return 1}}}function Bv(e){return new $v(e)}class zv extends fa{constructor(t){super(t),this.getDrawInfo(),this._themeClasses=t.dom.classList.value}shouldUpdate(t){return t.state.facet(Ft).enabled?!!(t.docChanged||t.selectionSet||this._themeClasses!==this.view.dom.classList.value||Cs(t.transactions)):!1}update(t){if(!this.shouldUpdate(t))return;this.map.clear(),this._themeClasses!==this.view.dom.classList.value&&(this._drawInfo=void 0,this._themeClasses=this.view.dom.classList.value);const{ranges:n}=t.state.selection;let s=0;for(const[o,a]of t.state.field(tn).entries()){const i=[];let c=0;for(const u of a){do{if(s>=n.length||u.to<n[s].from)continue;if(n[s].from===n[s].to){s++;continue}const p=n[s],m={from:c+Math.max(u.from,p.from)-u.from,to:c+Math.min(u.to,p.to)-u.from,extends:p.to>u.to},f=i.slice(-1)[0];if(f&&f.to===m.from){let{to:h}=m;u.folded&&m.extends?h=m.from+1:u.folded&&!m.extends&&(h=f.to),i[i.length-1]=Object.assign(Object.assign({},f),{to:h,extends:m.extends})}else u.folded||i.push(m);if(m.extends)break;s++}while(s<n.length&&u.to>=n[s].from);c+=u.folded?1:u.to-u.from}if(i.length===0)continue;const d=o+1;this.map.set(d,i)}}drawLine(t,n){let{context:s,lineHeight:o,charWidth:a,offsetX:i,offsetY:c}=t;const d=this.get(n);if(d)for(const u of d){const p=i+u.from*a,m=(u.to-u.from)*a,f=s.canvas.width-p;u.extends&&(s.globalAlpha=.65,s.beginPath(),s.rect(p,c,f,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()),s.globalAlpha=1,s.beginPath(),s.rect(p,c,m,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const t=document.createElement("span");t.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(t);const s={backgroundColor:window.getComputedStyle(t).backgroundColor};return this._drawInfo=s,this.view.dom.removeChild(t),s}}function Wv(e){return new zv(e)}class Uv extends fa{constructor(t){super(t),this._fontInfoMap=new Map,this._themeClasses=new Set(t.dom.classList.values()),t.state.facet(Ft).enabled&&this.updateImpl(t.state)}shouldUpdate(t){return!!(t.docChanged||t.state.facet(Ft)!==t.startState.facet(Ft)||this.themeChanged()||Cs(t.transactions))}update(t){this.shouldUpdate(t)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(t.state,t.changes))}updateImpl(t,n){var s;this.map.clear(),this._displayText=t.facet(Ft).displayText,this.themeChanged()&&this._fontInfoMap.clear();let o;if(this._previousTree&&n){const m=Aa.addTree(this._previousTree),f=[];n.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),o=Aa.applyChanges(m,f)}const a=t.doc.toString(),i=(s=t.facet(tl))===null||s===void 0?void 0:s.parser,c=i?i.parse(a,o):void 0;this._previousTree=c;const d={style:m=>rl(t,m)};let u=[];if(c){const m=t.doc.lineAt(this.view.viewport.from).number,f=t.doc.lineAt(this.view.viewport.to).number,h=f-m,g=m/(t.doc.lines-h),{SizeRatio:b,PixelMultiplier:v}=zt,j=h*b*v,O=g*j,C=Math.max(1,Math.floor(m-O)),L=Math.min(f+Math.floor(j-O),t.doc.lines);oo(c,d,(_,R,I)=>{u.push({from:_,to:R,tags:I})},t.doc.line(C).from,t.doc.line(L).to)}this.updateMapImpl(t,u),u=[];const p=()=>{c&&(oo(c,d,(m,f,h)=>{u.push({from:m,to:f,tags:h})}),this.updateMapImpl(t,u),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(p):setTimeout(p)}updateMapImpl(t,n){this.map.clear();const s=t.doc.toString(),o=n.values();let a=o.next();for(const[i,c]of t.field(tn).entries()){const d=[];for(const p of c){if(p.from===p.to)continue;if(p.folded){d.push({text:"…",tags:""});continue}let m=p.from;for(;!a.done&&a.value.from<p.to;){const{from:f,to:h,tags:g}=a.value;if(h<m){a=o.next();continue}f>m&&d.push({text:s.slice(m,f),tags:""});const b=Math.max(f,p.from),v=Math.min(h,p.to);if(d.push({text:s.slice(b,v),tags:g}),m=v,h>v)break;a=o.next()}m!==p.to&&d.push({text:s.slice(m,p.to),tags:""})}const u=i+1;this.map.set(u,d)}}measure(t){const{color:n,font:s,lineHeight:o}=this.getFontInfo("");return t.textBaseline="ideographic",t.fillStyle=n,t.font=s,{charWidth:t.measureText("_").width,lineHeight:o}}beforeDraw(){this._fontInfoMap.clear()}drawLine(t,n){const s=this.get(n);if(!s)return;let{context:o,charWidth:a,lineHeight:i,offsetX:c,offsetY:d}=t,u;o.textBaseline="ideographic";for(const p of s){const m=this.getFontInfo(p.tags);switch((!u||u.color!==m.color)&&(o.fillStyle=m.color),(!u||u.font!==m.font)&&(o.font=m.font),u=m,i=Math.max(i,m.lineHeight),this._displayText){case"characters":{o.fillText(p.text,c,d+i),c+=p.text.length*a;break}case"blocks":{const f=/\S+/g;let h;for(;(h=f.exec(p.text))!==null;){const g=c+h.index*a;let b=(f.lastIndex-h.index)*a;if(g>o.canvas.width)break;g+b>o.canvas.width&&(b=o.canvas.width-g);const v=2/zt.SizeRatio,j=i-v;o.fillStyle=m.color,o.globalAlpha=.65,o.beginPath(),o.rect(g,d,b,j),o.fill()}c+=p.text.length*a;break}}}}getFontInfo(t){const n=this._fontInfoMap.get(t);if(n)return n;const s=Vr("span",{class:t}),o=Vr("div",{class:"cm-line",style:"display: none"},s);this.view.contentDOM.appendChild(o);const a=window.getComputedStyle(s),i=parseFloat(a.lineHeight)/zt.SizeRatio,c={color:a.color,font:`${a.fontStyle} ${a.fontWeight} ${i}px ${a.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(t,c),this.view.contentDOM.removeChild(o),c}themeChanged(){const t=this._themeClasses,n=new Set(this.view.dom.classList.values());if(this._themeClasses=n,!t||(t.delete("cm-focused"),n.delete("cm-focused"),t.size!==n.size))return!0;let s=!0;return t.forEach(o=>{n.has(o)||(s=!1)}),!s}}function Hv(e){return new Uv(e)}const Ed=4;function qv(e,t,n){const s=e[n];s&&(t.context.fillStyle=s,t.context.globalAlpha=1,t.context.beginPath(),t.context.rect(t.offsetX,t.offsetY,Ed,t.lineHeight),t.context.fill())}const Kv=tr.theme({"&":{height:"100%",overflowY:"auto"},"& .cm-minimap-gutter":{borderRight:0,flexShrink:0,left:"unset",position:"sticky",right:0,top:0},"& .cm-minimap-inner":{height:"100%",position:"absolute",right:0,top:0,overflowY:"hidden","& canvas":{display:"block"}},"& .cm-minimap-box-shadow":{boxShadow:"12px 0px 20px 5px #6c6c6c"}}),Gi=6,Vv=fs.fromClass(class{constructor(e){this.view=e,this.text=Hv(e),this.selection=Wv(e),this.diagnostic=Bv(e),e.state.facet(pn)&&this.create(e)}create(e){const t=e.state.facet(pn);if(!t)throw Error("Expected nonnull");this.inner=Vr("div",{class:"cm-minimap-inner"}),this.canvas=Vr("canvas"),this.dom=t.create(e).dom,this.dom.classList.add("cm-gutters"),this.dom.classList.add("cm-minimap-gutter"),this.inner.appendChild(this.canvas),this.dom.appendChild(this.inner),this.view.scrollDOM.insertBefore(this.dom,this.view.contentDOM.nextSibling);for(const n in this.view.state.facet(Ft).eventHandlers){const s=this.view.state.facet(Ft).eventHandlers[n];s&&this.dom.addEventListener(n,o=>s(o,this.view))}}remove(){this.dom&&this.dom.remove()}update(e){const t=e.startState.facet(pn),n=e.state.facet(pn);if(t&&!n){this.remove();return}!t&&n&&this.create(e.view),n&&(this.text.update(e),this.selection.update(e),this.diagnostic.update(e),this.render())}getWidth(){const e=this.view.dom.clientWidth;if(e<=zt.MaxWidth*Gi){const t=e/(zt.MaxWidth*Gi);return zt.MaxWidth*t}return zt.MaxWidth}render(){if(!this.dom||!this.canvas||!this.inner)return;this.text.beforeDraw(),this.updateBoxShadow(),this.dom.style.width=this.getWidth()+"px",this.canvas.style.maxWidth=this.getWidth()+"px",this.canvas.width=this.getWidth()*zt.PixelMultiplier;const e=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=e+"px",this.canvas.height=e*zt.PixelMultiplier,this.canvas.style.height=e+"px";const t=this.canvas.getContext("2d");if(!t)return;t.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:n,lineHeight:s}=this.text.measure(t);let{startIndex:o,endIndex:a,offsetY:i}=this.canvasStartAndEndIndex(t,s);const c=this.view.state.facet(Ft).gutters;for(let d=o;d<a;d++){const u=this.view.state.field(tn);if(d>=u.length)break;const p={offsetX:0,offsetY:i,context:t,lineHeight:s,charWidth:n};if(c.length){p.offsetX+=2;for(let m of c)qv(m,p,d+1),p.offsetX+=Ed;p.offsetX+=2}this.text.drawLine(p,d+1),this.selection.drawLine(p,d+1),this.diagnostic.drawLine(p,d+1),i+=s}t.restore()}canvasStartAndEndIndex(e,t){let{top:n,bottom:s}=this.view.documentPadding;n/=zt.SizeRatio,s/=zt.SizeRatio;const o=e.canvas.height,{clientHeight:a,scrollHeight:i,scrollTop:c}=this.view.scrollDOM;let d=c/(i-a);isNaN(d)&&(d=0);const u=this.view.state.field(tn).length,p=n+s+u*t,m=Math.max(0,d*(p-o)),f=Math.max(0,n-m),h=Math.round(Math.max(0,m-n)/t),g=Math.round((o-f)/t);return{startIndex:h,endIndex:h+g,offsetY:f}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:e,scrollWidth:t,scrollLeft:n}=this.view.scrollDOM;e+n<t?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:e=>tr.scrollMargins.of(t=>{var n;const s=(n=t.plugin(e))===null||n===void 0?void 0:n.getWidth();return s?{right:s}:null})}),pn=ms.define({combine:e=>{var t;return(t=e.find(n=>n!==null))!==null&&t!==void 0?t:null},enables:e=>[[Ft.compute([e],t=>t.facet(e)),Kv,tn,Vv,Fv]]});function Ji({file:e,onClose:t,projectPath:n,isSidebar:s=!1,isExpanded:o=!1,onToggleExpand:a=null}){const{t:i}=Et("codeEditor"),[c,d]=l.useState(""),[u,p]=l.useState(!0),[m,f]=l.useState(!1),[h,g]=l.useState(!1),[b,v]=l.useState(()=>{const F=localStorage.getItem("codeEditorTheme");return F?F==="dark":!0}),[j,O]=l.useState(!1),[C,L]=l.useState(!!e.diffInfo),[_,R]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[I,k]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[q,G]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[re,le]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),K=l.useRef(null),Z=l.useMemo(()=>{if(!e.diffInfo||!C||!I)return[];const F={};return[pn.compute(["doc"],ee=>{const xe=ro(ee)?.chunks||[];return Object.keys(F).forEach(fe=>delete F[fe]),xe.forEach(fe=>{const be=ee.doc.lineAt(fe.fromB).number,te=ee.doc.lineAt(Math.min(fe.toB,ee.doc.length)).number;for(let Se=be;Se<=te;Se++)F[Se]=b?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[F]}})]},[e.diffInfo,C,I,b]),U=l.useMemo(()=>!e.diffInfo||!C?[]:[fs.fromClass(class{constructor(F){setTimeout(()=>{const ne=ro(F.state)?.chunks||[];if(ne.length>0){const xe=ne[0];F.dispatch({effects:tr.scrollIntoView(xe.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[e.diffInfo,C]),de=l.useMemo(()=>{const F=ee=>{const ne=document.createElement("div");ne.className="cm-editor-toolbar-panel";let xe=0;const fe=()=>{const be=e.diffInfo&&C,Se=(be?ro(ee.state):null)?.chunks||[],$e=Se.length;let he='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(he+='<div style="display: flex; align-items: center; gap: 8px;">',be&&(he+=`
|
|
296
|
+
<span style="font-weight: 500;">${$e>0?`${xe+1}/${$e}`:"0"} ${i("toolbar.changes")}</span>
|
|
297
|
+
<button class="cm-diff-nav-btn cm-diff-nav-prev" title="${i("toolbar.previousChange")}" ${$e===0?"disabled":""}>
|
|
298
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
299
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
|
|
300
|
+
</svg>
|
|
301
|
+
</button>
|
|
302
|
+
<button class="cm-diff-nav-btn cm-diff-nav-next" title="${i("toolbar.nextChange")}" ${$e===0?"disabled":""}>
|
|
303
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
304
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
305
|
+
</svg>
|
|
306
|
+
</button>
|
|
307
|
+
`),he+="</div>",he+='<div style="display: flex; align-items: center; gap: 4px;">',e.diffInfo&&(he+=`
|
|
308
|
+
<button class="cm-toolbar-btn cm-toggle-diff-btn" title="${i(C?"toolbar.hideDiff":"toolbar.showDiff")}">
|
|
309
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
310
|
+
${C?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />'}
|
|
311
|
+
</svg>
|
|
312
|
+
</button>
|
|
313
|
+
`),he+=`
|
|
314
|
+
<button class="cm-toolbar-btn cm-settings-btn" title="${i("toolbar.settings")}">
|
|
315
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
316
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
317
|
+
</svg>
|
|
318
|
+
</button>
|
|
319
|
+
`,s&&a&&(he+=`
|
|
320
|
+
<button class="cm-toolbar-btn cm-expand-btn" title="${i(o?"toolbar.collapse":"toolbar.expand")}">
|
|
321
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
322
|
+
${o?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
|
|
323
|
+
</svg>
|
|
324
|
+
</button>
|
|
325
|
+
`),he+="</div>",he+="</div>",ne.innerHTML=he,be){const Le=ne.querySelector(".cm-diff-nav-prev"),ke=ne.querySelector(".cm-diff-nav-next");Le?.addEventListener("click",()=>{if(Se.length===0)return;xe=xe>0?xe-1:Se.length-1;const Ee=Se[xe];Ee&&ee.dispatch({effects:tr.scrollIntoView(Ee.fromB,{y:"center"})}),fe()}),ke?.addEventListener("click",()=>{if(Se.length===0)return;xe=xe<Se.length-1?xe+1:0;const Ee=Se[xe];Ee&&ee.dispatch({effects:tr.scrollIntoView(Ee.fromB,{y:"center"})}),fe()})}e.diffInfo&&ne.querySelector(".cm-toggle-diff-btn")?.addEventListener("click",()=>{L(!C)}),ne.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),s&&a&&ne.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{a()})};return fe(),{top:!0,dom:ne,update:fe}};return[Eu.of(F)]},[e.diffInfo,C,s,o,a]),ue=F=>{const ee=F.split(".").pop()?.toLowerCase();switch(ee){case"js":case"jsx":case"ts":case"tsx":return[Ru({jsx:!0,typescript:ee.includes("ts")})];case"py":return[Pu()];case"html":case"htm":return[Du()];case"css":case"scss":case"less":return[Mu()];case"json":return[Tu()];case"md":case"markdown":return[Iu()];default:return[]}};l.useEffect(()=>{(async()=>{try{if(p(!0),e.diffInfo&&e.diffInfo.new_string!==void 0&&e.diffInfo.old_string!==void 0){d(e.diffInfo.new_string),p(!1);return}const ee=await it.readFile(e.projectName,e.path);if(!ee.ok)throw new Error(`Failed to load file: ${ee.status} ${ee.statusText}`);const ne=await ee.json();d(ne.content)}catch(ee){console.error("Error loading file:",ee),d(`// Error loading file: ${ee.message}
|
|
326
|
+
// File: ${e.name}
|
|
327
|
+
// Path: ${e.path}`)}finally{p(!1)}})()},[e,n]);const ce=async()=>{f(!0);try{console.log("Saving file:",{projectName:e.projectName,path:e.path,contentLength:c?.length});const F=await it.saveFile(e.projectName,e.path,c);if(console.log("Save response:",{status:F.status,ok:F.ok,contentType:F.headers.get("content-type")}),!F.ok){const ne=F.headers.get("content-type");if(ne&&ne.includes("application/json")){const xe=await F.json();throw new Error(xe.error||`Save failed: ${F.status}`)}else{const xe=await F.text();throw console.error("Non-JSON error response:",xe),new Error(`Save failed: ${F.status} ${F.statusText}`)}}const ee=await F.json();console.log("Save successful:",ee),O(!0),setTimeout(()=>O(!1),2e3)}catch(F){console.error("Error saving file:",F),alert(`Error saving file: ${F.message}`)}finally{f(!1)}},J=()=>{const F=new Blob([c],{type:"text/plain"}),ee=URL.createObjectURL(F),ne=document.createElement("a");ne.href=ee,ne.download=e.name,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(ee)},_e=()=>{g(!h)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",b?"dark":"light")},[b]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",_.toString())},[_]),l.useEffect(()=>{const F=()=>{const ee=localStorage.getItem("codeEditorTheme");ee&&v(ee==="dark");const ne=localStorage.getItem("codeEditorWordWrap");ne!==null&&R(ne==="true");const xe=localStorage.getItem("codeEditorShowMinimap");xe!==null&&k(xe!=="false");const fe=localStorage.getItem("codeEditorLineNumbers");fe!==null&&G(fe!=="false");const be=localStorage.getItem("codeEditorFontSize");be&&le(be)};return window.addEventListener("storage",F),window.addEventListener("codeEditorSettingsChanged",F),()=>{window.removeEventListener("storage",F),window.removeEventListener("codeEditorSettingsChanged",F)}},[]),l.useEffect(()=>{const F=ee=>{(ee.ctrlKey||ee.metaKey)&&(ee.key==="s"?(ee.preventDefault(),ce()):ee.key==="Escape"&&(ee.preventDefault(),t()))};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[c]),u?r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
328
|
+
.code-editor-loading {
|
|
329
|
+
background-color: ${b?"#111827":"#ffffff"} !important;
|
|
330
|
+
}
|
|
331
|
+
.code-editor-loading:hover {
|
|
332
|
+
background-color: ${b?"#111827":"#ffffff"} !important;
|
|
333
|
+
}
|
|
334
|
+
`}),s?r.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:i("loading",{fileName:e.name})})]})}):r.jsx("div",{className:"fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center",children:r.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:i("loading",{fileName:e.name})})]})})})]}):r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
335
|
+
/* Light background for full line changes */
|
|
336
|
+
.cm-deletedChunk {
|
|
337
|
+
background-color: ${b?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
|
|
338
|
+
border-left: 3px solid ${b?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
|
|
339
|
+
padding-left: 4px !important;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.cm-insertedChunk {
|
|
343
|
+
background-color: ${b?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
|
|
344
|
+
border-left: 3px solid ${b?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
|
|
345
|
+
padding-left: 4px !important;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/* Override linear-gradient underline and use solid darker background for partial changes */
|
|
349
|
+
.cm-editor.cm-merge-b .cm-changedText {
|
|
350
|
+
background: ${b?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
|
|
351
|
+
padding-top: 2px !important;
|
|
352
|
+
padding-bottom: 2px !important;
|
|
353
|
+
margin-top: -2px !important;
|
|
354
|
+
margin-bottom: -2px !important;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.cm-editor .cm-deletedChunk .cm-changedText {
|
|
358
|
+
background: ${b?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
|
|
359
|
+
padding-top: 2px !important;
|
|
360
|
+
padding-bottom: 2px !important;
|
|
361
|
+
margin-top: -2px !important;
|
|
362
|
+
margin-bottom: -2px !important;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/* Minimap gutter styling */
|
|
366
|
+
.cm-gutter.cm-gutter-minimap {
|
|
367
|
+
background-color: ${b?"#1e1e1e":"#f5f5f5"};
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/* Editor toolbar panel styling */
|
|
371
|
+
.cm-editor-toolbar-panel {
|
|
372
|
+
padding: 8px 12px;
|
|
373
|
+
background-color: ${b?"#1f2937":"#ffffff"};
|
|
374
|
+
border-bottom: 1px solid ${b?"#374151":"#e5e7eb"};
|
|
375
|
+
color: ${b?"#d1d5db":"#374151"};
|
|
376
|
+
font-size: 14px;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.cm-diff-nav-btn,
|
|
380
|
+
.cm-toolbar-btn {
|
|
381
|
+
padding: 4px;
|
|
382
|
+
background: transparent;
|
|
383
|
+
border: none;
|
|
384
|
+
cursor: pointer;
|
|
385
|
+
border-radius: 4px;
|
|
386
|
+
display: inline-flex;
|
|
387
|
+
align-items: center;
|
|
388
|
+
justify-content: center;
|
|
389
|
+
color: inherit;
|
|
390
|
+
transition: background-color 0.2s;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.cm-diff-nav-btn:hover,
|
|
394
|
+
.cm-toolbar-btn:hover {
|
|
395
|
+
background-color: ${b?"#374151":"#f3f4f6"};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.cm-diff-nav-btn:disabled {
|
|
399
|
+
opacity: 0.5;
|
|
400
|
+
cursor: not-allowed;
|
|
401
|
+
}
|
|
402
|
+
`}),r.jsx("div",{className:s?"w-full h-full flex flex-col":`fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${h?"md:p-0":""}`,children:r.jsxs("div",{className:s?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(h?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border flex-shrink-0 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:e.name}),e.diffInfo&&r.jsx("span",{className:"text-xs bg-primary/15 dark:bg-primary/30 text-primary dark:text-primary/80 px-2 py-1 rounded whitespace-nowrap",children:i("header.showingChanges")})]}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate",children:e.path})]})}),r.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:J,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:i("actions.download"),children:r.jsx(uo,{className:"w-5 h-5 md:w-4 md:h-4"})}),r.jsx("button",{onClick:ce,disabled:m,className:`px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors min-h-[44px] md:min-h-0 ${j?"bg-green-600 hover:bg-green-700":"bg-primary hover:bg-primary/90"}`,children:j?r.jsxs(r.Fragment,{children:[r.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),r.jsx("span",{className:"hidden sm:inline",children:i("actions.saved")})]}):r.jsxs(r.Fragment,{children:[r.jsx(jm,{className:"w-5 h-5 md:w-4 md:h-4"}),r.jsx("span",{className:"hidden sm:inline",children:i(m?"actions.saving":"actions.save")})]})}),!s&&r.jsx("button",{onClick:_e,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:i(h?"actions.exitFullscreen":"actions.fullscreen"),children:h?r.jsx(hm,{className:"w-4 h-4"}):r.jsx(pl,{className:"w-4 h-4"})}),r.jsx("button",{onClick:t,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:i("actions.close"),children:r.jsx(Ut,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Au,{ref:K,value:c,onChange:d,extensions:[...ue(e.name),...de,...e.diffInfo&&C&&e.diffInfo.old_string!==void 0?[Cv({original:e.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...Z,...U]:[],..._?[tr.lineWrapping]:[]],theme:b?_u:void 0,height:"100%",style:{fontSize:`${re}px`,height:"100%"},basicSetup:{lineNumbers:q,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),r.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-border bg-muted flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[r.jsxs("span",{children:[i("footer.lines")," ",c.split(`
|
|
403
|
+
`).length]}),r.jsxs("span",{children:[i("footer.characters")," ",c.length]})]}),r.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:i("footer.shortcuts")})]})]})})]})}var Gv=Np(),Jv=Cp(),Yv=Ep(),no={exports:{}},Yi;function Xv(){return Yi||(Yi=1,function(e,t){(function(n,s){e.exports=s()})(self,()=>(()=>{var n={6:(i,c)=>{function d(p){try{const m=new URL(p),f=m.password&&m.username?`${m.protocol}//${m.username}:${m.password}@${m.host}`:m.username?`${m.protocol}//${m.username}@${m.host}`:`${m.protocol}//${m.host}`;return p.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(p,m,f,h={}){this._terminal=p,this._regex=m,this._handler=f,this._options=h}provideLinks(p,m){const f=u.computeLink(p,this._regex,this._terminal,this._handler);m(this._addCallbacks(f))}_addCallbacks(p){return p.map(m=>(m.leave=this._options.leave,m.hover=(f,h)=>{if(this._options.hover){const{range:g}=m;this._options.hover(f,h,g)}},m))}};class u{static computeLink(m,f,h,g){const b=new RegExp(f.source,(f.flags||"")+"g"),[v,j]=u._getWindowedLineStrings(m-1,h),O=v.join("");let C;const L=[];for(;C=b.exec(O);){const _=C[0];if(!d(_))continue;const[R,I]=u._mapStrIdx(h,j,0,C.index),[k,q]=u._mapStrIdx(h,R,I,_.length);if(R===-1||I===-1||k===-1||q===-1)continue;const G={start:{x:I+1,y:R+1},end:{x:q,y:k+1}};L.push({range:G,text:_,activate:g})}return L}static _getWindowedLineStrings(m,f){let h,g=m,b=m,v=0,j="";const O=[];if(h=f.buffer.active.getLine(m)){const C=h.translateToString(!0);if(h.isWrapped&&C[0]!==" "){for(v=0;(h=f.buffer.active.getLine(--g))&&v<2048&&(j=h.translateToString(!0),v+=j.length,O.push(j),h.isWrapped&&j.indexOf(" ")===-1););O.reverse()}for(O.push(C),v=0;(h=f.buffer.active.getLine(++b))&&h.isWrapped&&v<2048&&(j=h.translateToString(!0),v+=j.length,O.push(j),j.indexOf(" ")===-1););}return[O,g]}static _mapStrIdx(m,f,h,g){const b=m.buffer.active,v=b.getNullCell();let j=h;for(;g;){const O=b.getLine(f);if(!O)return[-1,-1];for(let C=j;C<O.length;++C){O.getCell(C,v);const L=v.getChars();if(v.getWidth()&&(g-=L.length||1,C===O.length-1&&L==="")){const _=b.getLine(f+1);_&&_.isWrapped&&(_.getCell(0,v),v.getWidth()===2&&(g+=1))}if(g<0)return[f,C]}f++,j=0}return[f,j]}}c.LinkComputer=u}},s={};function o(i){var c=s[i];if(c!==void 0)return c.exports;var d=s[i]={exports:{}};return n[i](d,d.exports,o),d.exports}var a={};return(()=>{var i=a;Object.defineProperty(i,"__esModule",{value:!0}),i.WebLinksAddon=void 0;const c=o(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(p,m){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=m}else console.warn("Opening link blocked as opener could not be cleared")}i.WebLinksAddon=class{constructor(p=u,m={}){this._handler=p,this._options=m}activate(p){this._terminal=p;const m=this._options,f=m.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,f,this._handler,m))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(no)),no.exports}var Qv=Xv();const Zv=`
|
|
404
|
+
.xterm .xterm-screen {
|
|
405
|
+
outline: none !important;
|
|
406
|
+
}
|
|
407
|
+
.xterm:focus .xterm-screen {
|
|
408
|
+
outline: none !important;
|
|
409
|
+
}
|
|
410
|
+
.xterm-screen:focus {
|
|
411
|
+
outline: none !important;
|
|
412
|
+
}
|
|
413
|
+
`;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=Zv,document.head.appendChild(e)}function eb({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:s=!1,onProcessComplete:o,minimal:a=!1,autoConnect:i=!1}){const{t:c}=Et("chat"),d=l.useRef(null),u=l.useRef(null),p=l.useRef(null),m=l.useRef(null),[f,h]=l.useState(!1),[g,b]=l.useState(!1),[v,j]=l.useState(!1),[O,C]=l.useState(null),[L,_]=l.useState(!1),R=l.useRef(e),I=l.useRef(t),k=l.useRef(n),q=l.useRef(s),G=l.useRef(o);l.useEffect(()=>{R.current=e,I.current=t,k.current=n,q.current=s,G.current=o});const re=l.useCallback(async()=>{if(!(L||f))try{let ce;if(!yg){const J=localStorage.getItem("auth-token");if(!J){console.error("No authentication token found for Shell WebSocket connection");return}ce=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(J)}`}m.current=new WebSocket(ce),m.current.onopen=()=>{h(!0),_(!1),setTimeout(()=>{p.current&&u.current&&(p.current.fit(),m.current.send(JSON.stringify({type:"init",projectPath:R.current.fullPath||R.current.path,sessionId:q.current?null:I.current?.id,hasSession:q.current?!1:!!I.current,provider:q.current?"plain-shell":I.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:k.current,isPlainShell:q.current})))},100)},m.current.onmessage=J=>{try{const _e=JSON.parse(J.data);if(_e.type==="output"){let F=_e.data;if(q.current&&G.current){const ee=F.replace(/\x1b\[[0-9;]*m/g,"");if(ee.includes("Process exited with code 0"))G.current(0);else if(ee.match(/Process exited with code (\d+)/)){const ne=parseInt(ee.match(/Process exited with code (\d+)/)[1]);ne!==0&&G.current(ne)}}u.current&&u.current.write(F)}else _e.type==="url_open"&&window.open(_e.url,"_blank")}catch(_e){console.error("[Shell] Error handling WebSocket message:",_e,J.data)}},m.current.onclose=J=>{h(!1),_(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},m.current.onerror=J=>{h(!1),_(!1)}}catch{h(!1),_(!1)}},[L,f]),le=l.useCallback(()=>{!g||f||L||(_(!0),re())},[g,f,L,re]),K=l.useCallback(()=>{m.current&&(m.current.close(),m.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),h(!1),_(!1)},[]),Z=l.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),U=l.useMemo(()=>Z?Z.slice(0,30):null,[Z]),de=l.useMemo(()=>Z?Z.slice(0,50):null,[Z]),ue=()=>{j(!0),m.current&&(m.current.close(),m.current=null),u.current&&(u.current.dispose(),u.current=null,p.current=null),h(!1),b(!1),setTimeout(()=>{j(!1)},200)};return l.useEffect(()=>{const ce=t?.id||null;O!==null&&O!==ce&&g&&K(),C(ce)},[t?.id,g,K]),l.useEffect(()=>{if(!d.current||!e||v||u.current)return;u.current=new Gv.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),p.current=new Jv.FitAddon;const ce=new Yv.WebglAddon,J=new Qv.WebLinksAddon;u.current.loadAddon(p.current),u.current.loadAddon(J);try{u.current.loadAddon(ce)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler(F=>(F.ctrlKey||F.metaKey)&&F.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):(F.ctrlKey||F.metaKey)&&F.key==="v"?(navigator.clipboard.readText().then(ee=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:ee}))}).catch(()=>{}),!1):!0),setTimeout(()=>{p.current&&(p.current.fit(),u.current&&m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),b(!0),u.current.onData(F=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:F}))});const _e=new ResizeObserver(()=>{p.current&&u.current&&setTimeout(()=>{p.current.fit(),m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&_e.observe(d.current),()=>{_e.disconnect(),m.current&&(m.current.readyState===WebSocket.OPEN||m.current.readyState===WebSocket.CONNECTING)&&m.current.close(),m.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,v]),l.useEffect(()=>{!i||!g||L||f||le()},[i,g,L,f,le]),e?a?r.jsx("div",{className:"h-full w-full bg-gray-900",children:r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):r.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${f?"bg-green-500":"bg-red-500"}`}),t&&r.jsxs("span",{className:"text-xs text-primary/80",children:["(",U,"...)"]}),!t&&r.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!g&&r.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),v&&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:K,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:ue,disabled:v||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"}}),!g&&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")})}),g&&!f&&!L&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("button",{onClick:le,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:c("shell.actions.connectTitle"),children:[r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),r.jsx("span",{children:c("shell.actions.connect")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:s?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:de}):c("shell.startSession")})]})}),L&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[r.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),r.jsx("span",{className:"text-base font-medium",children:c("shell.connecting")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:s?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName})})]})})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:c("shell.selectProject.title")}),r.jsx("p",{children:c("shell.selectProject.description")})]})})}function Ad({project:e,session:t=null,command:n=null,isPlainShell:s=null,autoConnect:o=!0,onComplete:a=null,onClose:i=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:m=!1}){const[f,h]=l.useState(!1),g=s!==null?s:n!==null,b=l.useCallback(v=>{h(!0),a&&a(v)},[a]);return e?r.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!m&&u&&c&&r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-200",children:c}),f&&r.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),i&&r.jsx("button",{onClick:i,className:"text-gray-400 hover:text-white",title:"Close",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),r.jsx("div",{className:"flex-1 w-full min-h-0",children:r.jsx(eb,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:g,onProcessComplete:b,minimal:m,autoConnect:m?!0:o})})]}):r.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),r.jsx("p",{children:"A project is required to open a shell"})]})})}async function tb(e,t){const n=new FormData,s=`recording_${Date.now()}.webm`,o=new File([e],s,{type:e.type});n.append("audio",o);const a=window.localStorage.getItem("whisperMode")||"default";n.append("mode",a);try{const i=await it.transcribe(n);if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function rb({onTranscript:e,className:t=""}){const[n,s]=l.useState("idle"),[o,a]=l.useState(null),[i,c]=l.useState(!0),d=l.useRef(null),u=l.useRef(null),p=l.useRef([]),m=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),a("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),a("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),a(null)})()},[]);const f=async()=>{try{if(console.log("Starting recording..."),a(null),p.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const C=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=C;const L=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",_=new MediaRecorder(C,{mimeType:L});d.current=_,_.ondataavailable=R=>{R.data.size>0&&p.current.push(R.data)},_.onstop=async()=>{console.log("Recording stopped, creating blob...");const R=new Blob(p.current,{type:L});u.current&&(u.current.getTracks().forEach(G=>G.stop()),u.current=null),s("transcribing");const I=window.localStorage.getItem("whisperMode")||"default",k=I==="prompt"||I==="vibe"||I==="instructions"||I==="architect";let q;k&&(q=setTimeout(()=>{s("processing")},2e3));try{const G=await tb(R);G&&e&&e(G)}catch(G){console.error("Transcription error:",G),a(G.message)}finally{q&&clearTimeout(q),s("idle")}},_.start(),s("recording"),console.log("Recording started successfully")}catch(C){console.error("Failed to start recording:",C);let L="Microphone access failed";C.name==="NotAllowedError"?L="Microphone access denied. Please allow microphone permissions.":C.name==="NotFoundError"?L="No microphone found. Please check your audio devices.":C.name==="NotSupportedError"?L="Microphone not supported by this browser.":C.name==="NotReadableError"?L="Microphone is being used by another application.":C.message.includes("HTTPS")&&(L=C.message),a(L),s("idle")}},h=()=>{console.log("Stopping recording..."),d.current&&d.current.state==="recording"?d.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),u.current&&(u.current.getTracks().forEach(C=>C.stop()),u.current=null),s("idle"))},g=C=>{if(C&&(C.preventDefault(),C.stopPropagation()),!i)return;const L=Date.now();if(L-m.current<300){console.log("Ignoring rapid tap");return}m.current=L,console.log("Button clicked, current state:",n),n==="idle"?f():n==="recording"&&h()};l.useEffect(()=>()=>{u.current&&u.current.getTracks().forEach(C=>C.stop())},[]);const b=()=>{if(!i)return{icon:r.jsx(es,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(n){case"recording":return{icon:r.jsx(es,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:r.jsx(Ot,{className:"w-5 h-5 animate-spin"}),className:"bg-primary hover:bg-primary/90",disabled:!0};case"processing":return{icon:r.jsx(il,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:r.jsx(es,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:v,className:j,disabled:O}=b();return r.jsxs("div",{className:"relative",children:[r.jsx("button",{type:"button",style:{backgroundColor:n==="recording"?"#ef4444":n==="transcribing"?"#3b82f6":n==="processing"?"#a855f7":"#374151"},className:`
|
|
414
|
+
flex items-center justify-center
|
|
415
|
+
w-12 h-12 rounded-full
|
|
416
|
+
text-white transition-all duration-200
|
|
417
|
+
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ring
|
|
418
|
+
dark:ring-offset-gray-800
|
|
419
|
+
touch-action-manipulation
|
|
420
|
+
${O?"cursor-not-allowed opacity-75":"cursor-pointer"}
|
|
421
|
+
${n==="recording"?"animate-pulse":""}
|
|
422
|
+
hover:opacity-90
|
|
423
|
+
${t}
|
|
424
|
+
`,onClick:g,disabled:O,children:v}),o&&r.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
|
|
425
|
+
bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
|
|
426
|
+
animate-fade-in`,children:o}),n==="recording"&&r.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),n==="processing"&&r.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}function Xi({diff:e,fileName:t,isMobile:n,wrapText:s}){if(!e)return r.jsx("div",{className:"p-4 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No diff available"});const o=(a,i)=>{const c=a.startsWith("+")&&!a.startsWith("+++"),d=a.startsWith("-")&&!a.startsWith("---"),u=a.startsWith("@@");return r.jsx("div",{className:`font-mono text-xs p-2 ${n&&s?"whitespace-pre-wrap break-all":"whitespace-pre overflow-x-auto"} ${c?"bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-300":d?"bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300":u?"bg-primary/10 dark:bg-primary/20 text-primary":"text-gray-600 dark:text-gray-400"}`,children:a},i)};return r.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-background/95 shadow-sm",children:[t&&r.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e.split(`
|
|
427
|
+
`).map((a,i)=>o(a,i))]})}function nb({selectedProject:e,isMobile:t,onFileOpen:n}){const[s,o]=l.useState(null),[a,i]=l.useState({}),[c,d]=l.useState(!1),[u,p]=l.useState(""),[m,f]=l.useState(new Set),[h,g]=l.useState(new Set),[b,v]=l.useState(!1),[j,O]=l.useState(""),[C,L]=l.useState([]),[_,R]=l.useState(!0),[I,k]=l.useState(!1),[q,G]=l.useState(!1),[re,le]=l.useState(!1),[K,Z]=l.useState(""),[U,de]=l.useState(!1),[ue,ce]=l.useState("changes"),[J,_e]=l.useState([]),[F,ee]=l.useState(new Set),[ne,xe]=l.useState({}),[fe,be]=l.useState(!1),[te,Se]=l.useState(null),[$e,he]=l.useState(!1),[nt,Le]=l.useState(!1),[ke,Ee]=l.useState(!1),[Fe,rt]=l.useState(!1),[He,Xe]=l.useState(t),[pe,De]=l.useState(null),[at,Ke]=l.useState(!1),Be=l.useRef(null),A=l.useRef(null),[V,y]=l.useState(()=>localStorage.getItem("selected-provider")||"claude");l.useEffect(()=>{const M=()=>{const W=localStorage.getItem("selected-provider")||"claude";y(W)};return window.addEventListener("storage",M),()=>window.removeEventListener("storage",M)},[]),l.useEffect(()=>{e&&(x(),S(),B(),ue==="history"&&pt())},[e,ue]),l.useEffect(()=>{const M=W=>{A.current&&!A.current.contains(W.target)&&G(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const x=async()=>{if(e){d(!0);try{const W=await(await me(`/api/git/status?project=${encodeURIComponent(e.name)}`)).json();if(W.error)console.error("Git status error:",W.error),o({error:W.error,details:W.details});else{o(W),O(W.branch||"main");const Ce=new Set([...W.modified||[],...W.added||[],...W.deleted||[],...W.untracked||[]]);g(Ce);for(const st of W.modified||[])gt(st);for(const st of W.added||[])gt(st);for(const st of W.deleted||[])gt(st);for(const st of W.untracked||[])gt(st)}}catch(M){console.error("Error fetching git status:",M)}finally{d(!1)}}},S=async()=>{try{const W=await(await me(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!W.error&&W.branches&&L(W.branches)}catch(M){console.error("Error fetching branches:",M)}},B=async()=>{if(e)try{const W=await(await me(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();W.error?Se(null):Se(W)}catch(M){console.error("Error fetching remote status:",M),Se(null)}},D=async M=>{try{const Ce=await(await me("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:M})})).json();Ce.success?(O(M),G(!1),x()):console.error("Failed to switch branch:",Ce.error)}catch(W){console.error("Error switching branch:",W)}},Y=async()=>{if(K.trim()){de(!0);try{const W=await(await me("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:K.trim()})})).json();W.success?(O(K.trim()),le(!1),G(!1),Z(""),S(),x()):console.error("Failed to create branch:",W.error)}catch(M){console.error("Error creating branch:",M)}finally{de(!1)}}},we=async()=>{he(!0);try{const W=await(await me("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();W.success?(x(),B()):console.error("Fetch failed:",W.error)}catch(M){console.error("Error fetching from remote:",M)}finally{he(!1)}},Ie=async()=>{Le(!0);try{const W=await(await me("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();W.success?(x(),B()):console.error("Pull failed:",W.error)}catch(M){console.error("Error pulling from remote:",M)}finally{Le(!1)}},Oe=async()=>{Ee(!0);try{const W=await(await me("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();W.success?(x(),B()):console.error("Push failed:",W.error)}catch(M){console.error("Error pushing to remote:",M)}finally{Ee(!1)}},dt=async()=>{rt(!0);try{const W=await(await me("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:j})})).json();W.success?(x(),B()):console.error("Publish failed:",W.error)}catch(M){console.error("Error publishing branch:",M)}finally{rt(!1)}},Ne=async M=>{try{const Ce=await(await me("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:M})})).json();Ce.success?(g(st=>{const kt=new Set(st);return kt.delete(M),kt}),x()):console.error("Discard failed:",Ce.error)}catch(W){console.error("Error discarding changes:",W)}},Re=async M=>{try{const Ce=await(await me("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:M})})).json();Ce.success?(g(st=>{const kt=new Set(st);return kt.delete(M),kt}),x()):console.error("Delete failed:",Ce.error)}catch(W){console.error("Error deleting untracked file:",W)}},lt=async()=>{if(!pe)return;const{type:M,file:W,message:Ce}=pe;De(null);try{switch(M){case"discard":await Ne(W);break;case"delete":await Re(W);break;case"commit":await oe();break;case"pull":await Ie();break;case"push":await Oe();break;case"publish":await dt();break}}catch(st){console.error(`Error executing ${M}:`,st)}},gt=async M=>{try{const Ce=await(await me(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(M)}`)).json();!Ce.error&&Ce.diff&&i(st=>({...st,[M]:Ce.diff}))}catch(W){console.error("Error fetching file diff:",W)}},It=async M=>{if(n)try{const Ce=await(await me(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(M)}`)).json();if(Ce.error){console.error("Error fetching file with diff:",Ce.error),n(M);return}const st={old_string:Ce.oldContent||"",new_string:Ce.currentContent||""};n(M,st)}catch(W){console.error("Error opening file:",W),n(M)}},pt=async()=>{try{const W=await(await me(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!W.error&&W.commits&&_e(W.commits)}catch(M){console.error("Error fetching commits:",M)}},Nt=async M=>{try{const Ce=await(await me(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${M}`)).json();!Ce.error&&Ce.diff&&xe(st=>({...st,[M]:Ce.diff}))}catch(W){console.error("Error fetching commit diff:",W)}},bt=async()=>{be(!0);try{const W=await(await me("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(h),provider:V})})).json();W.message?p(W.message):console.error("Failed to generate commit message:",W.error)}catch(M){console.error("Error generating commit message:",M)}finally{be(!1)}},ye=M=>{f(W=>{const Ce=new Set(W);return Ce.has(M)?Ce.delete(M):Ce.add(M),Ce})},X=M=>{ee(W=>{const Ce=new Set(W);return Ce.has(M)?Ce.delete(M):(Ce.add(M),ne[M]||Nt(M)),Ce})},ie=M=>{g(W=>{const Ce=new Set(W);return Ce.has(M)?Ce.delete(M):Ce.add(M),Ce})},oe=async()=>{if(!(!u.trim()||h.size===0)){v(!0);try{const W=await(await me("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,message:u,files:Array.from(h)})})).json();W.success?(p(""),g(new Set),x(),B()):console.error("Commit failed:",W.error)}catch(M){console.error("Error committing changes:",M)}finally{v(!1)}}},Je=async()=>{Ke(!0);try{const W=await(await me("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();W.success?(x(),B()):(console.error("Initial commit failed:",W.error),alert(W.error||"Failed to create initial commit"))}catch(M){console.error("Error creating initial commit:",M),alert("Failed to create initial commit")}finally{Ke(!1)}},ct=M=>{switch(M){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return M}},wt=M=>{const W=F.has(M.hash),Ce=ne[M.hash];return r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[r.jsxs("div",{className:"flex items-start p-3 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer",onClick:()=>X(M.hash),children:[r.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:W?r.jsx(jr,{className:"w-3 h-3"}):r.jsx(qr,{className:"w-3 h-3"})}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:M.message}),r.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[M.author," • ",M.date]})]}),r.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:M.hash.substring(0,7)})]})})]}),W&&Ce&&r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900",children:r.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[r.jsx("div",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 mb-2",children:M.stats}),r.jsx(Xi,{diff:Ce,fileName:"commit",isMobile:t,wrapText:_})]})})]},M.hash)},Pe=(M,W)=>{const Ce=m.has(M),st=h.has(M),kt=a[M];return r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700 last:border-0",children:[r.jsxs("div",{className:`flex items-center hover:bg-gray-50 dark:hover:bg-gray-800 ${t?"px-2 py-1.5":"px-3 py-2"}`,children:[r.jsx("input",{type:"checkbox",checked:st,onChange:()=>ie(M),onClick:E=>E.stopPropagation(),className:`rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:focus:ring-ring dark:bg-gray-800 dark:checked:bg-primary ${t?"mr-1.5":"mr-2"}`}),r.jsxs("div",{className:"flex items-center flex-1",children:[r.jsx("div",{className:`p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded cursor-pointer ${t?"mr-1":"mr-2"}`,onClick:E=>{E.stopPropagation(),ye(M)},children:r.jsx(qr,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${Ce?"rotate-90":"rotate-0"}`})}),r.jsx("span",{className:`flex-1 truncate ${t?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:E=>{E.stopPropagation(),It(M)},title:"Click to open file",children:M}),r.jsxs("div",{className:"flex items-center gap-1",children:[(W==="M"||W==="D")&&r.jsxs("button",{onClick:E=>{E.stopPropagation(),De({type:"discard",file:M,message:`Discard all changes to "${M}"? This action cannot be undone.`})},className:`${t?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Discard changes",children:[r.jsx(er,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Discard"})]}),W==="U"&&r.jsxs("button",{onClick:E=>{E.stopPropagation(),De({type:"delete",file:M,message:`Delete untracked file "${M}"? This action cannot be undone.`})},className:`${t?"px-2 py-1 text-xs":"p-1"} hover:bg-red-100 dark:hover:bg-red-900 rounded text-red-600 dark:text-red-400 font-medium flex items-center gap-1`,title:"Delete untracked file",children:[r.jsx(er,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Delete"})]}),r.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${W==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":W==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":W==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,title:ct(W),children:W})]})]})]}),r.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${Ce&&kt?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[r.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${W==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":W==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":W==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,children:W}),r.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ct(W)})]}),t&&r.jsx("button",{onClick:E=>{E.stopPropagation(),R(!_)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:_?"Switch to horizontal scroll":"Switch to text wrap",children:_?"↔️ Scroll":"↩️ Wrap"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto",children:kt&&r.jsx(Xi,{diff:kt,fileName:M,isMobile:t,wrapText:_})})]})]},M)};return e?r.jsxs("div",{className:"h-full flex flex-col bg-background",children:[r.jsxs("div",{className:`flex items-center justify-between border-b border-gray-200 dark:border-gray-700 ${t?"px-3 py-2":"px-4 py-3"}`,children:[r.jsxs("div",{className:"relative",ref:A,children:[r.jsxs("button",{onClick:()=>G(!q),className:`flex items-center hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors ${t?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[r.jsx($s,{className:`text-gray-600 dark:text-gray-400 ${t?"w-3 h-3":"w-4 h-4"}`}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:`font-medium ${t?"text-xs":"text-sm"}`,children:j}),te?.hasRemote&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[te.ahead>0&&r.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${te.ahead} commit${te.ahead!==1?"s":""} ahead`,children:["↑",te.ahead]}),te.behind>0&&r.jsxs("span",{className:"text-primary",title:`${te.behind} commit${te.behind!==1?"s":""} behind`,children:["↓",te.behind]}),te.isUpToDate&&r.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),r.jsx(jr,{className:`w-3 h-3 text-gray-500 transition-transform ${q?"rotate-180":""}`})]}),q&&r.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-50",children:[r.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:C.map(M=>r.jsx("button",{onClick:()=>D(M),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${M===j?"bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100":"text-gray-700 dark:text-gray-300"}`,children:r.jsxs("div",{className:"flex items-center space-x-2",children:[M===j&&r.jsx(ir,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),r.jsx("span",{className:M===j?"font-medium":"",children:M})]})},M))}),r.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:r.jsxs("button",{onClick:()=>{le(!0),G(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center space-x-2",children:[r.jsx(Gr,{className:"w-3 h-3"}),r.jsx("span",{children:"Create new branch"})]})})]})]}),r.jsxs("div",{className:`flex items-center ${t?"gap-1":"gap-2"}`,children:[te?.hasRemote&&r.jsxs(r.Fragment,{children:[!te?.hasUpstream&&r.jsxs("button",{onClick:()=>De({type:"publish",message:`Publish branch "${j}" to ${te.remoteName}?`}),disabled:Fe,className:"px-2 py-1 text-xs bg-purple-600 text-white rounded hover:bg-purple-700 disabled:opacity-50 flex items-center gap-1",title:`Publish branch "${j}" to ${te.remoteName}`,children:[r.jsx(Dn,{className:`w-3 h-3 ${Fe?"animate-pulse":""}`}),r.jsx("span",{children:Fe?"Publishing...":"Publish"})]}),te?.hasUpstream&&!te?.isUpToDate&&r.jsxs(r.Fragment,{children:[te.behind>0&&r.jsxs("button",{onClick:()=>De({type:"pull",message:`Pull ${te.behind} commit${te.behind!==1?"s":""} from ${te.remoteName}?`}),disabled:nt,className:"px-2 py-1 text-xs bg-green-600 text-white rounded hover:bg-green-700 disabled:opacity-50 flex items-center gap-1",title:`Pull ${te.behind} commit${te.behind!==1?"s":""} from ${te.remoteName}`,children:[r.jsx(uo,{className:`w-3 h-3 ${nt?"animate-pulse":""}`}),r.jsx("span",{children:nt?"Pulling...":`Pull ${te.behind}`})]}),te.ahead>0&&r.jsxs("button",{onClick:()=>De({type:"push",message:`Push ${te.ahead} commit${te.ahead!==1?"s":""} to ${te.remoteName}?`}),disabled:ke,className:"px-2 py-1 text-xs bg-orange-600 text-white rounded hover:bg-orange-700 disabled:opacity-50 flex items-center gap-1",title:`Push ${te.ahead} commit${te.ahead!==1?"s":""} to ${te.remoteName}`,children:[r.jsx(Dn,{className:`w-3 h-3 ${ke?"animate-pulse":""}`}),r.jsx("span",{children:ke?"Pushing...":`Push ${te.ahead}`})]}),(te.ahead>0||te.behind>0&&te.ahead>0)&&r.jsxs("button",{onClick:we,disabled:$e,className:"px-2 py-1 text-xs bg-primary text-white rounded hover:bg-primary/80 disabled:opacity-50 flex items-center gap-1",title:`Fetch from ${te.remoteName}`,children:[r.jsx(Zt,{className:`w-3 h-3 ${$e?"animate-spin":""}`}),r.jsx("span",{children:$e?"Fetching...":"Fetch"})]})]})]}),r.jsx("button",{onClick:()=>{x(),S(),B()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${t?"p-1":"p-1.5"}`,children:r.jsx(Zt,{className:`${c?"animate-spin":""} ${t?"w-3 h-3":"w-4 h-4"}`})})]})]}),s?.error?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-gray-500 dark:text-gray-400 px-6 py-12",children:[r.jsx($s,{className:"w-20 h-20 mb-6 opacity-30"}),r.jsx("h3",{className:"text-xl font-medium mb-3 text-center",children:s.error}),s.details&&r.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:s.details}),r.jsx("div",{className:"p-4 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/60 max-w-md",children:r.jsxs("p",{className:"text-sm text-primary text-center",children:[r.jsx("strong",{children:"Tip:"})," Run ",r.jsx("code",{className:"bg-primary/15 dark:bg-primary/30 px-2 py-1 rounded font-mono text-xs",children:"git init"})," in your project directory to initialize git source control."]})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:`flex border-b border-gray-200 dark:border-gray-700 transition-all duration-300 ease-in-out ${m.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[r.jsx("button",{onClick:()=>ce("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${ue==="changes"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(Ho,{className:"w-4 h-4"}),r.jsx("span",{children:"Changes"})]})}),r.jsx("button",{onClick:()=>ce("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${ue==="history"?"text-primary border-b-2 border-primary dark:border-primary":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(Ma,{className:"w-4 h-4"}),r.jsx("span",{children:"History"})]})})]}),ue==="changes"&&r.jsx(r.Fragment,{children:r.jsx("div",{className:`transition-all duration-300 ease-in-out ${m.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:t&&He?r.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:r.jsxs("button",{onClick:()=>Xe(!1),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80",children:[r.jsx(Bs,{className:"w-4 h-4"}),r.jsxs("span",{children:["Commit ",h.size," file",h.size!==1?"s":""]}),r.jsx(jr,{className:"w-3 h-3"})]})}):r.jsx(r.Fragment,{children:r.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[t&&r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-sm font-medium",children:"Commit Changes"}),r.jsx("button",{onClick:()=>Xe(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:r.jsx(jr,{className:"w-4 h-4 rotate-180"})})]}),r.jsxs("div",{className:"relative",children:[r.jsx("textarea",{ref:Be,value:u,onChange:M=>p(M.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 resize-none pr-20",rows:"3",onKeyDown:M=>{M.key==="Enter"&&(M.ctrlKey||M.metaKey)&&oe()}}),r.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[r.jsx("button",{onClick:bt,disabled:h.size===0||fe,className:"p-1.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",title:"Generate commit message",children:fe?r.jsx(Zt,{className:"w-4 h-4 animate-spin"}):r.jsx(qo,{className:"w-4 h-4"})}),r.jsx("div",{style:{display:"none"},children:r.jsx(rb,{onTranscript:M=>p(M),mode:"default",className:"p-1.5"})})]})]}),r.jsxs("div",{className:"flex items-center justify-between mt-2",children:[r.jsxs("span",{className:"text-xs text-gray-500",children:[h.size," file",h.size!==1?"s":""," selected"]}),r.jsxs("button",{onClick:()=>De({type:"commit",message:`Commit ${h.size} file${h.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||h.size===0||b,className:"px-3 py-1 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",children:[r.jsx(ir,{className:"w-3 h-3"}),r.jsx("span",{children:b?"Committing...":"Commit"})]})]})]})})})}),ue==="changes"&&s&&!s.error&&r.jsxs("div",{className:`border-b border-gray-200 dark:border-gray-700 flex items-center justify-between transition-all duration-300 ease-in-out ${t?"px-3 py-1.5":"px-4 py-2"} ${m.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[r.jsxs("span",{className:"text-gray-600 dark:text-gray-400 text-xs",children:[h.size," of ",(s?.modified?.length||0)+(s?.added?.length||0)+(s?.deleted?.length||0)+(s?.untracked?.length||0)," ",t?"":"files"," selected"]}),r.jsxs("div",{className:`flex ${t?"gap-1":"gap-2"}`,children:[r.jsx("button",{onClick:()=>{const M=new Set([...s?.modified||[],...s?.added||[],...s?.deleted||[],...s?.untracked||[]]);g(M)},className:"text-primary hover:text-primary text-xs",children:t?"All":"Select All"}),r.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),r.jsx("button",{onClick:()=>g(new Set),className:"text-primary hover:text-primary text-xs",children:t?"None":"Deselect All"})]})]}),!s?.error&&!t&&r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("button",{onClick:()=>k(!I),className:"w-full px-4 py-2 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-750 text-xs text-gray-600 dark:text-gray-400 flex items-center justify-center gap-1",children:[r.jsx(om,{className:"w-3 h-3"}),r.jsx("span",{children:"File Status Guide"}),I?r.jsx(jr,{className:"w-3 h-3"}):r.jsx(qr,{className:"w-3 h-3"})]}),I&&r.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-800 text-xs",children:r.jsxs("div",{className:`${t?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 rounded border border-yellow-200 dark:border-yellow-800 font-bold text-xs",children:"M"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Modified"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 rounded border border-green-200 dark:border-green-800 font-bold text-xs",children:"A"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Added"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 rounded border border-red-200 dark:border-red-800 font-bold text-xs",children:"D"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Deleted"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 rounded border border-gray-300 dark:border-gray-600 font-bold text-xs",children:"U"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Untracked"})]})]})})]})]}),ue==="changes"&&!s?.error&&r.jsx("div",{className:`flex-1 overflow-y-auto ${t?"pb-mobile-nav":""}`,children:c?r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Zt,{className:"w-6 h-6 animate-spin text-gray-400"})}):s?.hasCommits===!1?r.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[r.jsx($s,{className:"w-16 h-16 mb-4 opacity-30 text-gray-400 dark:text-gray-500"}),r.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-900 dark:text-white",children:"No commits yet"}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6 max-w-md",children:"This repository doesn't have any commits yet. Create your first commit to start tracking changes."}),r.jsx("button",{onClick:Je,disabled:at,className:"px-4 py-2 bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:at?r.jsxs(r.Fragment,{children:[r.jsx(Zt,{className:"w-4 h-4 animate-spin"}),r.jsx("span",{children:"Creating Initial Commit..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(Bs,{className:"w-4 h-4"}),r.jsx("span",{children:"Create Initial Commit"})]})})]}):!s||!s.modified?.length&&!s.added?.length&&!s.deleted?.length&&!s.untracked?.length?r.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[r.jsx(Bs,{className:"w-12 h-12 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No changes detected"})]}):r.jsxs("div",{className:t?"pb-4":"",children:[s.modified?.map(M=>Pe(M,"M")),s.added?.map(M=>Pe(M,"A")),s.deleted?.map(M=>Pe(M,"D")),s.untracked?.map(M=>Pe(M,"U"))]})}),ue==="history"&&!s?.error&&r.jsx("div",{className:`flex-1 overflow-y-auto ${t?"pb-mobile-nav":""}`,children:c?r.jsx("div",{className:"flex items-center justify-center h-32",children:r.jsx(Zt,{className:"w-6 h-6 animate-spin text-gray-400"})}):J.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:[r.jsx(Ma,{className:"w-12 h-12 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No commits found"})]}):r.jsx("div",{className:t?"pb-4":"",children:J.map(M=>wt(M))})}),re&&r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>le(!1)}),r.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:r.jsxs("div",{className:"p-6",children:[r.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Create New Branch"}),r.jsxs("div",{className:"mb-4",children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Branch Name"}),r.jsx("input",{type:"text",value:K,onChange:M=>Z(M.target.value),onKeyDown:M=>{M.key==="Enter"&&!U&&Y()},placeholder:"feature/new-feature",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-ring",autoFocus:!0})]}),r.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-4",children:["This will create a new branch from the current branch (",j,")"]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>{le(!1),Z("")},className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),r.jsx("button",{onClick:Y,disabled:!K.trim()||U,className:"px-4 py-2 text-sm bg-primary text-white rounded-md hover:bg-primary/80 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:U?r.jsxs(r.Fragment,{children:[r.jsx(Zt,{className:"w-3 h-3 animate-spin"}),r.jsx("span",{children:"Creating..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(Gr,{className:"w-3 h-3"}),r.jsx("span",{children:"Create Branch"})]})})]})]})})]}),pe&&r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>De(null)}),r.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full",children:r.jsxs("div",{className:"p-6",children:[r.jsxs("div",{className:"flex items-center mb-4",children:[r.jsx("div",{className:`p-2 rounded-full mr-3 ${pe.type==="discard"||pe.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:r.jsx(go,{className:`w-5 h-5 ${pe.type==="discard"||pe.type==="delete"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`})}),r.jsx("h3",{className:"text-lg font-semibold",children:pe.type==="discard"?"Discard Changes":pe.type==="delete"?"Delete File":pe.type==="commit"?"Confirm Commit":pe.type==="pull"?"Confirm Pull":pe.type==="publish"?"Publish Branch":"Confirm Push"})]}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:pe.message}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>De(null),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),r.jsx("button",{onClick:lt,className:`px-4 py-2 text-sm text-white rounded-md ${pe.type==="discard"||pe.type==="delete"?"bg-red-600 hover:bg-red-700":pe.type==="commit"?"bg-primary hover:bg-primary/90":pe.type==="pull"?"bg-green-600 hover:bg-green-700":pe.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:pe.type==="discard"?r.jsxs(r.Fragment,{children:[r.jsx(er,{className:"w-4 h-4"}),r.jsx("span",{children:"Discard"})]}):pe.type==="delete"?r.jsxs(r.Fragment,{children:[r.jsx(er,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete"})]}):pe.type==="commit"?r.jsxs(r.Fragment,{children:[r.jsx(ir,{className:"w-4 h-4"}),r.jsx("span",{children:"Commit"})]}):pe.type==="pull"?r.jsxs(r.Fragment,{children:[r.jsx(uo,{className:"w-4 h-4"}),r.jsx("span",{children:"Pull"})]}):pe.type==="publish"?r.jsxs(r.Fragment,{children:[r.jsx(Dn,{className:"w-4 h-4"}),r.jsx("span",{children:"Publish"})]}):r.jsxs(r.Fragment,{children:[r.jsx(Dn,{className:"w-4 h-4"}),r.jsx("span",{children:"Push"})]})})]})]})})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center text-gray-500 dark:text-gray-400",children:r.jsx("p",{children:"Select a project to view source control"})})}class sb extends Ct.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,n){console.error("ErrorBoundary caught an error:",t,n),this.setState({error:t,errorInfo:n})}render(){return this.state.hasError?r.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:r.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[r.jsxs("div",{className:"flex items-center mb-4",children:[r.jsx("div",{className:"flex-shrink-0",children:r.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),r.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),r.jsxs("div",{className:"text-sm text-red-700",children:[r.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&r.jsxs("details",{className:"mt-4",children:[r.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),r.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),r.jsx("div",{className:"mt-4",children:r.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"Try Again"})})]})}):this.props.children}}const ob=l.forwardRef(({className:e,...t},n)=>r.jsx(Sc,{ref:n,className:yt("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...t}));ob.displayName=Sc.displayName;const ab=l.forwardRef(({className:e,...t},n)=>r.jsx(Nc,{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}));ab.displayName=Nc.displayName;const ib=l.forwardRef(({className:e,...t},n)=>r.jsx(Cc,{ref:n,className:yt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...t}));ib.displayName=Cc.displayName;function lb({selectedProject:e,selectedSession:t,activeTab:n,setActiveTab:s,ws:o,sendMessage:a,latestMessage:i,isMobile:c,isPWA:d,onMenuClick:u,isLoading:p,onInputFocusChange:m,onSessionActive:f,onSessionInactive:h,onSessionProcessing:g,onSessionNotProcessing:b,processingSessions:v,onReplaceTemporarySession:j,onNavigateToSession:O,onShowSettings:C,autoExpandTools:L,showRawParameters:_,showThinking:R,autoScrollToBottom:I,sendByCtrlEnter:k,externalMessageUpdate:q,urlContext:G,urlPrompt:re,integrationClientId:le,latestIntegrationMessage:K,sendIntegrationMessage:Z,onShowNewProject:U,onNewSession:de,newSessionResetNonce:ue}){const{t:ce}=Et(),[J,_e]=l.useState(null),[F,ee]=l.useState(600),[ne,xe]=l.useState(!1),[fe,be]=l.useState(!1),te=l.useRef(null),Se=(He,Xe=null)=>{const pe={name:He.split("/").pop(),path:He,projectName:e?.name,diffInfo:Xe};_e(pe)},$e=()=>{_e(null),be(!1)},he=()=>{be(!fe)},nt=He=>{c||(xe(!0),He.preventDefault())};if(l.useEffect(()=>{n==="files"&&s("chat")},[n,s]),l.useEffect(()=>{const He=pe=>{if(!ne)return;const De=te.current?.parentElement;if(!De)return;const at=De.getBoundingClientRect(),Ke=at.right-pe.clientX,Be=300,A=at.width*.8;Ke>=Be&&Ke<=A&&ee(Ke)},Xe=()=>{xe(!1)};return ne&&(document.addEventListener("mousemove",He),document.addEventListener("mouseup",Xe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",He),document.removeEventListener("mouseup",Xe),document.body.style.cursor="",document.body.style.userSelect=""}},[ne]),p)return r.jsxs("div",{className:"h-full flex flex-col",children:[c&&r.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:r.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:r.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),r.jsx("h2",{className:"text-xl font-semibold",children:ce("mainContent.loading")})]})})]});if(!e)return r.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[c&&r.jsx("div",{className:"bg-background/90 p-2 sm:p-3 pwa-header-safe flex-shrink-0 backdrop-blur",children:r.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),r.jsx("div",{className:"flex flex-1 items-center justify-center px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"w-full max-w-xl px-8 py-10 text-center text-muted-foreground",children:[r.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),r.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:ce("mainContent.chooseProject")}),r.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:ce("mainContent.selectProjectDescription")}),r.jsx("div",{className:"mx-auto flex w-fit items-center",children:r.jsxs("button",{onClick:U,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:ce("sidebar:projects.newProject"),children:[r.jsx(Ir,{className:"w-5 h-5"}),r.jsx("span",{children:ce("sidebar:projects.newProject")})]})})]})})]});const Le=t?.__provider||t?.provider||"claude",ke=Le==="openai"?"codex":Le,Ee=ke==="codex"&&typeof t?.id=="string"?t.id.trim():"",Fe=Ee?`codex://threads/${encodeURIComponent(Ee)}`:"",rt=()=>{Fe&&(window.location.href=Fe)};return r.jsxs("div",{className:"chat-shell h-full flex flex-col bg-background",children:[r.jsx("div",{className:"chat-header flex-shrink-0 px-3 py-3 sm:px-4 sm:py-3 pwa-header-safe",children:r.jsxs("div",{className:"relative flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 flex-1 items-center space-x-2",children:[c&&r.jsx("button",{onClick:u,onTouchStart:He=>{He.preventDefault(),u()},className:"pwa-menu-button flex-shrink-0 rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground touch-manipulation active:scale-95",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),r.jsxs("div",{className:"flex flex-1 items-center gap-3 overflow-x-auto scrollbar-hide min-w-0",children:[n==="chat"&&t&&r.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl bg-muted/60",children:ke==="codex"?r.jsx(kn,{className:"w-4 h-4"}):ke==="gemini"?r.jsx(jn,{className:"w-4 h-4"}):ke==="opencode"?r.jsx(Sn,{className:"h-4 w-auto max-w-full"}):r.jsx(rn,{className:"w-4 h-4"})}),r.jsx("div",{className:"min-w-0 flex-1",children:n==="chat"&&t?r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"overflow-x-auto whitespace-nowrap scrollbar-hide text-sm font-semibold text-gray-900 dark:text-white sm:text-base",children:ke==="codex"?t.summary||t.name||"Codex Session":ke==="gemini"?t.summary||t.name||"Gemini Session":ke==="opencode"?t.summary||t.name||"OpenCode Session":t.summary||"New Session"}),r.jsx("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:e.displayName})]}):n==="chat"&&!t?r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:ce("mainContent.newSession")}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):r.jsxs("div",{className:"min-w-0",children:[r.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:n==="git"?ce("tabs.git"):"Project"}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[n==="chat"&&ke==="codex"&&Fe&&!c&&r.jsx("button",{onClick:rt,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:ce("mainContent.openInCodexClient"),"aria-label":ce("mainContent.openInCodexClient"),children:r.jsx(po,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>de&&de(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:ce("tooltips.newChat","New Chat"),children:r.jsx(um,{className:"w-5 h-5"})})]})]})}),r.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[r.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${J?"mr-0":""} ${fe?"hidden":""}`,children:[r.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:r.jsx(sb,{showDetails:!0,children:r.jsx(ov,{selectedProject:e,selectedSession:t,ws:o,sendMessage:a,latestMessage:i,onFileOpen:Se,onInputFocusChange:m,onSessionActive:f,onSessionInactive:h,onSessionProcessing:g,onSessionNotProcessing:b,processingSessions:v,onReplaceTemporarySession:j,onNavigateToSession:O,onShowSettings:C,autoExpandTools:L,showRawParameters:_,showThinking:R,autoScrollToBottom:I,sendByCtrlEnter:k,externalMessageUpdate:q,urlContext:G,urlPrompt:re,integrationClientId:le,latestIntegrationMessage:K,sendIntegrationMessage:Z,newSessionResetNonce:ue},`${e?.name||"no-project"}:${t?.id||`new-${ue}`}`)})}),n==="shell"&&r.jsx("div",{className:"h-full w-full overflow-hidden",children:r.jsx(Ad,{project:e,session:t,showHeader:!1})}),n==="git"&&r.jsx("div",{className:"chat-surface h-full overflow-hidden",children:r.jsx(nb,{selectedProject:e,isMobile:c,onFileOpen:Se})}),r.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),J&&!c&&r.jsxs(r.Fragment,{children:[!fe&&r.jsx("div",{ref:te,onMouseDown:nt,className:"group relative w-1 flex-shrink-0 cursor-col-resize bg-border/70 transition-colors hover:bg-primary",title:"Drag to resize",children:r.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-primary dark:bg-primary opacity-0 group-hover:opacity-100 transition-opacity"})}),r.jsx("div",{className:`chat-surface h-full flex-shrink-0 overflow-hidden bg-muted/20 ${fe?"flex-1":""}`,style:fe?{}:{width:`${F}px`},children:r.jsx(Ji,{file:J,onClose:$e,projectPath:e?.path,isSidebar:!0,isExpanded:fe,onToggleExpand:he})})]})]}),J&&c&&r.jsx(Ji,{file:J,onClose:$e,projectPath:e?.path,isSidebar:!1})]})}const cb=Ct.memo(lb),_d="0.2.8",Id=()=>{const[e,t]=l.useState(!1),[n,s]=l.useState(null),[o,a]=l.useState(null);return l.useEffect(()=>{(async()=>{try{const c=await me("/api/system/version");if(!c.ok)throw new Error(`Version API failed: ${c.status}`);const d=await c.json();if(!d?.success)throw new Error(d?.error||"Version API returned unsuccessful result");if(d.latestVersion){const u=String(d.latestVersion).replace(/^v/,"");s(u),t(!!d.updateAvailable),a({title:d.releaseInfo?.title||`v${u}`,body:d.releaseInfo?.body||"",htmlUrl:d.releaseInfo?.htmlUrl||`https://www.npmjs.com/package/${d.packageName||"@axhub/genie"}`,publishedAt:d.releaseInfo?.publishedAt||null})}else t(!1),s(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),t(!1),s(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:_d,releaseInfo:o}};function db(){const{t:e}=Et("settings"),[t,n]=l.useState([]),[s,o]=l.useState(!0),[a,i]=l.useState(!1),[c,d]=l.useState(""),[u,p]=l.useState(null),[m,f]=l.useState(null),{updateAvailable:h,latestVersion:g,releaseInfo:b}=Id();l.useEffect(()=>{v()},[]);const v=async()=>{try{o(!0);const R=await(await me("/api/settings/api-keys")).json();n(R.apiKeys||[])}catch(_){console.error("Error fetching settings:",_)}finally{o(!1)}},j=async()=>{if(c.trim())try{const R=await(await me("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:c})})).json();R.success&&(f(R.apiKey),d(""),i(!1),v())}catch(_){console.error("Error creating API key:",_)}},O=async _=>{if(confirm(e("apiKeys.confirmDelete")))try{await me(`/api/settings/api-keys/${_}`,{method:"DELETE"}),v()}catch(R){console.error("Error deleting API key:",R)}},C=async(_,R)=>{try{await me(`/api/settings/api-keys/${_}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!R})}),v()}catch(I){console.error("Error toggling API key:",I)}},L=(_,R)=>{navigator.clipboard.writeText(_),p(R),setTimeout(()=>p(null),2e3)};return s?r.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):r.jsxs("div",{className:"space-y-8",children:[m&&r.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[r.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:m.apiKey}),r.jsx(Ge,{size:"sm",variant:"outline",onClick:()=>L(m.apiKey,"new"),children:u==="new"?r.jsx(ir,{className:"h-4 w-4"}):r.jsx(bp,{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(dl,{className:"h-5 w-5"}),r.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),r.jsxs(Ge,{size:"sm",onClick:()=>i(!a),children:[r.jsx(Gr,{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(po,{className:"h-3 w-3"})]})]}),a&&r.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[r.jsx(ar,{placeholder:e("apiKeys.form.placeholder"),value:c,onChange:_=>d(_.target.value),className:"mb-2"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ge,{onClick:j,children:e("apiKeys.form.createButton")}),r.jsx(Ge,{variant:"outline",onClick:()=>i(!1),children:e("apiKeys.form.cancelButton")})]})]}),r.jsx("div",{className:"space-y-2",children:t.length===0?r.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(_=>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:_.key_name}),r.jsx("code",{className:"text-xs text-muted-foreground",children:_.api_key}),r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(_.created_at).toLocaleDateString(),_.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(_.last_used).toLocaleDateString()}`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{size:"sm",variant:_.is_active?"outline":"secondary",onClick:()=>C(_.id,_.is_active),children:_.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),r.jsx(Ge,{size:"sm",variant:"ghost",onClick:()=>O(_.id),children:r.jsx(er,{className:"h-4 w-4"})})]})]},_.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:b?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",_d]}),h&&g&&r.jsxs("a",{href:b?.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:g})}),r.jsx(po,{className:"h-2.5 w-2.5"})]})]})})]})}function ub({isOpen:e,onClose:t,provider:n="claude",project:s,onComplete:o,customCommand:a,isAuthenticated:i=!1}){if(!e)return null;const c=()=>{if(a)return a;switch(n){case"claude":return i?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions";case"codex":return"codex login";case"gemini":return"npx -y @google/gemini-cli";case"opencode":return"npx -y opencode-ai@latest login";default:return i?"claude setup-token --dangerously-skip-permissions":"claude /exit --dangerously-skip-permissions"}},d=()=>{switch(n){case"claude":return"Claude CLI Login";case"codex":return"Codex CLI Login";case"gemini":return"Gemini CLI Login";case"opencode":return"OpenCode CLI Login";default:return"CLI Login"}},u=p=>{o?.(p),p===0&&t()};return r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),r.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:r.jsx(Ut,{className:"w-6 h-6"})})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Ad,{project:s,command:c(),onComplete:u,minimal:!0})})]})})}function Td({compact:e=!1}){const{i18n:t,t:n}=Et("settings"),s=o=>{const a=o.target.value;t.changeLanguage(a)};return e?r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(ul,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),r.jsx("select",{value:t.language,onChange:s,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 focus:outline-none focus:ring-2",children:Ia.map(o=>r.jsx("option",{value:o.value,children:o.nativeName},o.value))})]}):r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:n("account.languageLabel")}),r.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("account.languageDescription")})]}),r.jsx("select",{value:t.language,onChange:s,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-36",children:Ia.map(o=>r.jsx("option",{value:o.value,children:o.nativeName},o.value))})]})})}function pb({isOpen:e,onClose:t,projects:n=[],initialTab:s="appearance"}){const{isDarkMode:o,toggleDarkMode:a}=Uo(),{t:i}=Et("settings"),[c,d]=l.useState([]),[u,p]=l.useState([]),[m,f]=l.useState(""),[h,g]=l.useState(""),[b,v]=l.useState(!1),[j,O]=l.useState(!1),[C,L]=l.useState(null),[_,R]=l.useState("name"),[I,k]=l.useState([]),[q,G]=l.useState(!1),[re,le]=l.useState(null),[K,Z]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[U,de]=l.useState(!1),[ue,ce]=l.useState({}),[J,_e]=l.useState({}),[F,ee]=l.useState({}),[ne,xe]=l.useState(s),[fe,be]=l.useState(""),te=["appearance","api"],[Se,$e]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[he,nt]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Le,ke]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Ee,Fe]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[rt,He]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[Xe,pe]=l.useState([]),[De,at]=l.useState("default"),[Ke,Be]=l.useState(!1),[A,V]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[y,x]=l.useState(null),[S,B]=l.useState(!1),[D,Y]=l.useState(!1),[we,Ie]=l.useState(""),[Oe,dt]=l.useState(null),[Ne,Re]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[lt,gt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[It,pt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),Nt=async()=>{try{const T=await me("/api/codex/mcp/config/read");if(T.ok){const ae=await T.json();if(ae.success&&ae.servers){pe(ae.servers);return}}const P=await me("/api/codex/mcp/cli/list");if(P.ok){const ae=await P.json();if(ae.success&&ae.servers){const Ve=ae.servers.map(xt=>({id:xt.name,name:xt.name,type:xt.type||"stdio",scope:"user",config:{command:xt.command||"",args:xt.args||[],env:xt.env||{}}}));pe(Ve)}}}catch(T){console.error("Error fetching Codex MCP servers:",T)}},bt=async()=>{try{const T=await me("/api/mcp/config/read");if(T.ok){const Ve=await T.json();if(Ve.success&&Ve.servers){k(Ve.servers);return}}const P=await me("/api/mcp/cli/list");if(P.ok){const Ve=await P.json();if(Ve.success&&Ve.servers){const xt=Ve.servers.map(ot=>({id:ot.name,name:ot.name,type:ot.type,scope:"user",config:{command:ot.command||"",args:ot.args||[],env:ot.env||{},url:ot.url||"",headers:ot.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));k(xt);return}}const ae=await me("/api/mcp/servers?scope=user");if(ae.ok){const Ve=await ae.json();k(Ve.servers||[])}else console.error("Failed to fetch MCP servers")}catch(T){console.error("Error fetching MCP servers:",T)}},ye=async T=>{try{re&&await X(re.id,"user");const P=await me("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:T.name,type:T.type,scope:T.scope,projectPath:T.projectPath,command:T.config?.command,args:T.config?.args||[],url:T.config?.url,headers:T.config?.headers||{},env:T.config?.env||{}})});if(P.ok){const ae=await P.json();if(ae.success)return await bt(),!0;throw new Error(ae.error||"Failed to save server via Claude CLI")}else{const ae=await P.json();throw new Error(ae.error||"Failed to save server")}}catch(P){throw console.error("Error saving MCP server:",P),P}},X=async(T,P="user")=>{try{const ae=await me(`/api/mcp/cli/remove/${T}?scope=${P}`,{method:"DELETE"});if(ae.ok){const Ve=await ae.json();if(Ve.success)return await bt(),!0;throw new Error(Ve.error||"Failed to delete server via Claude CLI")}else{const Ve=await ae.json();throw new Error(Ve.error||"Failed to delete server")}}catch(ae){throw console.error("Error deleting MCP server:",ae),ae}},ie=async T=>{try{y&&await oe(y.id);const P=await me("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:T.name,command:T.config?.command,args:T.config?.args||[],env:T.config?.env||{}})});if(P.ok){const ae=await P.json();if(ae.success)return await Nt(),!0;throw new Error(ae.error||"Failed to save Codex MCP server")}else{const ae=await P.json();throw new Error(ae.error||"Failed to save server")}}catch(P){throw console.error("Error saving Codex MCP server:",P),P}},oe=async T=>{try{const P=await me(`/api/codex/mcp/cli/remove/${T}`,{method:"DELETE"});if(P.ok){const ae=await P.json();if(ae.success)return await Nt(),!0;throw new Error(ae.error||"Failed to delete Codex MCP server")}else{const ae=await P.json();throw new Error(ae.error||"Failed to delete server")}}catch(P){throw console.error("Error deleting Codex MCP server:",P),P}},Je=()=>{V({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),x(null),Be(!1)},ct=async T=>{T.preventDefault(),B(!0);try{y&&await oe(y.name),await ie(A),Je(),L("success")}catch(P){alert(`Error: ${P.message}`),L("error")}finally{B(!1)}};l.useEffect(()=>{e&&(wt(),Pe(),M(),W(),xe(te.includes(s)?s:"appearance"))},[e,s]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",Se),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Se]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",he.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[he]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Le.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Le]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Ee.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ee]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",rt),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[rt]);const wt=async()=>{try{const T=localStorage.getItem("claude-settings");if(T){const ae=JSON.parse(T);d(ae.allowedTools||[]),p(ae.disallowedTools||[]),v(ae.skipPermissions||!1),R(ae.projectSortOrder||"name")}else d([]),p([]),v(!1),R("name");const P=localStorage.getItem("codex-settings");if(P){const ae=JSON.parse(P);at(ae.permissionMode||"default")}else at("default");await bt(),await Nt()}catch(T){console.error("Error loading tool settings:",T),d([]),p([]),v(!1),R("name")}},Pe=async()=>{try{const T=await me("/api/cli/claude/status");if(T.ok){const P=await T.json();Re({authenticated:P.authenticated,email:P.email,loading:!1,error:P.error||null})}else Re({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(T){console.error("Error checking Claude auth status:",T),Re({authenticated:!1,email:null,loading:!1,error:T.message})}},M=async()=>{try{const T=await me("/api/cli/codex/status");if(T.ok){const P=await T.json();gt({authenticated:P.authenticated,email:P.email,loading:!1,error:P.error||null})}else gt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(T){console.error("Error checking Codex auth status:",T),gt({authenticated:!1,email:null,loading:!1,error:T.message})}},W=async()=>{try{const T=await me("/api/cli/gemini/status");if(T.ok){const P=await T.json();pt({authenticated:P.authenticated,email:P.email,loading:!1,error:P.error||null})}else pt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(T){console.error("Error checking Gemini auth status:",T),pt({authenticated:!1,email:null,loading:!1,error:T.message})}},Ce=T=>{T===0&&(L("success"),we==="claude"?Pe():we==="codex"?M():we==="gemini"&&W())},st=()=>{O(!0),L(null);try{const T={allowedTools:c,disallowedTools:u,skipPermissions:b,projectSortOrder:_,lastUpdated:new Date().toISOString()},P={permissionMode:De,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(T)),localStorage.setItem("codex-settings",JSON.stringify(P)),L("success"),setTimeout(()=>{t()},1e3)}catch(T){console.error("Error saving tool settings:",T),L("error")}finally{O(!1)}},kt=()=>{Z({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),le(null),G(!1),be("")},E=async T=>{T.preventDefault(),de(!0);try{if(K.importMode==="json"){const P=await me("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:K.name,jsonConfig:K.jsonInput,scope:K.scope,projectPath:K.projectPath})});if(P.ok){const ae=await P.json();if(ae.success)await bt(),kt(),L("success");else throw new Error(ae.error||"Failed to add server via JSON")}else{const ae=await P.json();throw new Error(ae.error||"Failed to add server")}}else await ye(K),kt(),L("success")}catch(P){alert(`Error: ${P.message}`),L("error")}finally{de(!1)}},je=(T,P)=>{Z(ae=>({...ae,config:{...ae.config,[T]:P}}))};return e?r.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[r.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Nm,{className:"w-5 h-5 md:w-6 md:h-6 text-primary"}),r.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:r.jsx(Ut,{className:"w-5 h-5"})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r.jsx("div",{className:"border-b border-border",children:r.jsxs("div",{className:"flex px-4 md:px-6",children:[r.jsx("button",{onClick:()=>xe("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ne==="appearance"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),r.jsxs("button",{onClick:()=>xe("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ne==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(dl,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]})]})}),r.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[ne==="appearance"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:ne==="appearance"&&r.jsxs("div",{className:"space-y-6 md:space-y-8",children:[r.jsx("div",{className:"space-y-4",children:r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),r.jsxs("button",{onClick:a,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":o,"aria-label":"Toggle dark mode",children:[r.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),r.jsx("span",{className:`${o?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:o?r.jsx(fo,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(ho,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),r.jsx("div",{className:"space-y-4",children:r.jsx(Td,{})}),r.jsx("div",{className:"space-y-4",children:r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),r.jsxs("select",{value:_,onChange:T=>R(T.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-32",children:[r.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),r.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),r.jsxs("button",{onClick:()=>$e(Se==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Se==="dark","aria-label":"Toggle editor theme",children:[r.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),r.jsx("span",{className:`${Se==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:Se==="dark"?r.jsx(fo,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(ho,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),r.jsxs("button",{onClick:()=>nt(!he),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":he,"aria-label":"Toggle word wrap",children:[r.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),r.jsx("span",{className:`${he?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),r.jsxs("button",{onClick:()=>ke(!Le),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Le,"aria-label":"Toggle minimap",children:[r.jsx("span",{className:"sr-only",children:"Toggle minimap"}),r.jsx("span",{className:`${Le?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),r.jsxs("button",{onClick:()=>Fe(!Ee),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ee,"aria-label":"Toggle line numbers",children:[r.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),r.jsx("span",{className:`${Ee?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),r.jsxs("select",{value:rt,onChange:T=>He(T.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-24",children:[r.jsx("option",{value:"10",children:"10px"}),r.jsx("option",{value:"11",children:"11px"}),r.jsx("option",{value:"12",children:"12px"}),r.jsx("option",{value:"13",children:"13px"}),r.jsx("option",{value:"14",children:"14px"}),r.jsx("option",{value:"15",children:"15px"}),r.jsx("option",{value:"16",children:"16px"}),r.jsx("option",{value:"18",children:"18px"}),r.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),q&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:r.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[r.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(re?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:kt,children:r.jsx(Ut,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:E,className:"p-4 space-y-4",children:[!re&&r.jsxs("div",{className:"flex gap-2 mb-4",children:[r.jsx("button",{type:"button",onClick:()=>Z(T=>({...T,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${K.importMode==="form"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),r.jsx("button",{type:"button",onClick:()=>Z(T=>({...T,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${K.importMode==="json"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),K.importMode==="form"&&re&&r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),r.jsxs("div",{className:"flex items-center gap-2",children:[K.scope==="user"?r.jsx(_a,{className:"w-4 h-4"}):r.jsx(Mr,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm",children:K.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),K.scope==="local"&&K.projectPath&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",K.projectPath]})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),K.importMode==="form"&&!re&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{type:"button",onClick:()=>Z(T=>({...T,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${K.scope==="user"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(_a,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),r.jsx("button",{type:"button",onClick:()=>Z(T=>({...T,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${K.scope==="local"?"bg-primary text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[r.jsx(Mr,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:K.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),K.scope==="local"&&!re&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),r.jsxs("select",{value:K.projectPath,onChange:T=>Z(P=>({...P,projectPath:T.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",required:K.scope==="local",children:[r.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),n.map(T=>r.jsx("option",{value:T.path||T.fullPath,children:T.displayName||T.name},T.name))]}),K.projectPath&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:K.projectPath})})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:K.importMode==="json"?"md:col-span-2":"",children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),r.jsx(ar,{value:K.name,onChange:T=>{Z(P=>({...P,name:T.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),K.importMode==="form"&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),r.jsxs("select",{value:K.type,onChange:T=>{Z(P=>({...P,type:T.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",children:[r.jsx("option",{value:"stdio",children:"stdio"}),r.jsx("option",{value:"sse",children:"SSE"}),r.jsx("option",{value:"http",children:"HTTP"})]})]})]}),re&&K.raw&&K.importMode==="form"&&r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:re.scope==="global"?"~/.claude.json":"project config"})}),r.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(K.raw,null,2)})]}),K.importMode==="json"&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),r.jsx("textarea",{value:K.jsonInput,onChange:T=>{Z(P=>({...P,jsonInput:T.target.value}));try{if(T.target.value.trim()){const P=JSON.parse(T.target.value);P.type?P.type==="stdio"&&!P.command?be(i("mcpForm.validation.stdioRequiresCommand")):(P.type==="http"||P.type==="sse")&&!P.url?be(i("mcpForm.validation.httpRequiresUrl",{type:P.type})):be(""):be(i("mcpForm.validation.missingType"))}}catch{T.target.value.trim()?be(i("mcpForm.validation.invalidJson")):be("")}},className:`w-full px-3 py-2 border ${fe?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary font-mono text-sm`,rows:"8",placeholder:`{
|
|
428
|
+
"type": "stdio",
|
|
429
|
+
"command": "/path/to/server",
|
|
430
|
+
"args": ["--api-key", "abc123"],
|
|
431
|
+
"env": {
|
|
432
|
+
"CACHE_DIR": "/tmp"
|
|
433
|
+
}
|
|
434
|
+
}`,required:!0}),fe&&r.jsx("p",{className:"text-xs text-red-500 mt-1",children:fe}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i("mcpForm.validation.jsonHelp"),r.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',r.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),K.importMode==="form"&&K.type==="stdio"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),r.jsx(ar,{value:K.config.command,onChange:T=>je("command",T.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),r.jsx("textarea",{value:Array.isArray(K.config.args)?K.config.args.join(`
|
|
435
|
+
`):"",onChange:T=>je("args",T.target.value.split(`
|
|
436
|
+
`).filter(P=>P.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`--api-key
|
|
437
|
+
abc123`})]})]}),K.importMode==="form"&&(K.type==="sse"||K.type==="http")&&r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.url")," *"]}),r.jsx(ar,{value:K.config.url,onChange:T=>je("url",T.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),K.importMode==="form"&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),r.jsx("textarea",{value:Object.entries(K.config.env||{}).map(([T,P])=>`${T}=${P}`).join(`
|
|
438
|
+
`),onChange:T=>{const P={};T.target.value.split(`
|
|
439
|
+
`).forEach(ae=>{const[Ve,...xt]=ae.split("=");Ve&&Ve.trim()&&(P[Ve.trim()]=xt.join("=").trim())}),je("env",P)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`API_KEY=your-key
|
|
440
|
+
DEBUG=true`})]}),K.importMode==="form"&&(K.type==="sse"||K.type==="http")&&r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.headers")}),r.jsx("textarea",{value:Object.entries(K.config.headers||{}).map(([T,P])=>`${T}=${P}`).join(`
|
|
441
|
+
`),onChange:T=>{const P={};T.target.value.split(`
|
|
442
|
+
`).forEach(ae=>{const[Ve,...xt]=ae.split("=");Ve&&Ve.trim()&&(P[Ve.trim()]=xt.join("=").trim())}),je("headers",P)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`Authorization=Bearer token
|
|
443
|
+
X-API-Key=your-key`})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(Ge,{type:"button",variant:"outline",onClick:kt,children:i("mcpForm.actions.cancel")}),r.jsx(Ge,{type:"submit",disabled:U,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(U?"mcpForm.actions.saving":re?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),Ke&&r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:r.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[r.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(y?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:Je,children:r.jsx(Ut,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:ct,className:"p-4 space-y-4",children:[r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),r.jsx(ar,{value:A.name,onChange:T=>V(P=>({...P,name:T.target.value})),placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),r.jsx(ar,{value:A.config?.command||"",onChange:T=>V(P=>({...P,config:{...P.config,command:T.target.value}})),placeholder:"npx @my-org/mcp-server",required:!0})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),r.jsx("textarea",{value:(A.config?.args||[]).join(`
|
|
444
|
+
`),onChange:T=>V(P=>({...P,config:{...P.config,args:T.target.value.split(`
|
|
445
|
+
`).filter(ae=>ae.trim())}})),placeholder:`--port
|
|
446
|
+
3000`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),r.jsx("textarea",{value:Object.entries(A.config?.env||{}).map(([T,P])=>`${T}=${P}`).join(`
|
|
447
|
+
`),onChange:T=>{const P={};T.target.value.split(`
|
|
448
|
+
`).forEach(ae=>{const[Ve,...xt]=ae.split("=");Ve&&xt.length>0&&(P[Ve.trim()]=xt.join("=").trim())}),V(ae=>({...ae,config:{...ae.config,env:P}}))},placeholder:`API_KEY=xxx
|
|
449
|
+
DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[r.jsx(Ge,{type:"button",variant:"outline",onClick:Je,children:i("mcpForm.actions.cancel")}),r.jsx(Ge,{type:"submit",disabled:S||!A.name||!A.config?.command,className:"bg-green-600 hover:bg-green-700 text-white",children:i(S?"mcpForm.actions.saving":y?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),ne==="api"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(db,{})})]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[r.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[C==="success"&&r.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),i("saveStatus.success")]}),C==="error"&&r.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),r.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[r.jsx(Ge,{variant:"outline",onClick:t,disabled:j,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),r.jsx(Ge,{onClick:st,disabled:j,className:"flex-1 sm:flex-none h-10 bg-primary hover:bg-primary/90 disabled:opacity-50 touch-manipulation",children:j?r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),i("saveStatus.saving")]}):i("footerActions.save")})]})]})]}),r.jsx(ub,{isOpen:D,onClose:()=>Y(!1),provider:we,project:Oe,onComplete:Ce,isAuthenticated:we==="claude"?Ne.authenticated:we==="codex"?lt.authenticated:!1},we)]}):null}const mb=({isOpen:e,onToggle:t,autoExpandTools:n,onAutoExpandChange:s,showRawParameters:o,onShowRawParametersChange:a,showThinking:i,onShowThinkingChange:c,autoScrollToBottom:d,onAutoScrollChange:u,sendByCtrlEnter:p,onSendByCtrlEnterChange:m,isMobile:f})=>{const{t:h}=Et("settings"),[g,b]=l.useState(e),[v,j]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:O}=Uo(),[C,L]=l.useState(()=>{const F=localStorage.getItem("quickSettingsHandlePosition");if(F)try{return JSON.parse(F).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[_,R]=l.useState(!1),[I,k]=l.useState(0),[q,G]=l.useState(0),[re,le]=l.useState(!1),K=l.useRef(null),Z=l.useRef({min:10,max:90}),U=5;l.useEffect(()=>{b(e)},[e]),l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:C}))},[C]);const de=l.useCallback(()=>f?{bottom:`${window.innerHeight*C/100}px`}:{top:`${C}%`,transform:"translateY(-50%)"},[C,f]),ue=l.useCallback(F=>{F.stopPropagation();const ee=F.type.includes("touch")?F.touches[0].clientY:F.clientY;k(ee),G(C),le(!1),R(!1)},[C]),ce=l.useCallback(F=>{if(I===0)return;const ee=F.type.includes("touch")?F.touches[0].clientY:F.clientY,ne=Math.abs(ee-I);if(!_&&ne>U&&(R(!0),le(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",F.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!_)return;F.type.includes("touch")&&F.preventDefault();const xe=ee-I;let fe;f?fe=-(xe/window.innerHeight)*100:fe=xe/window.innerHeight*100;let be=q+fe;be=Math.max(Z.current.min,Math.min(Z.current.max,be)),L(be)},[_,I,q,f,U]),J=l.useCallback(()=>{R(!1),k(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);l.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),l.useEffect(()=>{if(I!==0){const F=fe=>ce(fe),ee=()=>J(),ne=fe=>ce(fe),xe=()=>J();return document.addEventListener("mousemove",F),document.addEventListener("mouseup",ee),document.addEventListener("touchmove",ne,{passive:!1}),document.addEventListener("touchend",xe),()=>{document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",ee),document.removeEventListener("touchmove",ne),document.removeEventListener("touchend",xe)}}},[I,ce,J]);const _e=F=>{if(re){F.preventDefault(),le(!1);return}const ee=!g;b(ee),t(ee)};return r.jsxs(r.Fragment,{children:[r.jsx("button",{ref:K,onClick:_e,onMouseDown:F=>{ue(F)},onTouchStart:F=>{ue(F)},className:`fixed ${g?"right-64":"right-0"} z-50 ${_?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${_?"border-primary":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${_?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...de(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":h(_?"quickSettings.dragHandle.dragging":g?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:h(_?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:_?r.jsx(em,{className:"h-5 w-5 text-primary"}):g?r.jsx(qr,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):r.jsx(ll,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),r.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${g?"translate-x-0":"translate-x-full"} ${f?"h-screen":""}`,children:r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:r.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[r.jsx(Em,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),h("quickSettings.title")]})}),r.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${f?"pb-mobile-nav":""}`,children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:h("quickSettings.sections.appearance")}),r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[O?r.jsx(fo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):r.jsx(ho,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.darkMode")]}),r.jsx(wp,{})]}),r.jsx("div",{children:r.jsx(Td,{compact:!0})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:h("quickSettings.sections.toolDisplay")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(pl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.autoExpandTools")]}),r.jsx("input",{type:"checkbox",checked:n,onChange:F=>s(F.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(cl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.showRawParameters")]}),r.jsx("input",{type:"checkbox",checked:o,onChange:F=>a(F.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(il,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.showThinking")]}),r.jsx("input",{type:"checkbox",checked:i,onChange:F=>c(F.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:h("quickSettings.sections.viewOptions")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Ip,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.autoScrollToBottom")]}),r.jsx("input",{type:"checkbox",checked:d,onChange:F=>u(F.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:h("quickSettings.sections.inputSettings")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(ul,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.sendByCtrlEnter")]}),r.jsx("input",{type:"checkbox",checked:p,onChange:F=>m(F.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:h("quickSettings.sendByCtrlEnterDescription")})]}),r.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:h("quickSettings.sections.whisperDictation")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:v==="default",onChange:()=>{j("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(es,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.whisper.modes.default")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:h("quickSettings.whisper.modes.defaultDescription")})]})]}),r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:v==="prompt",onChange:()=>{j("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(qo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.whisper.modes.prompt")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:h("quickSettings.whisper.modes.promptDescription")})]})]}),r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:v==="vibe"||v==="instructions"||v==="architect",onChange:()=>{j("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-primary focus:ring-ring dark:bg-gray-800 checked:bg-primary"}),r.jsxs("div",{className:"ml-3 flex-1",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[r.jsx(Ho,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),h("quickSettings.whisper.modes.vibe")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:h("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),g&&r.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:_e})]})},Md=l.createContext({user:null,token:null,login:()=>{},register:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,error:null}),Es=()=>{const e=l.useContext(Md);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},fb=({children:e})=>{const[t,n]=l.useState(null),[s,o]=l.useState(localStorage.getItem("auth-token")),[a,i]=l.useState(!0),[c,d]=l.useState(!1),[u,p]=l.useState(null);l.useEffect(()=>{m()},[]);const m=async()=>{try{if(i(!0),p(null),(await(await it.auth.status()).json()).needsSetup){d(!0),i(!1);return}if(s)try{const O=await it.auth.user();if(O.ok){const C=await O.json();n(C.user),d(!1)}else localStorage.removeItem("auth-token"),o(null),n(null)}catch(O){console.error("Token verification failed:",O),localStorage.removeItem("auth-token"),o(null),n(null)}}catch(v){console.error("[AuthContext] Auth status check failed:",v),p("Failed to check authentication status")}finally{i(!1)}},b={user:t,token:s,login:async(v,j)=>{try{p(null);const O=await it.auth.login(v,j),C=await O.json();return O.ok?(o(C.token),n(C.user),localStorage.setItem("auth-token",C.token),{success:!0}):(p(C.error||"Login failed"),{success:!1,error:C.error||"Login failed"})}catch(O){console.error("Login error:",O);const C="Network error. Please try again.";return p(C),{success:!1,error:C}}},register:async(v,j)=>{try{p(null);const O=await it.auth.register(v,j),C=await O.json();return O.ok?(o(C.token),n(C.user),d(!1),localStorage.setItem("auth-token",C.token),{success:!0}):(p(C.error||"Registration failed"),{success:!1,error:C.error||"Registration failed"})}catch(O){console.error("Registration error:",O);const C="Network error. Please try again.";return p(C),{success:!1,error:C}}},logout:()=>{o(null),n(null),localStorage.removeItem("auth-token"),s&&it.auth.logout().catch(v=>{console.error("Logout endpoint error:",v)})},isLoading:a,needsSetup:c,error:u};return r.jsx(Md.Provider,{value:b,children:e})},Dd=l.createContext(null),hb=()=>{const e=l.useContext(Dd);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},gb=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},xb=()=>{const e=l.useRef(null),t=l.useRef(!1),[n,s]=l.useState(null),[o,a]=l.useState(!1),i=l.useRef(null),c=l.useRef(!1),d=l.useRef([]),u=l.useRef([]),p=l.useRef(null),m=l.useRef(0),{token:f}=Es(),h=l.useCallback(()=>{if(p.current||t.current)return;const R=()=>{if(p.current=null,t.current){u.current=[];return}const I=u.current.shift();I&&(m.current+=1,s({...I,__messageSeq:m.current}),u.current.length>0&&(p.current=setTimeout(R,0)))};p.current=setTimeout(R,0)},[]),g=l.useCallback(R=>{u.current.push(R),h()},[h]),b=l.useCallback((R,I)=>{g({type:"connection-error",error:I,provider:R?.provider||(typeof R?.type=="string"?R.type.replace(/-command$/,""):"claude"),sessionId:R?.sessionId||R?.options?.sessionId||null,clientRequestId:R?.clientRequestId||null})},[g]),v=l.useCallback(R=>{R.timeoutId&&(clearTimeout(R.timeoutId),R.timeoutId=null)},[]),j=l.useCallback(R=>{if(R.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach(k=>{v(k),R.send(JSON.stringify(k.payload))})},[v]),O=l.useCallback(R=>{if(!R||typeof R!="object"||R.clientRequestId)return R;const I=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...R,clientRequestId:I}},[]),C=l.useCallback(()=>{if(t.current||c.current)return;const R=e.current;if(!(R&&(R.readyState===WebSocket.OPEN||R.readyState===WebSocket.CONNECTING)))try{const I=gb(f);if(!I){d.current.splice(0,d.current.length).forEach(G=>{v(G),b(G.payload,"No authentication token found for WebSocket connection")});return}c.current=!0;const k=new WebSocket(I);e.current=k,k.onopen=()=>{c.current=!1,a(!0),e.current=k,g({type:"ws-connection-state",state:"connected"}),j(k)},k.onmessage=q=>{try{const G=JSON.parse(q.data);g(G)}catch(G){console.error("Error parsing WebSocket message:",G)}},k.onclose=()=>{c.current=!1,a(!1),e.current===k&&(e.current=null),g({type:"ws-connection-state",state:"disconnected"}),i.current=setTimeout(()=>{t.current||C()},3e3)},k.onerror=q=>{console.error("WebSocket error:",q)}}catch(I){c.current=!1,console.error("Error creating WebSocket connection:",I)}},[v,b,j,f]);l.useEffect(()=>(t.current=!1,C(),()=>{c.current=!1,i.current&&clearTimeout(i.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[C,f]),l.useEffect(()=>()=>{t.current=!0,c.current=!1,i.current&&clearTimeout(i.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(I=>v(I)),e.current&&(e.current.close(),e.current=null)},[v]);const L=l.useCallback(R=>{const I=O(R),k=e.current;if(k&&k.readyState===WebSocket.OPEN){try{k.send(JSON.stringify(I))}catch(G){throw G}return}g({type:"ws-connection-state",state:"connecting",sessionId:I?.sessionId||I?.options?.sessionId||null,clientRequestId:I?.clientRequestId||null});const q={payload:I,timeoutId:setTimeout(()=>{d.current=d.current.filter(G=>G!==q),b(I,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(q),C()},[C,b,g,O]);return l.useMemo(()=>({ws:e.current,sendMessage:L,latestMessage:n,isConnected:o}),[L,n,o])},yb=({children:e})=>{const t=xb();return r.jsx(Dd.Provider,{value:t,children:e})},vb=()=>{const{t:e}=Et("auth"),[t,n]=l.useState(""),[s,o]=l.useState(""),[a,i]=l.useState(""),[c,d]=l.useState(!1),[u,p]=l.useState(""),{register:m}=Es(),f=async h=>{if(h.preventDefault(),p(""),s!==a){p(e("register.errors.passwordMismatch"));return}if(t.length<3){p(e("register.errors.usernameTooShort"));return}if(s.length<6){p(e("register.errors.passwordTooShort"));return}d(!0);const g=await m(t,s);g.success||p(g.error),d(!1)};return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx("div",{className:"w-full max-w-md",children:r.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx(rn,{size:64})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e("register.welcomeTitle")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:e("register.description")})]}),r.jsxs("form",{onSubmit:f,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:e("register.username")}),r.jsx("input",{type:"text",id:"username",value:t,onChange:h=>n(h.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("register.placeholders.username"),required:!0,disabled:c})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:e("register.password")}),r.jsx("input",{type:"password",id:"password",value:s,onChange:h=>o(h.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("register.placeholders.password"),required:!0,disabled:c})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:e("register.confirmPassword")}),r.jsx("input",{type:"password",id:"confirmPassword",value:a,onChange:h=>i(h.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("register.placeholders.confirmPassword"),required:!0,disabled:c})]}),u&&r.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:r.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:u})}),r.jsx("button",{type:"submit",disabled:c,className:"w-full bg-primary hover:bg-primary/90 disabled:bg-primary/60 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:e(c?"register.loading":"register.submit")})]}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e("register.singleUserHint")})})]})})})},bb=()=>{const{t:e}=Et("auth"),[t,n]=l.useState(""),[s,o]=l.useState(""),[a,i]=l.useState(!1),[c,d]=l.useState(""),{login:u}=Es(),p=async m=>{if(m.preventDefault(),d(""),!t||!s){d(e("login.errors.requiredFields"));return}i(!0);const f=await u(t,s);f.success||d(f.error),i(!1)};return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx("div",{className:"w-full max-w-md",children:r.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("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",children:e("login.title")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:e("login.description")})]}),r.jsxs("form",{onSubmit:p,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:e("login.username")}),r.jsx("input",{type:"text",id:"username",value:t,onChange:m=>n(m.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.username"),required:!0,disabled:a})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:e("login.password")}),r.jsx("input",{type:"password",id:"password",value:s,onChange:m=>o(m.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.password"),required:!0,disabled:a})]}),c&&r.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:r.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),r.jsx("button",{type:"submit",disabled:a,className:"w-full bg-primary hover:bg-primary/90 disabled:bg-primary/60 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:e(a?"login.loading":"login.submit")})]}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e("login.footer")})})]})})})},wb=()=>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..."})]})}),kb=({children:e})=>{const{user:t,isLoading:n,needsSetup:s}=Es();return n?r.jsx(wb,{}):s?r.jsx(vb,{}):t?e:r.jsx(bb,{})};function Hr(e,t){const[n,s]=l.useState(()=>{if(typeof window>"u")return t;try{const a=window.localStorage.getItem(e);return a?JSON.parse(a):t}catch(a){return console.log(a),t}});return[n,a=>{if(!(typeof window>"u"))try{const i=a instanceof Function?a(n):a;window.localStorage.setItem(e,JSON.stringify(i)),s(i)}catch(i){console.log(i)}}]}const jb=3e3;function ln(e){return typeof e=="string"&&e.trim().length>0}function Sb(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function Nb(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function Cb({enabled:e,channel:t,clientId:n,sessionId:s}){const o=l.useRef(null),a=l.useRef(null),i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(0),u=l.useRef(ln(s)?s.trim():null),[p,m]=l.useState(null),[f,h]=l.useState(!1),g=l.useMemo(()=>e===!0&&ln(t)&&ln(n),[e,t,n]);l.useEffect(()=>{u.current=ln(s)?s.trim():null},[s]);const b=l.useCallback(_=>{d.current+=1,m({..._,__messageSeq:d.current})},[]),v=l.useCallback(()=>{const _=o.current;_&&(_.close(),o.current=null),h(!1),i.current=!1},[]),j=l.useCallback((_,R=o.current)=>!_||!R||R.readyState!==WebSocket.OPEN?!1:(R.send(JSON.stringify({type:"integration.ack",requestId:_,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),O=l.useCallback((_=o.current)=>{!g||!_||_.readyState!==WebSocket.OPEN||_.send(JSON.stringify({type:"integration.connect",requestId:Sb("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:n.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:ln(s)?s.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[t,n,g,s]),C=l.useCallback(()=>{if(!g||c.current||i.current)return;const _=o.current;if(_&&(_.readyState===WebSocket.OPEN||_.readyState===WebSocket.CONNECTING))return;const R=Nb();if(!R)return;i.current=!0;const I=new WebSocket(R);o.current=I,I.onopen=()=>{i.current=!1,o.current=I,h(!0),O(I)},I.onmessage=k=>{try{const q=JSON.parse(k.data);q&&typeof q.type=="string"&&q.type.startsWith("integration.")&&(q.type==="integration.ping"&&j(q.requestId||null,I),b(q))}catch(q){console.error("Error parsing integration WebSocket message:",q)}},I.onclose=()=>{o.current===I&&(o.current=null),i.current=!1,h(!1),!c.current&&g&&(a.current=setTimeout(()=>{a.current=null,C()},jb))},I.onerror=k=>{console.error("Integration WebSocket error:",k)}},[O,b,g,j]);l.useEffect(()=>{if(c.current=!1,!g){a.current&&(clearTimeout(a.current),a.current=null),v();return}return C(),()=>{a.current&&(clearTimeout(a.current),a.current=null),v()}},[v,C,g]),l.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),v()},[v]),l.useEffect(()=>{g&&O()},[O,g,s]);const L=l.useCallback(_=>{const R=o.current;return!R||R.readyState!==WebSocket.OPEN?!1:(R.send(JSON.stringify(_)),!0)},[]);return{integrationWs:o.current,latestIntegrationMessage:p,sendIntegrationMessage:L,isIntegrationConnected:f,isIntegrationEnabled:g}}function Fo(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 so(e,t){const n=Fo(t);return n?[e?.fullPath,e?.path].some(s=>Fo(s)===n):!1}function Qi(){const e=$u(),{sessionId:t}=Bu(),[n]=zu(),{t:s}=Et("common");l.useRef(0);const{updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c}=Id(),[d,u]=l.useState(!1),[p,m]=l.useState([]),[f,h]=l.useState(null),[g,b]=l.useState(null),[v,j]=l.useState(0),[O,C]=l.useState("chat"),[L,_]=l.useState(!1),R=L&&!1,[I,k]=l.useState(!1),[q,G]=l.useState(!0),[re,le]=l.useState(null),[K,Z]=l.useState(!1),[U,de]=l.useState(!1),[ue,ce]=l.useState("appearance"),[J,_e]=l.useState(!1),[F,ee]=Hr("autoExpandTools",!1),[ne,xe]=Hr("showRawParameters",!1),[fe,be]=Hr("showThinking",!0),[te,Se]=Hr("autoScrollToBottom",!0),[$e,he]=Hr("sendByCtrlEnter",!1),[nt,Le]=Hr("sidebarVisible",!0),[ke,Ee]=l.useState(!1),[Fe,rt]=l.useState(new Set),[He,Xe]=l.useState(new Set),pe=l.useRef({sessionId:null,status:"idle"}),De=l.useCallback((H,N="claude")=>{if(!H)return N;try{const se=localStorage.getItem("session-provider-map");if(!se)return N;const ge=JSON.parse(se)?.[H];return typeof ge=="string"&&ge?ge:N}catch{return N}},[]),[at,Ke]=l.useState(0),Be=l.useRef({selectionKey:null}),A=l.useRef({attemptedKeys:new Set}),V=l.useRef(p),y=n.get("cwd")||n.get("workdir"),x=l.useMemo(()=>Fo(y),[y]),S=n.get("project")||n.get("projectName"),B=n.get("provider")||n.get("tool")||n.get("cli");n.get("model");const D=n.get("context"),Y=n.get("prompt"),we=n.get("integrationWs"),Ie=n.get("integrationClientId"),Oe=n.get("integrationChannel"),dt=n.toString(),Re=p.find(H=>!!(so(H,x)||S&&(H.fullPath===S||H.path===S)))?.name||null,lt=l.useCallback((H,N)=>{const se=n.toString(),Te=se?`${H}?${se}`:H;e(Te,N)},[e,n]),{ws:gt,sendMessage:It,latestMessage:pt}=hb(),{latestIntegrationMessage:Nt,sendIntegrationMessage:bt}=Cb({enabled:we==="1",clientId:Ie,channel:Oe,sessionId:g?.id||t||null}),ye=l.useCallback(H=>typeof H!="string"?!1:/^new-session-\d+$/i.test(H)||/^codex-\d+$/i.test(H),[]),X=l.useRef(null),[ie,oe]=l.useState(!1);l.useEffect(()=>{O==="files"&&C("chat")},[O]),l.useEffect(()=>{const H=()=>{const N=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");oe(N),document.addEventListener("touchstart",{}),N?(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 H(),window.matchMedia("(display-mode: standalone)").addEventListener("change",H),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",H)}},[]),l.useEffect(()=>{const H=()=>{_(window.innerWidth<768)};return H(),window.addEventListener("resize",H),()=>window.removeEventListener("resize",H)},[]),l.useEffect(()=>{Pe()},[]),l.useEffect(()=>{V.current=p},[p]),l.useEffect(()=>{if(!x&&!S||p.length===0)return;const H=`${x||""}::${S||""}`;if(Be.current.selectionKey===H)return;if(g){Be.current.selectionKey=H;return}let N=null;if(x&&(N=p.find(se=>so(se,x))),!N&&S){const se=S.trim().toLowerCase();N=p.find(Te=>[Te.name,Te.displayName,Te.path,Te.fullPath].some(Qe=>typeof Qe=="string"&&Qe.toLowerCase()===se))}N&&h(N),Be.current.selectionKey=H},[x,S,p,g]),l.useEffect(()=>{if(!x||q||g||V.current.some(ge=>so(ge,x)))return;const N=`cwd:${x}`;if(A.current.attemptedKeys.has(N))return;A.current.attemptedKeys.add(N);let se=!1;return(async()=>{try{const ge=await it.createProject(x),Qe=await ge.json().catch(()=>({}));if(!ge.ok){const et=Qe?.error||"Unknown error";if(et.includes("Project already configured")){await Pe();return}console.warn(`[URL] Failed to auto-create project for cwd "${x}": ${et}`);return}if(se)return;Qe?.project&&h(Qe.project),await Pe()}catch(ge){console.error(`[URL] Error auto-creating project for cwd "${x}":`,ge)}})(),()=>{se=!0}},[x,q,g]);const Je=(H,N,se,Te)=>{if(!se||!Te)return!0;const ge=H?.find(Ze=>Ze.name===se.name),Qe=N?.find(Ze=>Ze.name===se.name);if(!ge||!Qe)return!1;const et=Ze=>[...Ze.sessions||[],...Ze.codexSessions||[],...Ze.geminiSessions||[],...Ze.opencodeSessions||[]].find(Pt=>Pt.id===Te.id),vt=et(ge),qe=et(Qe);return!vt||!qe?!1:vt.id===qe.id&&vt.title===qe.title&&vt.created_at===qe.created_at&&vt.updated_at===qe.updated_at},ct=(H,N)=>!H||!N?H!==N:H.name!==N.name||H.displayName!==N.displayName||H.fullPath!==N.fullPath||H.path!==N.path,wt=H=>{if(!H)return!1;if(t===H)return!0;const N=pe.current;return N?.sessionId===H&&N?.status!=="missing"&&N?.status!=="error"?!0:Fe.has(H)||He.has(H)};l.useEffect(()=>{if(pt){if(pt.type==="loading_progress"){X.current&&(clearTimeout(X.current),X.current=null),le(pt),pt.phase==="complete"&&(X.current=setTimeout(()=>{le(null),X.current=null},500));return}if(pt.type==="projects_updated"){if(pt.changedFile&&g&&f){const Te=pt.changedFile.replace(/\\/g,"/").split("/"),ge=Te[Te.length-1]||"",Qe=ge.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]||ge.replace(".jsonl","");(pt.changedSessionId||Qe)===g.id&&(Fe.has(g.id)||Ke(qe=>qe+1))}if(g&&Fe.has(g.id)||Fe.size>0&&Array.from(Fe).some(se=>se.startsWith("new-session-"))){const se=pt.projects;if(!Je(p,se,f,g))return}const N=pt.projects;if(m(N),f){const se=N.find(Te=>Te.name===f.name);if(se&&(ct(f,se)&&h(se),g)){const ge=[...se.sessions||[],...se.codexSessions||[],...se.geminiSessions||[],...se.opencodeSessions||[]].find(Qe=>Qe.id===g.id);if(!ge)wt(g.id)||b(null);else{const Qe={...ge,__provider:g.__provider||De(ge.id,"claude"),__projectName:g.__projectName||se.name};(Qe.title!==g.title||Qe.updated_at!==g.updated_at||Qe.__provider!==g.__provider||Qe.__projectName!==g.__projectName)&&b(Qe)}}}}}return()=>{X.current&&(clearTimeout(X.current),X.current=null)}},[Fe,pt,He,De,f,g,t]);const Pe=async(H={})=>{const{background:N=!1}=H;try{N||G(!0);const Te=await(await it.projects()).json();m(ge=>ge.length===0||Te.some((et,vt)=>{const qe=ge[vt];return qe?et.name!==qe.name||et.displayName!==qe.displayName||et.fullPath!==qe.fullPath||JSON.stringify(et.sessionMeta)!==JSON.stringify(qe.sessionMeta)||JSON.stringify(et.sessions)!==JSON.stringify(qe.sessions)||JSON.stringify(et.codexSessions)!==JSON.stringify(qe.codexSessions)||JSON.stringify(et.geminiSessions)!==JSON.stringify(qe.geminiSessions)||JSON.stringify(et.opencodeSessions)!==JSON.stringify(qe.opencodeSessions):!0})||Te.length!==ge.length?Te:ge)}catch(se){console.error("Error fetching projects:",se)}finally{N||G(!1)}};window.refreshProjects=(H={})=>Pe({background:!0,...H}),window.openSettings=l.useCallback((H="appearance")=>{ce(H),de(!0)},[]),l.useEffect(()=>{if(!t||p.length===0)return;const H=g?.id||null;f?.name;const N=H!==t,se=B||g?.__provider||localStorage.getItem("selected-provider")||"claude",Te=De(t,se),ge=`${t}::${dt}`,Qe=ye(t),et=(mt,Ze,Ae)=>{if(!mt||!Ze)return!1;const Pt=p.find(Tt=>Tt.name===mt.name)||mt,ur={...Ze,__provider:Ae||Te,__projectName:Pt.name};return h(Tt=>Tt?.name===Pt.name?Tt:Pt),b(Tt=>Tt?.id===ur.id&&Tt?.__provider===ur.__provider&&Tt?.__projectName===ur.__projectName?Tt:ur),N&&C("chat"),pe.current={sessionId:t,status:"resolved",resolutionKey:ge},!0};for(const mt of p){const Ze=[{items:mt.sessions,provider:De(t,se)},{items:mt.codexSessions,provider:"codex"},{items:mt.geminiSessions,provider:"gemini"},{items:mt.opencodeSessions,provider:"opencode"}];for(const Ae of Ze){const Pt=Ae.items?.find(Ht=>Ht.id===t);if(Pt){et(mt,Pt,Ae.provider);return}}}if(f&&(b({id:t,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:Te,__projectName:f.name}),N&&C("chat"),pe.current={sessionId:t,status:"placeholder",resolutionKey:ge}),Qe||pe.current.sessionId===t&&pe.current.status==="resolving"&&pe.current.resolutionKey===ge)return;pe.current={sessionId:t,status:"resolving",resolutionKey:ge};let vt=!1;return(async()=>{try{const mt=await it.resolveSession(t,Te),Ze=await mt.json().catch(()=>({}));if(vt)return;if(!mt.ok||!Ze?.found||!Ze?.project||!Ze?.session){pe.current={sessionId:t,status:"missing",resolutionKey:ge};return}if(Ze?.provider)try{const Tt=localStorage.getItem("session-provider-map"),qt=Tt?JSON.parse(Tt):{};qt[t]=Ze.provider,localStorage.setItem("session-provider-map",JSON.stringify(qt))}catch{}if(!et(Ze.project,Ze.session,Ze.provider||Te))return;const Pt=new URLSearchParams(dt);(Ze.project.fullPath||Ze.project.path)&&Pt.set("project",Ze.project.fullPath||Ze.project.path),Ze.provider&&Pt.set("provider",Ze.provider);const Ht=`/session/${t}${Pt.toString()?`?${Pt.toString()}`:""}`,ur=`${window.location.pathname}${window.location.search}`;Ht!==ur&&e(Ht,{replace:!0})}catch(mt){vt||(console.error("Error resolving session route:",mt),pe.current={sessionId:t,status:"error",resolutionKey:ge})}})(),()=>{vt=!0}},[ye,e,p,De,dt,f?.name,g?.id,t]);const M=H=>{h(H),b(null),lt("/"),L&&k(!1)},W=H=>{if(b(H),O!=="git"&&O!=="preview"&&C("chat"),L){const N=H.__projectName,se=f?.name;N!==se&&k(!1)}lt(`/session/${H.id}`)},Ce=H=>{if(H?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${H.name}`),localStorage.removeItem(`draft_input_${H.name}`)}catch(N){console.warn("Failed to clear local chat cache for new session:",N)}h(H),b(null),j(N=>N+1),C("chat"),lt("/"),L&&k(!1)},st=H=>{g?.id===H&&(b(null),lt("/")),m(N=>N.map(se=>({...se,sessions:se.sessions?.filter(Te=>Te.id!==H)||[],sessionMeta:{...se.sessionMeta,total:Math.max(0,(se.sessionMeta?.total||0)-1)}})))},kt=async()=>{try{const N=await(await it.projects()).json();if(m(se=>N.some((ge,Qe)=>{const et=se[Qe];return et?ge.name!==et.name||ge.displayName!==et.displayName||ge.fullPath!==et.fullPath||JSON.stringify(ge.sessionMeta)!==JSON.stringify(et.sessionMeta)||JSON.stringify(ge.sessions)!==JSON.stringify(et.sessions):!0})||N.length!==se.length?N:se),f){const se=N.find(Te=>Te.name===f.name);if(se&&(ct(f,se)&&h(se),g)){const ge=[...se.sessions||[],...se.codexSessions||[],...se.geminiSessions||[],...se.opencodeSessions||[]].find(Qe=>Qe.id===g.id);if(!ge)wt(g.id)||b(null);else{const Qe={...ge,__provider:g.__provider||De(ge.id,"claude"),__projectName:g.__projectName||se.name};(Qe.title!==g.title||Qe.updated_at!==g.updated_at||Qe.__provider!==g.__provider||Qe.__projectName!==g.__projectName)&&b(Qe)}}}}catch(H){console.error("Error refreshing sidebar:",H)}},E=H=>{f?.name===H&&(h(null),b(null),lt("/")),m(N=>N.filter(se=>se.name!==H))},je=l.useCallback((H,N)=>{m(se=>se.map(Te=>Te.name===H?{...Te,displayName:N,isCustomName:!0}:Te)),h(se=>!se||se.name!==H?se:{...se,displayName:N,isCustomName:!0})},[]),T=l.useCallback(H=>{H&&rt(N=>new Set([...N,H]))},[]),P=l.useCallback(H=>{H&&rt(N=>{const se=new Set(N);return se.delete(H),se})},[]),ae=l.useCallback(H=>{H&&Xe(N=>new Set([...N,H]))},[]),Ve=l.useCallback(H=>{H&&Xe(N=>{const se=new Set(N);return se.delete(H),se})},[]),xt=l.useCallback((H,N=null)=>{H&&(rt(se=>{const Te=new Set;for(const ge of se)N&&ge===N||ge.startsWith("new-session-")||Te.add(ge);return Te.add(H),Te}),Xe(se=>{const Te=new Set;for(const ge of se)N&&ge===N||ge.startsWith("new-session-")||Te.add(ge);return Te.add(H),Te}))},[]),ot=()=>{const{t:H}=Et("common"),[N,se]=l.useState(!1),[Te,ge]=l.useState(""),[Qe,et]=l.useState("");if(!d)return null;const vt=mt=>mt?mt.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,`
|
|
450
|
+
|
|
451
|
+
`).trim():"",qe=async()=>{se(!0),ge(`Starting update...
|
|
452
|
+
`),et("");try{const mt=await me("/api/system/update",{method:"POST"}),Ze=await mt.json();mt.ok?(ge(Ae=>Ae+Ze.output+`
|
|
453
|
+
`),ge(Ae=>Ae+`
|
|
454
|
+
✅ Update completed successfully!
|
|
455
|
+
`),ge(Ae=>Ae+`Please restart the server to apply changes.
|
|
456
|
+
`)):(et(Ze.error||"Update failed"),ge(Ae=>Ae+`
|
|
457
|
+
❌ Update failed: `+(Ze.error||"Unknown error")+`
|
|
458
|
+
`))}catch(mt){et(mt.message),ge(Ze=>Ze+`
|
|
459
|
+
❌ Update failed: `+mt.message+`
|
|
460
|
+
`)}finally{se(!1)}};return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[r.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>u(!1),"aria-label":H("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:H("versionUpdate.title")}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:c?.title||H("versionUpdate.newVersionReady")})]})]}),r.jsx("button",{onClick:()=>u(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:H("versionUpdate.currentVersion")}),r.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:i})]}),r.jsxs("div",{className:"flex justify-between items-center p-3 bg-primary/10 dark:bg-primary/20 rounded-lg border border-primary/30 dark:border-primary/50",children:[r.jsx("span",{className:"text-sm font-medium text-primary",children:H("versionUpdate.latestVersion")}),r.jsx("span",{className:"text-sm text-primary font-mono",children:a})]})]}),c?.body&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:H("versionUpdate.whatsNew")}),c?.htmlUrl&&r.jsxs("a",{href:c.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:text-primary hover:underline flex items-center gap-1",children:[H("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:vt(c.body)})})]}),Te&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:H("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:Te})})]}),!N&&!Te&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:H("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:H("versionUpdate.manualUpgradeHint")})]}),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.jsx("button",{onClick:()=>u(!1),className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:H(Te?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!Te&&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:H("versionUpdate.buttons.copyCommand")}),r.jsx("button",{onClick:qe,disabled:N,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:N?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),H("versionUpdate.buttons.updating")]}):H("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:[!L&&r.jsx("div",{className:`chat-sidebar h-full flex-shrink-0 overflow-hidden transition-all duration-300 ${nt?"w-[22rem]":"w-[4.25rem]"}`,children:r.jsx("div",{className:"h-full overflow-hidden",children:nt?r.jsx(Ka,{projects:p,selectedProject:f,selectedSession:g,onProjectSelect:M,onProjectRename:je,onSessionSelect:W,onNewSession:Ce,onSessionDelete:st,onProjectDelete:E,isLoading:q,loadingProgress:re,onRefresh:kt,onShowSettings:()=>de(!0),updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:ie,isMobile:L,onToggleSidebar:()=>Le(!1),lockedProjectName:Re,showNewProject:ke,setShowNewProject:Ee}):r.jsxs("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:[r.jsx("button",{onClick:()=>Le(!0),className:"flex h-10 w-10 items-center justify-center rounded-xl bg-background/80 text-foreground shadow-sm transition-colors duration-200 hover:bg-background","aria-label":s("versionUpdate.ariaLabels.showSidebar"),title:s("versionUpdate.ariaLabels.showSidebar"),children:r.jsx(qr,{className:"w-4 h-4 text-foreground"})}),o&&r.jsxs("button",{onClick:()=>u(!0),className:"relative rounded-xl bg-background/80 p-2 text-muted-foreground shadow-sm transition-colors duration-200 hover:bg-background hover:text-foreground","aria-label":s("versionUpdate.ariaLabels.updateAvailable"),title:s("versionUpdate.ariaLabels.updateAvailable"),children:[r.jsx(qo,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"absolute top-1 right-1 w-2 h-2 bg-primary rounded-full animate-pulse"})]})]})})}),L&&r.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${I?"opacity-100 visible":"opacity-0 invisible"}`,children:[r.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:H=>{H.stopPropagation(),k(!1)},onTouchStart:H=>{H.preventDefault(),H.stopPropagation(),k(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),r.jsx("div",{className:`chat-sidebar relative h-full w-[85vw] max-w-sm bg-white shadow-xl transform dark:bg-background sm:w-80 ${I?"translate-x-0":"-translate-x-full"}`,onClick:H=>H.stopPropagation(),onTouchStart:H=>H.stopPropagation(),children:r.jsx(Ka,{projects:p,selectedProject:f,selectedSession:g,onProjectSelect:M,onProjectRename:je,onSessionSelect:W,onNewSession:Ce,onSessionDelete:st,onProjectDelete:E,isLoading:q,loadingProgress:re,onRefresh:kt,onShowSettings:()=>de(!0),updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:ie,isMobile:L,onToggleSidebar:()=>Le(!1),lockedProjectName:Re,showNewProject:ke,setShowNewProject:Ee})})]}),r.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:r.jsx(cb,{selectedProject:f,selectedSession:g,activeTab:O,setActiveTab:C,ws:gt,sendMessage:It,latestMessage:pt,isMobile:L,isPWA:ie,onMenuClick:()=>k(!0),isLoading:q,onInputFocusChange:Z,onSessionActive:T,onSessionInactive:P,onSessionProcessing:ae,onSessionNotProcessing:Ve,processingSessions:He,onReplaceTemporarySession:xt,onNavigateToSession:H=>lt(`/session/${H}`),onShowSettings:()=>de(!0),autoExpandTools:F,showRawParameters:ne,showThinking:fe,autoScrollToBottom:te,sendByCtrlEnter:$e,externalMessageUpdate:at,urlContext:D,urlPrompt:Y,integrationClientId:Ie,latestIntegrationMessage:Nt,sendIntegrationMessage:bt,onShowNewProject:()=>Ee(!0),onNewSession:Ce,newSessionResetNonce:v})}),R,O==="chat"&&r.jsx(mb,{isOpen:J,onToggle:_e,autoExpandTools:F,onAutoExpandChange:ee,showRawParameters:ne,onShowRawParametersChange:xe,showThinking:fe,onShowThinkingChange:be,autoScrollToBottom:te,onAutoScrollChange:Se,sendByCtrlEnter:$e,onSendByCtrlEnterChange:he,isMobile:L}),r.jsx(pb,{isOpen:U,onClose:()=>de(!1),projects:p,initialTab:ue}),r.jsx(ot,{})]})}function Ob(){return r.jsx(kp,{i18n:Ap,children:r.jsx(jp,{children:r.jsx(fb,{children:r.jsx(yb,{children:r.jsx(kb,{children:r.jsx(Ou,{basename:window.__ROUTER_BASENAME__||"",children:r.jsxs(Fu,{children:[r.jsx(Ls,{path:"/",element:r.jsx(Qi,{})}),r.jsx(Ls,{path:"/session/:sessionId",element:r.jsx(Qi,{})}),r.jsx(Ls,{path:"/review",element:r.jsx(Sp,{})})]})})})})})})})}export{Ob as default};
|