@axhub/genie 0.2.5 → 0.2.7
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/assets/App-BWSqiXAT.js +220 -0
- package/dist/assets/App-DrlLKa8f.css +1 -0
- package/dist/assets/ReviewApp-nz3mbArg.js +1 -0
- package/dist/assets/{_basePickBy-CFRQvihx.js → _basePickBy-C19AekOu.js} +1 -1
- package/dist/assets/{_baseUniq-Dhh8nCvs.js → _baseUniq-JsnevLw_.js} +1 -1
- package/dist/assets/{arc-DQ0v3dU4.js → arc-BLpcuBlf.js} +1 -1
- package/dist/assets/architectureDiagram-2XIMDMQ5-CarjBOOv.js +36 -0
- package/dist/assets/{blockDiagram-WCTKOSBZ-Bbxhj5KC.js → blockDiagram-WCTKOSBZ-DQBLwsUS.js} +3 -3
- package/dist/assets/c4Diagram-IC4MRINW-CGobwBIj.js +10 -0
- package/dist/assets/channel-DkFNxV_H.js +1 -0
- package/dist/assets/{chunk-4BX2VUAB-DlvtrM0q.js → chunk-4BX2VUAB-De63kbgc.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-DJUSHyTa.js → chunk-55IACEB6-DtTDDdM9.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-C6Ch-htf.js → chunk-FMBD7UC4-DHuwd8tw.js} +1 -1
- package/dist/assets/{chunk-JSJVCQXG-DzQIht58.js → chunk-JSJVCQXG-BgytFtmO.js} +1 -1
- package/dist/assets/{chunk-KX2RTZJC-C05jARMH.js → chunk-KX2RTZJC-nZdp86aN.js} +1 -1
- package/dist/assets/chunk-NQ4KR5QH-CMH6EDP2.js +220 -0
- package/dist/assets/{chunk-QZHKN3VN-jxti9HTX.js → chunk-QZHKN3VN-DvUQ3mnO.js} +1 -1
- package/dist/assets/chunk-WL4C6EOR-Dn7db_6t.js +189 -0
- package/dist/assets/classDiagram-VBA2DB6C-DtwCEe8S.js +1 -0
- package/dist/assets/classDiagram-v2-RAHNMMFH-DtwCEe8S.js +1 -0
- package/dist/assets/clone-C0lCEIEO.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-DD_nzqsz.js +1 -0
- package/dist/assets/cytoscape.esm-5J0xJHOV.js +321 -0
- package/dist/assets/{dagre-KLK3FWXG-DJ3dNSYk.js → dagre-KLK3FWXG-CHYIvW47.js} +1 -1
- package/dist/assets/diagram-E7M64L7V-TVdvHtGc.js +24 -0
- package/dist/assets/{diagram-IFDJBPK2-Da6K4aP-.js → diagram-IFDJBPK2-Dzsiln_C.js} +1 -1
- package/dist/assets/{diagram-P4PSJMXO-vZZKB92A.js → diagram-P4PSJMXO-DKnGbUpE.js} +1 -1
- package/dist/assets/erDiagram-INFDFZHY-5Kw0bByo.js +70 -0
- package/dist/assets/{flowDiagram-PKNHOUZH-DUV13pHi.js → flowDiagram-PKNHOUZH-BAZ2-jKp.js} +4 -4
- package/dist/assets/ganttDiagram-A5KZAMGK-CsADFkcq.js +292 -0
- package/dist/assets/{gitGraphDiagram-K3NZZRJ6-BZ5gW69I.js → gitGraphDiagram-K3NZZRJ6-BflpyjGy.js} +1 -1
- package/dist/assets/{graph-BbvHswRd.js → graph-suelaXFh.js} +1 -1
- package/dist/assets/highlighted-body-OFNGDK62-CZrBMazC.js +1 -0
- package/dist/assets/index-B01NxbUv.css +1 -0
- package/dist/assets/index-DW5pGgQ_.js +2 -0
- package/dist/assets/{infoDiagram-LFFYTUFH-8auUIPKW.js → infoDiagram-LFFYTUFH-pfD1FA3p.js} +1 -1
- package/dist/assets/ishikawaDiagram-PHBUUO56-ndm9snwO.js +70 -0
- package/dist/assets/journeyDiagram-4ABVD52K-HgF2t7z5.js +139 -0
- package/dist/assets/{kanban-definition-K7BYSVSG-Bappd2YO.js → kanban-definition-K7BYSVSG-FWinmur1.js} +5 -5
- package/dist/assets/{layout-BmbfFZKy.js → layout-vcz43XvZ.js} +1 -1
- package/dist/assets/{linear-WZnF-PT6.js → linear-le4gc0vx.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-CK8m3lad.js +870 -0
- package/dist/assets/mindmap-definition-YRQLILUH-CNq9SKj4.js +68 -0
- package/dist/assets/{pieDiagram-SKSYHLDU-uxjlAy1t.js → pieDiagram-SKSYHLDU-C7PKDh3b.js} +2 -2
- package/dist/assets/quadrantDiagram-337W2JSQ-B7FnztNO.js +7 -0
- package/dist/assets/requirementDiagram-Z7DCOOCP-Bl_BM2Th.js +73 -0
- package/dist/assets/{sankeyDiagram-WA2Y5GQK-2-FHHM-R.js → sankeyDiagram-WA2Y5GQK-4gulcOP4.js} +3 -3
- package/dist/assets/sequenceDiagram-2WXFIKYE-VEuJDwyJ.js +145 -0
- package/dist/assets/{stateDiagram-RAJIS63D-DoW8U53H.js → stateDiagram-RAJIS63D-CB4Vl7qM.js} +1 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-C85ucl39.js +1 -0
- package/dist/assets/timeline-definition-YZTLITO2-BPGKhi7f.js +61 -0
- package/dist/assets/{treemap-KZPCXAKY-ajdAP-72.js → treemap-KZPCXAKY-DZSEE6Hz.js} +58 -58
- package/dist/assets/vendor-codemirror-CyOKkaQZ.js +31 -0
- package/dist/assets/vendor-react-CP4yFTs7.js +8 -0
- package/dist/assets/vendor-xterm-DfcmCpbH.js +66 -0
- package/dist/assets/{vennDiagram-LZ73GAT5-C9If0AT0.js → vennDiagram-LZ73GAT5-8E_G06fI.js} +4 -4
- package/dist/assets/xychartDiagram-JWTSCODW-CbBk50-O.js +7 -0
- package/dist/favicon.png +0 -0
- package/dist/icons/icon-128x128.png +0 -0
- package/dist/icons/icon-144x144.png +0 -0
- package/dist/icons/icon-152x152.png +0 -0
- package/dist/icons/icon-192x192.png +0 -0
- package/dist/icons/icon-384x384.png +0 -0
- package/dist/icons/icon-512x512.png +0 -0
- package/dist/icons/icon-72x72.png +0 -0
- package/dist/icons/icon-96x96.png +0 -0
- package/dist/index.html +4 -5
- package/dist/logo-128.png +0 -0
- package/dist/logo-256.png +0 -0
- package/dist/logo-32.png +0 -0
- package/dist/logo-512.png +0 -0
- package/dist/logo-64.png +0 -0
- package/package.json +2 -1
- package/server/_legacy-providers/README.md +30 -0
- package/server/_legacy-providers/claude-sdk.js +956 -0
- package/server/_legacy-providers/gemini-cli.js +368 -0
- package/server/_legacy-providers/openai-codex.js +705 -0
- package/server/_legacy-providers/opencode-cli.js +674 -0
- package/server/acp-runtime/client.js +1805 -0
- package/server/acp-runtime/client.test.js +688 -0
- package/server/acp-runtime/index.js +419 -0
- package/server/acp-runtime/registry.js +45 -0
- package/server/acp-runtime/session-store.js +254 -0
- package/server/acp-runtime/session-store.test.js +89 -0
- package/server/channels/runtime/AgentRuntimeAdapter.js +21 -70
- package/server/claude-sdk.js +24 -944
- package/server/cli.js +11 -5
- package/server/external-agent/service.js +77 -63
- package/server/gemini-cli.js +23 -360
- package/server/index.js +54 -46
- package/server/openai-codex.js +24 -698
- package/server/opencode-cli.js +70 -640
- package/server/routes/agent.js +2 -0
- package/server/routes/codex.js +5 -5
- package/server/routes/git.js +3 -20
- package/server/routes/mcp.js +18 -34
- package/server/routes/session-core.js +44 -10
- package/server/session-core/abortSession.js +2 -18
- package/server/session-core/eventStore.js +5 -1
- package/server/session-core/providerAdapters.js +98 -10
- package/server/session-core/providerDiscovery.js +2 -2
- package/server/session-core/runtimeState.js +16 -17
- package/server/session-core/runtimeWriter.js +19 -12
- package/server/utils/codexPath.js +3 -1
- package/server/utils/spawnCommand.js +7 -0
- package/shared/conversationEvents.js +347 -10
- package/shared/conversationEvents.test.js +403 -0
- package/dist/assets/App-BxazfNJn.js +0 -484
- package/dist/assets/App-qxJ8_QYu.css +0 -32
- package/dist/assets/ReviewApp-CsqTAlGU.js +0 -1
- package/dist/assets/architectureDiagram-2XIMDMQ5-DmUHdvQH.js +0 -36
- package/dist/assets/c4Diagram-IC4MRINW-BOivDlQU.js +0 -10
- package/dist/assets/channel-Cj8xVD0X.js +0 -1
- package/dist/assets/chunk-NQ4KR5QH-Ci-n7jfu.js +0 -220
- package/dist/assets/chunk-WL4C6EOR-C559Mk71.js +0 -189
- package/dist/assets/classDiagram-VBA2DB6C-CI2zklxw.js +0 -1
- package/dist/assets/classDiagram-v2-RAHNMMFH-CI2zklxw.js +0 -1
- package/dist/assets/clone-BEVqubrI.js +0 -1
- package/dist/assets/cose-bilkent-S5V4N54A-DNO9ncXL.js +0 -1
- package/dist/assets/cytoscape.esm-2ZfV8NB5.js +0 -331
- package/dist/assets/diagram-E7M64L7V-Ba_LGLun.js +0 -24
- package/dist/assets/erDiagram-INFDFZHY-Csb8dFdP.js +0 -70
- package/dist/assets/ganttDiagram-A5KZAMGK-B5Kv9Wfz.js +0 -292
- package/dist/assets/highlighted-body-TPN3WLV5-DZJajMGm.js +0 -1
- package/dist/assets/index-BFX9lxRB.css +0 -1
- package/dist/assets/index-BiErUGrv.js +0 -2
- package/dist/assets/ishikawaDiagram-PHBUUO56-JmsNlo2I.js +0 -70
- package/dist/assets/journeyDiagram-4ABVD52K-Cuudv7Vv.js +0 -139
- package/dist/assets/mermaid-O7DHMXV3-D-2fQRvw.js +0 -988
- package/dist/assets/mindmap-definition-YRQLILUH-BQHnzzud.js +0 -68
- package/dist/assets/quadrantDiagram-337W2JSQ-DpwZU-f_.js +0 -7
- package/dist/assets/requirementDiagram-Z7DCOOCP-C_9ClOWm.js +0 -73
- package/dist/assets/sequenceDiagram-2WXFIKYE-egns-0XI.js +0 -145
- package/dist/assets/stateDiagram-v2-FVOUBMTO-BoFZZ4Ds.js +0 -1
- package/dist/assets/timeline-definition-YZTLITO2-chPa8ppH.js +0 -61
- package/dist/assets/vendor-codemirror-Dz7_EqNA.js +0 -39
- package/dist/assets/vendor-react-Cpt6D04s.js +0 -59
- package/dist/assets/vendor-xterm-DfaPXD3y.js +0 -66
- package/dist/assets/xychartDiagram-JWTSCODW-DD42U6Or.js +0 -7
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
import{j as r,S as Kn,F as Js,T as wc,P as kc,E as ur,V as Ys,a as Ha,g as zp,D as Dr,R as Ls,G as qa,W as Va,l as jc,h as fa,b as Sc,C as Up,c as Wp,d as Hp,e as kn,f as qp,i as Vp,u as Gp,k as el,s as Kp,m as Jp,n as Yp,o as Xp,p as Qp,q as Zp,r as em,t as tm,v as rm,w as nm,x as sm,y as om}from"./vendor-codemirror-Dz7_EqNA.js";import{a as l,c as am,R as Tn,d as qo,g as Nc,B as im,e as lm,f as Vo,u as cm,h as dm,i as um}from"./vendor-react-Cpt6D04s.js";import{bJ as Te,bK as Xt,bL as ha,bM as on,bN as Cc,bO as Os,bP as Pe,bQ as Xs,bR as Ga,bS as xr,bT as Ec,bU as pm,bV as mm,bW as fm,bX as hm,bY as gm,bZ as xm,b_ as vm,b$ as ym,c0 as bm,c1 as wm,c2 as km,c3 as it,c4 as Ka,c5 as Mt,c6 as vr,c7 as jm,c8 as Re,c9 as Wn,ca as yn,cb as Ar,cc as an,cd as Ja,ce as Ic,cf as Sm,cg as Nm,ch as Cm,ci as Em,cj as Im,ck as tl,cl as rl,cm as nl,cn as Go,co as Am,cp as Tm,cq as _m,cr as Mm,cs as Dm,ct as Rm,cu as Pm,cv as Lm,cw as Om,cx as Fm,cy as Ac,cz as Ya,cA as $m,cB as Bm,I as zm,T as Um,U as Wm}from"./mermaid-O7DHMXV3-D-2fQRvw.js";import{r as Hm,a as qm,b as Vm}from"./vendor-xterm-DfaPXD3y.js";import{l as sl,i as Gm}from"./index-BiErUGrv.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 Km=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Jm=Te("arrow-down",Km);/**
|
|
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 Ym=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Tc=Te("chevron-left",Ym);/**
|
|
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 Xm=[["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"}]],ga=Te("download",Xm);/**
|
|
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 Qm=[["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"}]],xs=Te("ellipsis",Qm);/**
|
|
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 Zm=[["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"}]],xa=Te("external-link",Zm);/**
|
|
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 ef=[["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"}]],_c=Te("eye",ef);/**
|
|
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 tf=[["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"}]],rf=Te("eye-off",tf);/**
|
|
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 nf=[["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"}]],sf=Te("file-pen-line",nf);/**
|
|
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 of=[["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"}]],af=Te("file-plus-2",of);/**
|
|
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 lf=[["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"}]],cf=Te("file-search",lf);/**
|
|
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 df=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Xa=Te("file-text",df);/**
|
|
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 uf=[["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"}]],rn=Te("folder-open",uf);/**
|
|
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 pf=[["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"}]],tn=Te("folder-plus",pf);/**
|
|
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 mf=[["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"}]],Ko=Te("folder",mf);/**
|
|
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 ff=[["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"}]],Jo=Te("git-branch",ff);/**
|
|
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 hf=[["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"}]],Yo=Te("git-commit-horizontal",hf);/**
|
|
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 gf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ol=Te("globe",gf);/**
|
|
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 xf=[["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"}]],vf=Te("grip-vertical",xf);/**
|
|
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 yf=[["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"}]],al=Te("history",yf);/**
|
|
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 bf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],wf=Te("info",bf);/**
|
|
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 kf=[["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"}]],Mc=Te("key",kf);/**
|
|
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 jf=[["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"}]],Dc=Te("languages",jf);/**
|
|
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 Sf=[["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"}]],il=Te("list-todo",Sf);/**
|
|
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 Nf=[["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"}]],Rc=Te("maximize-2",Nf);/**
|
|
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 Cf=[["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"}]],Ef=Te("message-square-plus",Cf);/**
|
|
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 If=[["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"}]],Hn=Te("message-square",If);/**
|
|
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 Af=[["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"}]],Ps=Te("mic",Af);/**
|
|
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 Tf=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],_f=Te("minimize-2",Tf);/**
|
|
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 Mf=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],va=Te("moon",Mf);/**
|
|
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 Df=[["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"}]],ll=Te("pen-line",Df);/**
|
|
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 Rf=[["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"}]],cl=Te("pen",Rf);/**
|
|
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 Pf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],jn=Te("plus",Pf);/**
|
|
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 Lf=[["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"}]],Ir=Te("refresh-cw",Lf);/**
|
|
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 Of=[["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"}]],Ff=Te("save",Of);/**
|
|
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 $f=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],ya=Te("search",$f);/**
|
|
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 Bf=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],zf=Te("server",Bf);/**
|
|
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 Uf=[["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"}]],Pc=Te("settings",Uf);/**
|
|
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 Wf=[["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"}]],Hf=Te("settings-2",Wf);/**
|
|
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 qf=[["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"}]],Vf=Te("square-terminal",qf);/**
|
|
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 Gf=[["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"}]],dl=Te("star",Gf);/**
|
|
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 Kf=[["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"}]],ba=Te("sun",Kf);/**
|
|
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 Jf=[["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"}]],dr=Te("trash-2",Jf);/**
|
|
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 Yf=[["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"}]],wa=Te("triangle-alert",Yf);/**
|
|
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 Xf=[["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"}]],vs=Te("upload",Xf);/**
|
|
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 Qf=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],Zf=Te("wrench",Qf);/**
|
|
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 eh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],sr=Te("x",eh);function th(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var wr=e=>{const{present:t,children:n}=e,s=rh(t),o=typeof n=="function"?n({present:s.isPresent}):l.Children.only(n),a=Xt(s.ref,nh(o));return typeof n=="function"||s.isPresent?l.cloneElement(o,{ref:a}):null};wr.displayName="Presence";function rh(e){const[t,n]=l.useState(),s=l.useRef(null),o=l.useRef(e),a=l.useRef("none"),i=e?"mounted":"unmounted",[c,d]=th(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{const u=ys(s.current);a.current=c==="mounted"?u:"none"},[c]),ha(()=>{const u=s.current,p=o.current;if(p!==e){const h=a.current,g=ys(u);e?d("MOUNT"):g==="none"||u?.display==="none"?d("UNMOUNT"):d(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),ha(()=>{if(t){let u;const p=t.ownerDocument.defaultView??window,m=g=>{const S=ys(s.current).includes(CSS.escape(g.animationName));if(g.target===t&&S&&(d("ANIMATION_END"),!o.current)){const k=t.style.animationFillMode;t.style.animationFillMode="forwards",u=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=k)})}},h=g=>{g.target===t&&(a.current=ys(s.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{p.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:l.useCallback(u=>{s.current=u?getComputedStyle(u):null,n(u)},[])}}function ys(e){return e?.animationName||"none"}function nh(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function 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:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,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 Lc(e){const t=ah(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(lh);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 ah(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=dh(o),c=ch(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(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 ih=Symbol("radix.slottable");function lh(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ih}function ch(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 dh(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"],Jn=uh.reduce((e,t)=>{const n=Lc(`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 ph(e,t){e&&am.flushSync(()=>e.dispatchEvent(t))}function mh(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,fh(o,...t)]}function fh(...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 hh(e){const t=gh(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(vh);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 gh(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=bh(o),c=yh(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(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 xh=Symbol("radix.slottable");function vh(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===xh}function yh(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 bh(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 wh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Oc=wh.reduce((e,t)=>{const n=hh(`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}},{}),Xo="rovingFocusGroup.onEntryFocus",kh={bubbles:!1,cancelable:!0},Yn="RovingFocusGroup",[ka,Fc,jh]=Cc(Yn),[Sh,Qs]=mh(Yn,[jh]),[Nh,Ch]=Sh(Yn),$c=l.forwardRef((e,t)=>r.jsx(ka.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(ka.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Eh,{...e,ref:t})})}));$c.displayName=Yn;var Eh=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:p=!1,...m}=e,h=l.useRef(null),g=Xt(t,h),x=Xs(a),[S,k]=Ga({prop:i,defaultProp:c??null,onChange:d,caller:Yn}),[I,A]=l.useState(!1),w=xr(u),M=Fc(n),C=l.useRef(!1),[b,R]=l.useState(0);return l.useEffect(()=>{const B=h.current;if(B)return B.addEventListener(Xo,w),()=>B.removeEventListener(Xo,w)},[w]),r.jsx(Nh,{scope:n,orientation:s,dir:x,loop:o,currentTabStopId:S,onItemFocus:l.useCallback(B=>k(B),[k]),onItemShiftTab:l.useCallback(()=>A(!0),[]),onFocusableItemAdd:l.useCallback(()=>R(B=>B+1),[]),onFocusableItemRemove:l.useCallback(()=>R(B=>B-1),[]),children:r.jsx(Oc.div,{tabIndex:I||b===0?-1:0,"data-orientation":s,...m,ref:g,style:{outline:"none",...e.style},onMouseDown:Pe(e.onMouseDown,()=>{C.current=!0}),onFocus:Pe(e.onFocus,B=>{const D=!C.current;if(B.target===B.currentTarget&&D&&!I){const Z=new CustomEvent(Xo,kh);if(B.currentTarget.dispatchEvent(Z),!Z.defaultPrevented){const z=M().filter(Ce=>Ce.focusable),X=z.find(Ce=>Ce.active),q=z.find(Ce=>Ce.id===S),Se=[X,q,...z].filter(Boolean).map(Ce=>Ce.ref.current);Uc(Se,p)}}C.current=!1}),onBlur:Pe(e.onBlur,()=>A(!1))})})}),Bc="RovingFocusGroupItem",zc=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:i,...c}=e,d=Os(),u=a||d,p=Ch(Bc,n),m=p.currentTabStopId===u,h=Fc(n),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:S}=p;return l.useEffect(()=>{if(s)return g(),()=>x()},[s,g,x]),r.jsx(ka.ItemSlot,{scope:n,id:u,focusable:s,active:o,children:r.jsx(Oc.span,{tabIndex:m?0:-1,"data-orientation":p.orientation,...c,ref:t,onMouseDown:Pe(e.onMouseDown,k=>{s?p.onItemFocus(u):k.preventDefault()}),onFocus:Pe(e.onFocus,()=>p.onItemFocus(u)),onKeyDown:Pe(e.onKeyDown,k=>{if(k.key==="Tab"&&k.shiftKey){p.onItemShiftTab();return}if(k.target!==k.currentTarget)return;const I=Th(k,p.orientation,p.dir);if(I!==void 0){if(k.metaKey||k.ctrlKey||k.altKey||k.shiftKey)return;k.preventDefault();let w=h().filter(M=>M.focusable).map(M=>M.ref.current);if(I==="last")w.reverse();else if(I==="prev"||I==="next"){I==="prev"&&w.reverse();const M=w.indexOf(k.currentTarget);w=p.loop?_h(w,M+1):w.slice(M+1)}setTimeout(()=>Uc(w))}}),children:typeof i=="function"?i({isCurrentTabStop:m,hasTabStop:S!=null}):i})})});zc.displayName=Bc;var Ih={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ah(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Th(e,t,n){const s=Ah(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Ih[s]}function Uc(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function _h(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Wc=$c,Hc=zc,ja=["Enter"," "],Mh=["ArrowDown","PageUp","Home"],qc=["ArrowUp","PageDown","End"],Dh=[...Mh,...qc],Rh={ltr:[...ja,"ArrowRight"],rtl:[...ja,"ArrowLeft"]},Ph={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Xn="Menu",[qn,Lh,Oh]=Cc(Xn),[ln,Vc]=sh(Xn,[Oh,Ec,Qs]),Zs=Ec(),Gc=Qs(),[Fh,cn]=ln(Xn),[$h,Qn]=ln(Xn),Kc=e=>{const{__scopeMenu:t,open:n=!1,children:s,dir:o,onOpenChange:a,modal:i=!0}=e,c=Zs(t),[d,u]=l.useState(null),p=l.useRef(!1),m=xr(a),h=Xs(o);return l.useEffect(()=>{const g=()=>{p.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>p.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),r.jsx(pm,{...c,children:r.jsx(Fh,{scope:t,open:n,onOpenChange:m,content:d,onContentChange:u,children:r.jsx($h,{scope:t,onClose:l.useCallback(()=>m(!1),[m]),isUsingKeyboardRef:p,dir:h,modal:i,children:s})})})};Kc.displayName=Xn;var Bh="MenuAnchor",Qa=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=Zs(n);return r.jsx(mm,{...o,...s,ref:t})});Qa.displayName=Bh;var Za="MenuPortal",[zh,Jc]=ln(Za,{forceMount:void 0}),Yc=e=>{const{__scopeMenu:t,forceMount:n,children:s,container:o}=e,a=cn(Za,t);return r.jsx(zh,{scope:t,forceMount:n,children:r.jsx(wr,{present:n||a.open,children:r.jsx(fm,{asChild:!0,container:o,children:s})})})};Yc.displayName=Za;var or="MenuContent",[Uh,ei]=ln(or),Xc=l.forwardRef((e,t)=>{const n=Jc(or,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=cn(or,e.__scopeMenu),i=Qn(or,e.__scopeMenu);return r.jsx(qn.Provider,{scope:e.__scopeMenu,children:r.jsx(wr,{present:s||a.open,children:r.jsx(qn.Slot,{scope:e.__scopeMenu,children:i.modal?r.jsx(Wh,{...o,ref:t}):r.jsx(Hh,{...o,ref:t})})})})}),Wh=l.forwardRef((e,t)=>{const n=cn(or,e.__scopeMenu),s=l.useRef(null),o=Xt(t,s);return l.useEffect(()=>{const a=s.current;if(a)return hm(a)},[]),r.jsx(ti,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Hh=l.forwardRef((e,t)=>{const n=cn(or,e.__scopeMenu);return r.jsx(ti,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),qh=Lc("MenuContent.ScrollLock"),ti=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:s=!1,trapFocus:o,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:g,disableOutsideScroll:x,...S}=e,k=cn(or,n),I=Qn(or,n),A=Zs(n),w=Gc(n),M=Lh(n),[C,b]=l.useState(null),R=l.useRef(null),B=Xt(t,R,k.onContentChange),D=l.useRef(0),Z=l.useRef(""),z=l.useRef(0),X=l.useRef(null),q=l.useRef("right"),re=l.useRef(0),Se=x?xm:l.Fragment,Ce=x?{as:qh,allowPinchZoom:!0}:void 0,ge=H=>{const Le=Z.current+H,$=M().filter(P=>!P.disabled),N=document.activeElement,O=$.find(P=>P.ref.current===N)?.textValue,ne=$.map(P=>P.textValue),ke=ng(ne,Le,O),xe=$.find(P=>P.textValue===ke)?.ref.current;(function P(ae){Z.current=ae,window.clearTimeout(D.current),ae!==""&&(D.current=window.setTimeout(()=>P(""),1e3))})(Le),xe&&setTimeout(()=>xe.focus())};l.useEffect(()=>()=>window.clearTimeout(D.current),[]),gm();const de=l.useCallback(H=>q.current===X.current?.side&&og(H,X.current?.area),[]);return r.jsx(Uh,{scope:n,searchRef:Z,onItemEnter:l.useCallback(H=>{de(H)&&H.preventDefault()},[de]),onItemLeave:l.useCallback(H=>{de(H)||(R.current?.focus(),b(null))},[de]),onTriggerLeave:l.useCallback(H=>{de(H)&&H.preventDefault()},[de]),pointerGraceTimerRef:z,onPointerGraceIntentChange:l.useCallback(H=>{X.current=H},[]),children:r.jsx(Se,{...Ce,children:r.jsx(vm,{asChild:!0,trapped:o,onMountAutoFocus:Pe(a,H=>{H.preventDefault(),R.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:r.jsx(ym,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:m,onInteractOutside:h,onDismiss:g,children:r.jsx(Wc,{asChild:!0,...w,dir:I.dir,orientation:"vertical",loop:s,currentTabStopId:C,onCurrentTabStopIdChange:b,onEntryFocus:Pe(d,H=>{I.isUsingKeyboardRef.current||H.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(bm,{role:"menu","aria-orientation":"vertical","data-state":md(k.open),"data-radix-menu-content":"",dir:I.dir,...A,...S,ref:B,style:{outline:"none",...S.style},onKeyDown:Pe(S.onKeyDown,H=>{const $=H.target.closest("[data-radix-menu-content]")===H.currentTarget,N=H.ctrlKey||H.altKey||H.metaKey,O=H.key.length===1;$&&(H.key==="Tab"&&H.preventDefault(),!N&&O&&ge(H.key));const ne=R.current;if(H.target!==ne||!Dh.includes(H.key))return;H.preventDefault();const xe=M().filter(P=>!P.disabled).map(P=>P.ref.current);qc.includes(H.key)&&xe.reverse(),tg(xe)}),onBlur:Pe(e.onBlur,H=>{H.currentTarget.contains(H.target)||(window.clearTimeout(D.current),Z.current="")}),onPointerMove:Pe(e.onPointerMove,Vn(H=>{const Le=H.target,$=re.current!==H.clientX;if(H.currentTarget.contains(Le)&&$){const N=H.clientX>re.current?"right":"left";q.current=N,re.current=H.clientX}}))})})})})})})});Xc.displayName=or;var Vh="MenuGroup",ri=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Jn.div,{role:"group",...s,ref:t})});ri.displayName=Vh;var Gh="MenuLabel",Qc=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Jn.div,{...s,ref:t})});Qc.displayName=Gh;var Fs="MenuItem",ul="menu.itemSelect",eo=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:s,...o}=e,a=l.useRef(null),i=Qn(Fs,e.__scopeMenu),c=ei(Fs,e.__scopeMenu),d=Xt(t,a),u=l.useRef(!1),p=()=>{const m=a.current;if(!n&&m){const h=new CustomEvent(ul,{bubbles:!0,cancelable:!0});m.addEventListener(ul,g=>s?.(g),{once:!0}),ph(m,h),h.defaultPrevented?u.current=!1:i.onClose()}};return r.jsx(Zc,{...o,ref:d,disabled:n,onClick:Pe(e.onClick,p),onPointerDown:m=>{e.onPointerDown?.(m),u.current=!0},onPointerUp:Pe(e.onPointerUp,m=>{u.current||m.currentTarget?.click()}),onKeyDown:Pe(e.onKeyDown,m=>{const h=c.searchRef.current!=="";n||h&&m.key===" "||ja.includes(m.key)&&(m.currentTarget.click(),m.preventDefault())})})});eo.displayName=Fs;var Zc=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:s=!1,textValue:o,...a}=e,i=ei(Fs,n),c=Gc(n),d=l.useRef(null),u=Xt(t,d),[p,m]=l.useState(!1),[h,g]=l.useState("");return l.useEffect(()=>{const x=d.current;x&&g((x.textContent??"").trim())},[a.children]),r.jsx(qn.ItemSlot,{scope:n,disabled:s,textValue:o??h,children:r.jsx(Hc,{asChild:!0,...c,focusable:!s,children:r.jsx(Jn.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...a,ref:u,onPointerMove:Pe(e.onPointerMove,Vn(x=>{s?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Vn(x=>i.onItemLeave(x))),onFocus:Pe(e.onFocus,()=>m(!0)),onBlur:Pe(e.onBlur,()=>m(!1))})})})}),Kh="MenuCheckboxItem",ed=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:s,...o}=e;return r.jsx(od,{scope:e.__scopeMenu,checked:n,children:r.jsx(eo,{role:"menuitemcheckbox","aria-checked":$s(n)?"mixed":n,...o,ref:t,"data-state":si(n),onSelect:Pe(o.onSelect,()=>s?.($s(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ed.displayName=Kh;var td="MenuRadioGroup",[Jh,Yh]=ln(td,{value:void 0,onValueChange:()=>{}}),rd=l.forwardRef((e,t)=>{const{value:n,onValueChange:s,...o}=e,a=xr(s);return r.jsx(Jh,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(ri,{...o,ref:t})})});rd.displayName=td;var nd="MenuRadioItem",sd=l.forwardRef((e,t)=>{const{value:n,...s}=e,o=Yh(nd,e.__scopeMenu),a=n===o.value;return r.jsx(od,{scope:e.__scopeMenu,checked:a,children:r.jsx(eo,{role:"menuitemradio","aria-checked":a,...s,ref:t,"data-state":si(a),onSelect:Pe(s.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});sd.displayName=nd;var ni="MenuItemIndicator",[od,Xh]=ln(ni,{checked:!1}),ad=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:s,...o}=e,a=Xh(ni,n);return r.jsx(wr,{present:s||$s(a.checked)||a.checked===!0,children:r.jsx(Jn.span,{...o,ref:t,"data-state":si(a.checked)})})});ad.displayName=ni;var Qh="MenuSeparator",id=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e;return r.jsx(Jn.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});id.displayName=Qh;var Zh="MenuArrow",ld=l.forwardRef((e,t)=>{const{__scopeMenu:n,...s}=e,o=Zs(n);return r.jsx(wm,{...o,...s,ref:t})});ld.displayName=Zh;var eg="MenuSub",[uw,cd]=ln(eg),Fn="MenuSubTrigger",dd=l.forwardRef((e,t)=>{const n=cn(Fn,e.__scopeMenu),s=Qn(Fn,e.__scopeMenu),o=cd(Fn,e.__scopeMenu),a=ei(Fn,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(Qa,{asChild:!0,...u,children:r.jsx(Zc,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":md(n.open),...e,ref:on(t,o.onTriggerChange),onClick:m=>{e.onClick?.(m),!(e.disabled||m.defaultPrevented)&&(m.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Pe(e.onPointerMove,Vn(m=>{a.onItemEnter(m),!m.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:Pe(e.onPointerLeave,Vn(m=>{p();const h=n.content?.getBoundingClientRect();if(h){const g=n.content?.dataset.side,x=g==="right",S=x?-5:5,k=h[x?"left":"right"],I=h[x?"right":"left"];a.onPointerGraceIntentChange({area:[{x:m.clientX+S,y:m.clientY},{x:k,y:h.top},{x:I,y:h.top},{x:I,y:h.bottom},{x:k,y:h.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(m),m.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,m=>{const h=a.searchRef.current!=="";e.disabled||h&&m.key===" "||Rh[s.dir].includes(m.key)&&(n.onOpenChange(!0),n.content?.focus(),m.preventDefault())})})})});dd.displayName=Fn;var ud="MenuSubContent",pd=l.forwardRef((e,t)=>{const n=Jc(or,e.__scopeMenu),{forceMount:s=n.forceMount,...o}=e,a=cn(or,e.__scopeMenu),i=Qn(or,e.__scopeMenu),c=cd(ud,e.__scopeMenu),d=l.useRef(null),u=Xt(t,d);return r.jsx(qn.Provider,{scope:e.__scopeMenu,children:r.jsx(wr,{present:s||a.open,children:r.jsx(qn.Slot,{scope:e.__scopeMenu,children:r.jsx(ti,{id:c.contentId,"aria-labelledby":c.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{i.isUsingKeyboardRef.current&&d.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:Pe(e.onFocusOutside,p=>{p.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Pe(e.onEscapeKeyDown,p=>{i.onClose(),p.preventDefault()}),onKeyDown:Pe(e.onKeyDown,p=>{const m=p.currentTarget.contains(p.target),h=Ph[i.dir].includes(p.key);m&&h&&(a.onOpenChange(!1),c.trigger?.focus(),p.preventDefault())})})})})})});pd.displayName=ud;function md(e){return e?"open":"closed"}function $s(e){return e==="indeterminate"}function si(e){return $s(e)?"indeterminate":e?"checked":"unchecked"}function tg(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function rg(e,t){return e.map((n,s)=>e[(t+s)%e.length])}function ng(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=rg(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 sg(e,t){const{x:n,y:s}=e;let o=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],u=c.x,p=c.y,m=d.x,h=d.y;p>s!=h>s&&n<(m-u)*(s-p)/(h-p)+u&&(o=!o)}return o}function og(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return sg(n,t)}function Vn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var ag=Kc,ig=Qa,lg=Yc,cg=Xc,dg=ri,ug=Qc,pg=eo,mg=ed,fg=rd,hg=sd,gg=ad,xg=id,vg=ld,yg=dd,bg=pd;function wg(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,kg(o,...t)]}function kg(...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 jg(e){const t=Sg(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Cg);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 Sg(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Ig(o),c=Eg(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(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 Ng=Symbol("radix.slottable");function Cg(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ng}function Eg(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 Ig(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 Ag=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Tg=Ag.reduce((e,t)=>{const n=jg(`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}},{}),to="DropdownMenu",[_g,pw]=wg(to,[Vc]),Wt=Vc(),[Mg,fd]=_g(to),hd=e=>{const{__scopeDropdownMenu:t,children:n,dir:s,open:o,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,d=Wt(t),u=l.useRef(null),[p,m]=Ga({prop:o,defaultProp:a??!1,onChange:i,caller:to});return r.jsx(Mg,{scope:t,triggerId:Os(),triggerRef:u,contentId:Os(),open:p,onOpenChange:m,onOpenToggle:l.useCallback(()=>m(h=>!h),[m]),modal:c,children:r.jsx(ag,{...d,open:p,onOpenChange:m,dir:s,modal:c,children:n})})};hd.displayName=to;var gd="DropdownMenuTrigger",xd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:s=!1,...o}=e,a=fd(gd,n),i=Wt(n);return r.jsx(ig,{asChild:!0,...i,children:r.jsx(Tg.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:on(t,a.triggerRef),onPointerDown:Pe(e.onPointerDown,c=>{!s&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:Pe(e.onKeyDown,c=>{s||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});xd.displayName=gd;var Dg="DropdownMenuPortal",vd=e=>{const{__scopeDropdownMenu:t,...n}=e,s=Wt(t);return r.jsx(lg,{...s,...n})};vd.displayName=Dg;var yd="DropdownMenuContent",bd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=fd(yd,n),a=Wt(n),i=l.useRef(!1);return r.jsx(cg,{id:o.contentId,"aria-labelledby":o.triggerId,...a,...s,ref:t,onCloseAutoFocus:Pe(e.onCloseAutoFocus,c=>{i.current||o.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Pe(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,p=d.button===2||u;(!o.modal||p)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});bd.displayName=yd;var Rg="DropdownMenuGroup",Pg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(dg,{...o,...s,ref:t})});Pg.displayName=Rg;var Lg="DropdownMenuLabel",Og=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(ug,{...o,...s,ref:t})});Og.displayName=Lg;var Fg="DropdownMenuItem",wd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(pg,{...o,...s,ref:t})});wd.displayName=Fg;var $g="DropdownMenuCheckboxItem",Bg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(mg,{...o,...s,ref:t})});Bg.displayName=$g;var zg="DropdownMenuRadioGroup",Ug=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(fg,{...o,...s,ref:t})});Ug.displayName=zg;var Wg="DropdownMenuRadioItem",Hg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(hg,{...o,...s,ref:t})});Hg.displayName=Wg;var qg="DropdownMenuItemIndicator",Vg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(gg,{...o,...s,ref:t})});Vg.displayName=qg;var Gg="DropdownMenuSeparator",kd=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(xg,{...o,...s,ref:t})});kd.displayName=Gg;var Kg="DropdownMenuArrow",Jg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(vg,{...o,...s,ref:t})});Jg.displayName=Kg;var Yg="DropdownMenuSubTrigger",Xg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(yg,{...o,...s,ref:t})});Xg.displayName=Yg;var Qg="DropdownMenuSubContent",Zg=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...s}=e,o=Wt(n);return r.jsx(bg,{...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)"}})});Zg.displayName=Qg;var bs=hd,ws=xd,ks=vd,js=bd,hr=wd,pl=kd;function ex(e){const t=tx(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(nx);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 tx(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=ox(o),c=sx(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(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 rx=Symbol("radix.slottable");function nx(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rx}function sx(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 ox(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 ax=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Zn=ax.reduce((e,t)=>{const n=ex(`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 ix(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,lx(o,...t)]}function lx(...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 cx(e,t){return l.useReducer((n,s)=>t[n][s]??n,e)}var oi="ScrollArea",[jd,mw]=ix(oi),[dx,ir]=jd(oi),Sd=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:s="hover",dir:o,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[u,p]=l.useState(null),[m,h]=l.useState(null),[g,x]=l.useState(null),[S,k]=l.useState(null),[I,A]=l.useState(0),[w,M]=l.useState(0),[C,b]=l.useState(!1),[R,B]=l.useState(!1),D=Xt(t,z=>d(z)),Z=Xs(o);return r.jsx(dx,{scope:n,type:s,dir:Z,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:p,content:m,onContentChange:h,scrollbarX:g,onScrollbarXChange:x,scrollbarXEnabled:C,onScrollbarXEnabledChange:b,scrollbarY:S,onScrollbarYChange:k,scrollbarYEnabled:R,onScrollbarYEnabledChange:B,onCornerWidthChange:A,onCornerHeightChange:M,children:r.jsx(Zn.div,{dir:Z,...i,ref:D,style:{position:"relative","--radix-scroll-area-corner-width":I+"px","--radix-scroll-area-corner-height":w+"px",...e.style}})})});Sd.displayName=oi;var Nd="ScrollAreaViewport",Cd=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:s,nonce:o,...a}=e,i=ir(Nd,n),c=l.useRef(null),d=Xt(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(Zn.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})})]})});Cd.displayName=Nd;var kr="ScrollAreaScrollbar",Ed=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=ir(kr,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(ux,{...s,ref:t,forceMount:n}):o.type==="scroll"?r.jsx(px,{...s,ref:t,forceMount:n}):o.type==="auto"?r.jsx(Id,{...s,ref:t,forceMount:n}):o.type==="always"?r.jsx(ai,{...s,ref:t}):null});Ed.displayName=kr;var ux=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=ir(kr,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(wr,{present:n||a,children:r.jsx(Id,{"data-state":a?"visible":"hidden",...s,ref:t})})}),px=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=ir(kr,e.__scopeScrollArea),a=e.orientation==="horizontal",i=no(()=>d("SCROLL_END"),100),[c,d]=cx("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const u=window.setTimeout(()=>d("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,o.scrollHideDelay,d]),l.useEffect(()=>{const u=o.viewport,p=a?"scrollLeft":"scrollTop";if(u){let m=u[p];const h=()=>{const g=u[p];m!==g&&(d("SCROLL"),i()),m=g};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,a,d,i]),r.jsx(wr,{present:n||c!=="hidden",children:r.jsx(ai,{"data-state":c==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:Pe(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Pe(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Id=l.forwardRef((e,t)=>{const n=ir(kr,e.__scopeScrollArea),{forceMount:s,...o}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=no(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,p=n.viewport.offsetHeight<n.viewport.scrollHeight;i(c?u:p)}},10);return Sn(n.viewport,d),Sn(n.content,d),r.jsx(wr,{present:s||a,children:r.jsx(ai,{"data-state":a?"visible":"hidden",...o,ref:t})})}),ai=l.forwardRef((e,t)=>{const{orientation:n="vertical",...s}=e,o=ir(kr,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=Dd(c.viewport,c.content),p={...s,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function m(h,g){return vx(h,i.current,c,g)}return n==="horizontal"?r.jsx(mx,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollLeft,g=ml(h,c,o.dir);a.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=m(h,o.dir))}}):n==="vertical"?r.jsx(fx,{...p,ref:t,onThumbPositionChange:()=>{if(o.viewport&&a.current){const h=o.viewport.scrollTop,g=ml(h,c);a.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=m(h))}}):null}),mx=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=ir(kr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=Xt(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(Td,{"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":ro(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.x),onDragScroll:p=>e.onDragScroll(p.x),onWheelScroll:(p,m)=>{if(a.viewport){const h=a.viewport.scrollLeft+p.deltaX;e.onWheelScroll(h),Pd(h,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&s({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:zs(i.paddingLeft),paddingEnd:zs(i.paddingRight)}})}})}),fx=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:s,...o}=e,a=ir(kr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=Xt(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(Td,{"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":ro(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.y),onDragScroll:p=>e.onDragScroll(p.y),onWheelScroll:(p,m)=>{if(a.viewport){const h=a.viewport.scrollTop+p.deltaY;e.onWheelScroll(h),Pd(h,m)&&p.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&s({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:zs(i.paddingTop),paddingEnd:zs(i.paddingBottom)}})}})}),[hx,Ad]=jd(kr),Td=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:s,hasThumb:o,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:p,onResize:m,...h}=e,g=ir(kr,n),[x,S]=l.useState(null),k=Xt(t,D=>S(D)),I=l.useRef(null),A=l.useRef(""),w=g.viewport,M=s.content-s.viewport,C=xr(p),b=xr(d),R=no(m,10);function B(D){if(I.current){const Z=D.clientX-I.current.left,z=D.clientY-I.current.top;u({x:Z,y:z})}}return l.useEffect(()=>{const D=Z=>{const z=Z.target;x?.contains(z)&&C(Z,M)};return document.addEventListener("wheel",D,{passive:!1}),()=>document.removeEventListener("wheel",D,{passive:!1})},[w,x,M,C]),l.useEffect(b,[s,b]),Sn(x,R),Sn(g.content,R),r.jsx(hx,{scope:n,scrollbar:x,hasThumb:o,onThumbChange:xr(a),onThumbPointerUp:xr(i),onThumbPositionChange:b,onThumbPointerDown:xr(c),children:r.jsx(Zn.div,{...h,ref:k,style:{position:"absolute",...h.style},onPointerDown:Pe(e.onPointerDown,D=>{D.button===0&&(D.target.setPointerCapture(D.pointerId),I.current=x.getBoundingClientRect(),A.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),B(D))}),onPointerMove:Pe(e.onPointerMove,B),onPointerUp:Pe(e.onPointerUp,D=>{const Z=D.target;Z.hasPointerCapture(D.pointerId)&&Z.releasePointerCapture(D.pointerId),document.body.style.webkitUserSelect=A.current,g.viewport&&(g.viewport.style.scrollBehavior=""),I.current=null})})})}),Bs="ScrollAreaThumb",_d=l.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Ad(Bs,e.__scopeScrollArea);return r.jsx(wr,{present:n||o.hasThumb,children:r.jsx(gx,{ref:t,...s})})}),gx=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:s,...o}=e,a=ir(Bs,n),i=Ad(Bs,n),{onThumbPositionChange:c}=i,d=Xt(t,m=>i.onThumbChange(m)),u=l.useRef(void 0),p=no(()=>{u.current&&(u.current(),u.current=void 0)},100);return l.useEffect(()=>{const m=a.viewport;if(m){const h=()=>{if(p(),!u.current){const g=yx(m,c);u.current=g,c()}};return c(),m.addEventListener("scroll",h),()=>m.removeEventListener("scroll",h)}},[a.viewport,p,c]),r.jsx(Zn.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:Pe(e.onPointerDownCapture,m=>{const g=m.target.getBoundingClientRect(),x=m.clientX-g.left,S=m.clientY-g.top;i.onThumbPointerDown({x,y:S})}),onPointerUp:Pe(e.onPointerUp,i.onThumbPointerUp)})});_d.displayName=Bs;var ii="ScrollAreaCorner",Md=l.forwardRef((e,t)=>{const n=ir(ii,e.__scopeScrollArea),s=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&s?r.jsx(xx,{...e,ref:t}):null});Md.displayName=ii;var xx=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...s}=e,o=ir(ii,n),[a,i]=l.useState(0),[c,d]=l.useState(0),u=!!(a&&c);return Sn(o.scrollbarX,()=>{const p=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(p),d(p)}),Sn(o.scrollbarY,()=>{const p=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(p),i(p)}),u?r.jsx(Zn.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 zs(e){return e?parseInt(e,10):0}function Dd(e,t){const n=e/t;return isNaN(n)?0:n}function ro(e){const t=Dd(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-n)*t;return Math.max(s,18)}function vx(e,t,n,s="ltr"){const o=ro(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 Rd([d,u],m)(e)}function ml(e,t,n="ltr"){const s=ro(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=km(e,d);return Rd([0,i],[0,c])(u)}function Rd(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 Pd(e,t){return e>0&&e<t}var yx=(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 no(e,t){const n=xr(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 Sn(e,t){const n=xr(t);ha(()=>{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 Ld=Sd,bx=Cd,Od=Ed,wx=_d,kx=Md;function jx(e,t=[]){let n=[];function s(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=m=>{const{scope:h,children:g,...x}=m,S=h?.[e]?.[d]||c,k=l.useMemo(()=>x,Object.values(x));return r.jsx(S.Provider,{value:k,children:g})};u.displayName=a+"Provider";function p(m,h){const g=h?.[e]?.[d]||c,x=l.useContext(g);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[u,p]}const o=()=>{const a=n.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return o.scopeName=e,[s,Sx(o,...t)]}function Sx(...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 Nx(e){const t=Cx(e),n=l.forwardRef((s,o)=>{const{children:a,...i}=s,c=l.Children.toArray(a),d=c.find(Ix);if(d){const u=d.props.children,p=c.map(m=>m===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:m);return r.jsx(t,{...i,ref:o,children:l.isValidElement(u)?l.cloneElement(u,void 0,p):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Cx(e){const t=l.forwardRef((n,s)=>{const{children:o,...a}=n;if(l.isValidElement(o)){const i=Tx(o),c=Ax(a,o.props);return o.type!==l.Fragment&&(c.ref=s?on(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 Ex=Symbol("radix.slottable");function Ix(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ex}function Ax(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 Tx(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var _x=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],so=_x.reduce((e,t)=>{const n=Nx(`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}},{}),oo="Tabs",[Mx,fw]=jx(oo,[Qs]),Fd=Qs(),[Dx,li]=Mx(oo),$d=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...u}=e,p=Xs(c),[m,h]=Ga({prop:s,onChange:o,defaultProp:a??"",caller:oo});return r.jsx(Dx,{scope:n,baseId:Os(),value:m,onValueChange:h,orientation:i,dir:p,activationMode:d,children:r.jsx(so.div,{dir:p,"data-orientation":i,...u,ref:t})})});$d.displayName=oo;var Bd="TabsList",zd=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=li(Bd,n),i=Fd(n);return r.jsx(Wc,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(so.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});zd.displayName=Bd;var Ud="TabsTrigger",Wd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,i=li(Ud,n),c=Fd(n),d=Vd(i.baseId,s),u=Gd(i.baseId,s),p=s===i.value;return r.jsx(Hc,{asChild:!0,...c,focusable:!o,active:p,children:r.jsx(so.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":u,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:d,...a,ref:t,onMouseDown:Pe(e.onMouseDown,m=>{!o&&m.button===0&&m.ctrlKey===!1?i.onValueChange(s):m.preventDefault()}),onKeyDown:Pe(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&i.onValueChange(s)}),onFocus:Pe(e.onFocus,()=>{const m=i.activationMode!=="manual";!p&&!o&&m&&i.onValueChange(s)})})})});Wd.displayName=Ud;var Hd="TabsContent",qd=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...i}=e,c=li(Hd,n),d=Vd(c.baseId,s),u=Gd(c.baseId,s),p=s===c.value,m=l.useRef(p);return l.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),r.jsx(wr,{present:o||p,children:({present:h})=>r.jsx(so.div,{"data-state":p?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:h&&a})})});qd.displayName=Hd;function Vd(e,t){return`${e}-trigger-${t}`}function Gd(e,t){return`${e}-content-${t}`}var Rx=$d,Kd=zd,Jd=Wd,Yd=qd;const Xd=l.forwardRef(({className:e,orientation:t="vertical",...n},s)=>r.jsx(Od,{ref:s,orientation:t,className:it("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(wx,{className:"relative flex-1 rounded-full bg-border/80"})}));Xd.displayName=Od.displayName;const Qd=l.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ld,{ref:s,className:it("relative overflow-hidden",e),...n,children:[r.jsx(bx,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsx(Xd,{}),r.jsx(kx,{})]}));Qd.displayName=Ld.displayName;const Pt=l.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:it("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}));Pt.displayName="Input";const es=({className:e="w-5 h-5"})=>r.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),ao=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ka();return r.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},io=({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"})]})]})]})},lo=({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"})]}),Px=!1,le=(e,t={})=>{const n=localStorage.getItem("auth-token"),s={};return t.body instanceof FormData||(s["Content-Type"]="application/json"),n&&(s.Authorization=`Bearer ${n}`),fetch(e,{...t,headers:{...s,...t.headers}})},mt={auth:{status:()=>fetch("/api/auth/status"),login:(e,t)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),register:(e,t)=>fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})}),user:()=>le("/api/auth/user"),logout:()=>le("/api/auth/logout",{method:"POST"})},projects:()=>le("/api/projects"),sessions:(e,t=5,n=0)=>le(`/api/projects/${e}/sessions?limit=${t}&offset=${n}`),historyIndex:e=>le(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("projectPath",t),le(`/api/session-core/providers/${e}${n.toString()?`?${n.toString()}`:""}`)},providersDiscovery:(e=null)=>{const t=new URLSearchParams;return e&&t.append("projectPath",e),le(`/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)),le(`/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)),le(`/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),le(`/api/session-core/sessions/${e}/resolve${n.toString()?`?${n.toString()}`:""}`)},renameProject:(e,t)=>le(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:t})}),deleteSession:(e,t)=>le(`/api/projects/${e}/sessions/${t}`,{method:"DELETE"}),deleteCodexSession:e=>le(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteOpencodeSession:e=>le(`/api/opencode/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,t=!1)=>le(`/api/projects/${e}${t?"?force=true":""}`,{method:"DELETE"}),createProject:e=>le("/api/projects/create",{method:"POST",body:JSON.stringify({path:e})}),createWorkspace:e=>le("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),readFile:(e,t)=>le(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),saveFile:(e,t,n)=>le(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:t,content:n})}),getFiles:e=>le(`/api/projects/${e}/files`),transcribe:e=>le("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>{const t=new URLSearchParams;return e&&t.append("path",e),le(`/api/browse-filesystem?${t}`)},createFolder:e=>le("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),get:e=>le(`/api${e}`)},Lx=({onClose:e,onProjectCreated:t})=>{const{t:n}=Mt(),[s,o]=l.useState(1),[a,i]=l.useState("existing"),[c,d]=l.useState(""),[u,p]=l.useState(!1),[m,h]=l.useState(null),[g,x]=l.useState([]),[S,k]=l.useState(!1),[I,A]=l.useState(!1),[w,M]=l.useState("~"),[C,b]=l.useState([]),[R,B]=l.useState(!1),[D,Z]=l.useState(!1),[z,X]=l.useState(!1),[q,re]=l.useState(""),[Se,Ce]=l.useState(!1);l.useEffect(()=>{c.length>2?ge(c):(x([]),k(!1))},[c]);const ge=async P=>{try{const ae=P.lastIndexOf("/"),ee=ae>0?P.substring(0,ae):"~",lt=await(await mt.browseFilesystem(ee)).json();if(lt.suggestions){const Ge=lt.suggestions.filter(Ke=>Ke.path.toLowerCase().startsWith(P.toLowerCase())&&Ke.path.toLowerCase()!==P.toLowerCase());x(Ge.slice(0,5)),k(Ge.length>0)}}catch(ae){console.error("Error loading path suggestions:",ae)}},de=()=>{if(h(null),s===1){if(!a){h(n("projectWizard.errors.selectType"));return}o(2)}else if(s===2){if(!c.trim()){h(n("projectWizard.errors.providePath"));return}o(3)}},H=()=>{h(null),o(s-1)},Le=async()=>{p(!0),h(null);try{const P={workspaceType:a,path:c.trim()},ae=await mt.createWorkspace(P),ee=await ae.json();if(!ae.ok)throw new Error(ee.details||ee.error||n("projectWizard.errors.failedToCreate"));t&&t(ee.project),e()}catch(P){console.error("Error creating workspace:",P),h(P.message||n("projectWizard.errors.failedToCreate"))}finally{p(!1)}},$=P=>{d(P.path),k(!1)},N=async()=>{A(!0),await O("~")},O=async P=>{try{B(!0);const ee=await(await mt.browseFilesystem(P)).json();M(ee.path||P),b(ee.suggestions||[])}catch(ae){console.error("Error loading folders:",ae)}finally{B(!1)}},ne=(P,ae=!1)=>{d(P),A(!1),ae&&o(3)},ke=async P=>{await O(P)},xe=async()=>{if(q.trim()){Ce(!0),h(null);try{const P=w.includes("\\")?"\\":"/",ae=`${w}${P}${q.trim()}`,ee=await mt.createFolder(ae),Ne=await ee.json();if(!ee.ok)throw new Error(Ne.error||n("projectWizard.errors.failedToCreateFolder","Failed to create folder"));re(""),X(!1),await O(Ne.path||ae)}catch(P){console.error("Error creating folder:",P),h(P.message||n("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}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(tn,{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(sr,{className:"w-5 h-5"})})]}),r.jsx("div",{className:"px-6 pt-4 pb-2",children:r.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(P=>r.jsxs(Tn.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${P<s?"bg-green-500 text-white":P===s?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:P<s?r.jsx(vr,{className:"w-4 h-4"}):P}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:n(P===1?"projectWizard.steps.type":P===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),P<3&&r.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${P<s?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},P))})}),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(jm,{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(tn,{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(tn,{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(Pt,{type:"text",value:c,onChange:P=>d(P.target.value),placeholder:a==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),S&&g.length>0&&r.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:g.map((P,ae)=>r.jsxs("button",{onClick:()=>$(P),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:P.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:P.path})]},ae))})]}),r.jsx(Re,{type:"button",variant:"outline",onClick:N,className:"px-3",title:"Browse folders",children:r.jsx(rn,{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(Re,{variant:"outline",onClick:s===1?e:H,disabled:u,children:s===1?n("projectWizard.buttons.cancel"):r.jsxs(r.Fragment,{children:[r.jsx(Tc,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.back")]})}),r.jsx(Re,{onClick:s===3?Le:de,disabled:u||s===1&&!a,children:u?r.jsxs(r.Fragment,{children:[r.jsx(Wn,{className:"w-4 h-4 mr-2 animate-spin"}),n("projectWizard.buttons.creating")]}):s===3?r.jsxs(r.Fragment,{children:[r.jsx(vr,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.createProject")]}):r.jsxs(r.Fragment,{children:[n("projectWizard.buttons.next"),r.jsx(yn,{className:"w-4 h-4 ml-1"})]})})]})]}),I&&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(rn,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>Z(!D),className:`p-2 rounded-md transition-colors ${D?"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:D?"Hide hidden folders":"Show hidden folders",children:D?r.jsx(_c,{className:"w-5 h-5"}):r.jsx(rf,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>X(!z),className:`p-2 rounded-md transition-colors ${z?"text-primary bg-primary/10 dark:bg-primary/25":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:r.jsx(jn,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>A(!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(sr,{className:"w-5 h-5"})})]})]}),z&&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(Pt,{type:"text",value:q,onChange:P=>re(P.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:P=>{P.key==="Enter"&&xe(),P.key==="Escape"&&(X(!1),re(""))},autoFocus:!0}),r.jsx(Re,{size:"sm",onClick:xe,disabled:!q.trim()||Se,children:Se?r.jsx(Wn,{className:"w-4 h-4 animate-spin"}):"Create"}),r.jsx(Re,{size:"sm",variant:"ghost",onClick:()=>{X(!1),re("")},children:"Cancel"})]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:R?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Wn,{className:"w-6 h-6 animate-spin text-gray-400"})}):r.jsxs("div",{className:"space-y-1",children:[w!=="~"&&w!=="/"&&!/^[A-Za-z]:\\?$/.test(w)&&r.jsxs("button",{onClick:()=>{const P=Math.max(w.lastIndexOf("/"),w.lastIndexOf("\\"));let ae;P<=0?ae="/":P===2&&/^[A-Za-z]:/.test(w)?ae=w.substring(0,3):ae=w.substring(0,P),ke(ae)},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(rn,{className:"w-5 h-5 text-gray-400"}),r.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),C.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):C.filter(P=>D||!P.name.startsWith(".")).sort((P,ae)=>P.name.toLowerCase().localeCompare(ae.name.toLowerCase())).map((P,ae)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>ke(P.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[r.jsx(tn,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:P.name})]}),r.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>ne(P.path,a==="existing"),className:"text-xs px-3",children:"Select"})]},ae))]})}),r.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),r.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:w})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[r.jsx(Re,{variant:"outline",onClick:()=>{A(!1),X(!1),re("")},children:"Cancel"}),r.jsx(Re,{variant:"outline",onClick:()=>ne(w,a==="existing"),children:"Use this folder"})]})]})]})})]})},Ox=(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"})},Fx=(e,t)=>{if(typeof e!="string")return"";const n=e.trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`},gn="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",Ss="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",Qo="block min-w-0 w-full max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",fl=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?r.jsx(ao,{className:t}):e==="gemini"?r.jsx(io,{className:t}):e==="opencode"?r.jsx(lo,{className:"h-3.5 w-auto max-w-full"}):r.jsx(es,{className:t});function hl({projects:e,selectedProject:t,selectedSession:n,onProjectSelect:s,onSessionSelect:o,onNewSession:a,onSessionDelete:i,onProjectDelete:c,isLoading:d,loadingProgress:u,onRefresh:p,updateAvailable:m,latestVersion:h,currentVersion:g,releaseInfo:x,onShowVersionModal:S,isPWA:k,isMobile:I,onToggleSidebar:A,lockedProjectName:w,showNewProject:M,setShowNewProject:C}){const{t:b}=Mt("sidebar"),[R,B]=l.useState(new Set),[D,Z]=l.useState(null),[z,X]=l.useState(""),[q,re]=l.useState({}),[Se,Ce]=l.useState({}),[ge,de]=l.useState(new Set),[H,Le]=l.useState(new Date),[$,N]=l.useState("name"),[O,ne]=l.useState(!1),[ke,xe]=l.useState(null),[P,ae]=l.useState(""),[ee,Ne]=l.useState(null),[lt,Ge]=l.useState(null),[Ke,qe]=l.useState({}),[ct,Et]=l.useState(""),[Xe,kt]=l.useState(new Set),[je,Ve]=l.useState(null),[jt,St]=l.useState(null),[Dt,Y]=l.useState(()=>{try{const T=localStorage.getItem("starredProjects");return T?new Set(JSON.parse(T)):new Set}catch(T){return console.error("Error loading starred projects:",T),new Set}}),oe=T=>G=>{G.target.closest(".overflow-y-auto")||G.target.closest("[data-scroll-container]")||(G.preventDefault(),G.stopPropagation(),T())};l.useEffect(()=>{const T=setInterval(()=>{Le(new Date)},6e4);return()=>clearInterval(T)},[]),l.useEffect(()=>{Ce({}),de(new Set)},[e]),l.useEffect(()=>{n&&t&&B(T=>new Set([...T,t.name]))},[n,t]),l.useEffect(()=>{w&&B(new Set([w]))},[w,e.length]),l.useEffect(()=>{if(e.length>0&&!d){const T=new Set;e.forEach(G=>{G.sessions&&G.sessions.length>=0&&T.add(G.name)}),de(T)}},[e,d]),l.useEffect(()=>{const T=()=>{try{const fe=localStorage.getItem("claude-settings");if(fe){const j=JSON.parse(fe);N(j.projectSortOrder||"name")}}catch(fe){console.error("Error loading sort order:",fe)}};T();const G=fe=>{fe.key==="claude-settings"&&T()};window.addEventListener("storage",G);const Me=setInterval(()=>{document.hasFocus()&&T()},1e3);return()=>{window.removeEventListener("storage",G),clearInterval(Me)}},[]);const Ee=T=>{const G=new Set;R.has(T)||G.add(T),B(G)},Ae=(T,G)=>{o({...T,__projectName:G})},Oe=T=>{const G=new Set(Dt);G.has(T)?G.delete(T):G.add(T),Y(G);try{localStorage.setItem("starredProjects",JSON.stringify([...G]))}catch(Me){console.error("Error saving starred projects:",Me)}},tt=T=>Dt.has(T),ue=T=>{let G={};try{G=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const Me=[...T.sessions||[],...Se[T.name]||[]].map(ye=>({...ye,__provider:G[ye.id]||"claude"})),fe=(T.codexSessions||[]).map(ye=>({...ye,__provider:"codex"})),j=(T.geminiSessions||[]).map(ye=>({...ye,__provider:"gemini"})),F=(T.opencodeSessions||[]).map(ye=>({...ye,__provider:"opencode"})),ve=ye=>ye.__provider==="codex"?new Date(ye.createdAt||ye.lastActivity):ye.__provider==="gemini"?new Date(ye.createdAt||ye.lastActivity):ye.__provider==="opencode"?new Date(ye.createdAt||ye.lastActivity):new Date(ye.lastActivity);return[...Me,...fe,...j,...F].sort((ye,ut)=>ve(ut)-ve(ye))},dt=T=>{const G=ue(T);return G.length===0?new Date(0):G.reduce((fe,j)=>{const F=new Date(j.lastActivity);return F>fe?F:fe},new Date(0))},Ye=[...e].sort((T,G)=>{const Me=tt(T.name),fe=tt(G.name);if(Me&&!fe)return-1;if(!Me&&fe)return 1;if($==="date")return dt(G)-dt(T);{const j=T.displayName||T.name,F=G.displayName||G.name;return j.localeCompare(F)}}),Qe=T=>{Z(T.name),X(T.displayName)},Be=()=>{Z(null),X("")},Lt=async T=>{try{(await mt.renameProject(T,z)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(G){console.error("Error renaming project:",G)}Z(null),X("")},Nt=(T,G,Me,fe="claude")=>{St({projectName:T,sessionId:G,sessionTitle:Me,provider:fe})},vt=async()=>{if(!jt)return;const{projectName:T,sessionId:G,provider:Me}=jt;St(null);try{console.log("[Sidebar] Deleting session:",{projectName:T,sessionId:G,provider:Me});let fe;if(Me==="codex"?fe=await mt.deleteCodexSession(G):Me==="opencode"?fe=await mt.deleteOpencodeSession(G):fe=await mt.deleteSession(T,G),console.log("[Sidebar] Delete response:",{ok:fe.ok,status:fe.status}),fe.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(G):console.warn("[Sidebar] No onSessionDelete callback provided");else{const j=await fe.text();console.error("[Sidebar] Failed to delete session:",{status:fe.status,error:j}),alert(b("messages.deleteSessionFailed"))}}catch(fe){console.error("[Sidebar] Error deleting session:",fe),alert(b("messages.deleteSessionError"))}},$t=T=>{const G=ue(T).length;Ve({project:T,sessionCount:G})},rt=async()=>{if(!je)return;const{project:T,sessionCount:G}=je,Me=G===0;Ve(null),kt(fe=>new Set([...fe,T.name]));try{const fe=await mt.deleteProject(T.name,!Me);if(fe.ok)c&&c(T.name);else{const j=await fe.json();console.error("Failed to delete project"),alert(j.error||b("messages.deleteProjectFailed"))}}catch(fe){console.error("Error deleting project:",fe),alert(b("messages.deleteProjectError"))}finally{kt(fe=>{const j=new Set(fe);return j.delete(T.name),j})}},ft=async T=>{if(!(!(T.sessionMeta?.hasMore!==!1)||q[T.name])){re(Me=>({...Me,[T.name]:!0}));try{const Me=(T.sessions?.length||0)+(Se[T.name]?.length||0),fe=await mt.sessions(T.name,5,Me);if(fe.ok){const j=await fe.json();Ce(F=>({...F,[T.name]:[...F[T.name]||[],...j.sessions]})),j.hasMore===!1&&(T.sessionMeta={...T.sessionMeta,hasMore:!1})}}catch(Me){console.error("Error loading more sessions:",Me)}finally{re(Me=>({...Me,[T.name]:!1}))}}},qt=Ye.filter(T=>{if(!ct.trim())return!0;const G=ct.toLowerCase(),Me=(T.displayName||T.name).toLowerCase(),fe=T.name.toLowerCase();return Me.includes(G)||fe.includes(G)}),It=!!w,ht=It?Ye.filter(T=>T.name===w):qt,Qt=t||ht[0]||null,Vt=I?"bottom":"right",Zt=I?"end":"start",Rt=I?4:8;return r.jsxs(r.Fragment,{children:[M&&qo.createPortal(r.jsx(Lx,{onClose:()=>C(!1),onProjectCreated:T=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),je&&qo.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(wa,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteProject")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:je.project.displayName||je.project.name}),"?"]}),je.sessionCount>0&&r.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[r.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:b("deleteConfirmation.sessionCount",{count:je.sessionCount})}),r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:b("deleteConfirmation.allConversationsDeleted")})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Re,{variant:"outline",className:"flex-1",onClick:()=>Ve(null),children:b("actions.cancel")}),r.jsxs(Re,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:rt,children:[r.jsx(dr,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),jt&&qo.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(wa,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:b("deleteConfirmation.deleteSession")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[b("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:jt.sessionTitle||b("sessions.unnamed")}),"?"]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:b("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Re,{variant:"outline",className:"flex-1",onClick:()=>St(null),children:b("actions.cancel")}),r.jsxs(Re,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:vt,children:[r.jsx(dr,{className:"w-4 h-4 mr-2"}),b("actions.delete")]})]})]})}),document.body),r.jsxs("div",{className:"h-full flex flex-col bg-muted/40 md:select-none",style:k&&I?{paddingTop:"44px"}:{},children:[r.jsxs("div",{className:"md:flex-shrink-0 md:px-3 md:pt-3",children:[r.jsxs("div",{className:"hidden h-[60px] items-center justify-between gap-3 rounded-2xl bg-background/70 px-3 md:flex",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-foreground text-background flex-shrink-0",children:r.jsx(Hn,{className:"w-4 h-4 text-primary-foreground"})}),r.jsx("div",{className:"min-w-0",children:r.jsx("h1",{className:"text-base font-semibold leading-none text-foreground truncate",children:b("app.title")})})]}),A&&r.jsx(Re,{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:A,title:b("tooltips.hideSidebar"),children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),r.jsx("div",{className:"chat-header bg-white p-3 dark:bg-background md:hidden",style:k&&I?{paddingTop:"16px"}:{},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:r.jsx(Hn,{className:"w-4 h-4 text-primary-foreground"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:b("app.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.title")})]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-muted/70 text-foreground transition-all duration-150 active:scale-95",onClick:async()=>{ne(!0);try{await p()}finally{ne(!1)}},disabled:O,children:r.jsx(Ir,{className:`w-4 h-4 text-foreground ${O?"animate-spin":""}`})}),!It&&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:()=>C(!0),children:r.jsx(tn,{className:"w-4 h-4"})})]})]})})]}),!d&&!I&&!It&&r.jsx("div",{className:"hidden"}),e.length>0&&!d&&!It&&r.jsx("div",{className:"px-3 py-3 md:px-3",children:r.jsxs("div",{className:"relative",children:[r.jsx(ya,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),r.jsx(Pt,{type:"text",placeholder:b("projects.searchPlaceholder"),value:ct,onChange:T=>Et(T.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"}),ct&&r.jsx("button",{onClick:()=>Et(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:r.jsx(sr,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.length>0&&!d&&Qt&&r.jsx("div",{className:"px-3 pb-2",children:r.jsxs(Re,{variant:"subtle",className:"h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm",onClick:()=>a(Qt),children:[r.jsx(jn,{className:"h-4 w-4"}),b("sessions.newSession")]})}),r.jsx(Qd,{className:"flex-1 overflow-x-hidden overflow-y-auto overscroll-contain px-2 py-2 md:px-3 md:py-2",children:r.jsx("div",{className:"space-y-1 overflow-x-hidden pb-safe-area-inset-bottom",children:d?r.jsx("div",{className:"flex min-h-[240px] items-start justify-center px-4 pt-10 md:min-h-[280px] md:px-6 md:pt-12",children:r.jsx("div",{className:"w-full max-w-[320px] text-center space-y-4",children:r.jsxs("div",{className:"space-y-2.5",children:[r.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:u&&u.total>0?r.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${u.current/u.total*100}%`}}):r.jsx("div",{className:"h-full w-1/3 rounded-full bg-primary animate-pulse"})}),u?.currentProject&&r.jsx("p",{className:"mx-auto max-w-[260px] break-words text-base font-medium leading-6 text-foreground",title:u.currentProject,children:u.currentProject.split("-").slice(-2).join("/")}),u&&u.total>0?r.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.current,"/",u.total,r.jsx("span",{className:"ml-1 text-sm text-muted-foreground",children:b("projects.projects")})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.loadingProjects")})]})})}):e.length===0?r.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[r.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:r.jsx(Ko,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.runClaudeCli")})]}):ht.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(ya,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:b("projects.noMatchingProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:b("projects.tryDifferentSearch")})]}):ht.map(T=>{const G=R.has(T.name),Me=t?.name===T.name,fe=tt(T.name),j=Xe.has(T.name),F=It&&T.name===w,ve=F||G,ye=T.displayName||T.name,ut=Fx(ye,I?22:28);return r.jsxs("div",{className:it("space-y-2",j&&"pointer-events-none opacity-50"),children:[!F&&r.jsxs("div",{className:"group md:group",children:[r.jsx("div",{className:"md:hidden",children:r.jsxs("div",{className:it("mx-1 flex min-h-10 items-center gap-2 px-2 py-2 text-muted-foreground transition-colors active:scale-[0.98]",Me?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==T.name&&s(T),Ee(T.name)},onTouchEnd:oe(()=>{t?.name!==T.name&&s(T),Ee(T.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:G?r.jsx(rn,{className:it("h-4 w-4",fe?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Ko,{className:it("h-4 w-4",fe?"text-yellow-600 dark:text-yellow-400":Me?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:D===T.name?r.jsx("input",{type:"text",value:z,onChange:U=>X(U.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:b("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:U=>U.stopPropagation(),onKeyDown:U=>{U.key==="Enter"&&Lt(T.name),U.key==="Escape"&&Be()},style:{fontSize:"16px"}}):r.jsx("div",{className:it(Qo,Me&&"font-semibold"),children:ut})})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:D===T.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:U=>{U.stopPropagation(),Lt(T.name)},title:b("tooltips.save"),children:r.jsx(vr,{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:U=>{U.stopPropagation(),Be()},title:b("tooltips.cancel"),children:r.jsx(sr,{className:"h-3.5 w-3.5"})})]}):r.jsxs(bs,{children:[r.jsx(ws,{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:U=>U.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(xs,{className:"h-4 w-4"})})}),r.jsx(ks,{children:r.jsxs(js,{side:Vt,align:Zt,sideOffset:Rt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:U=>U.stopPropagation(),children:[r.jsxs(hr,{className:gn,onSelect:U=>{U.preventDefault(),Qe(T)},children:[r.jsx(ll,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),r.jsxs(hr,{className:gn,onSelect:U=>{U.preventDefault(),Oe(T.name)},children:[r.jsx(dl,{className:it("h-4 w-4",fe&&"fill-yellow-400 text-yellow-500")}),b(fe?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(pl,{className:"my-1 h-px bg-border"}),r.jsxs(hr,{className:Ss,onSelect:U=>{U.preventDefault(),$t(T)},children:[r.jsx(dr,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})}),r.jsxs("div",{role:"button",tabIndex:0,className:it("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",D===T.name?"h-auto":"h-9",Me?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==T.name&&s(T),Ee(T.name)},onTouchEnd:oe(()=>{t?.name!==T.name&&s(T),Ee(T.name)}),onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),t?.name!==T.name&&s(T),Ee(T.name))},title:T.fullPath||ye,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:G?r.jsx(rn,{className:it("h-4 w-4",fe?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Ko,{className:it("h-4 w-4",fe?"text-yellow-600 dark:text-yellow-400":Me?"text-foreground":"text-muted-foreground")})}),r.jsx("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:D===T.name?r.jsx("input",{type:"text",value:z,onChange:U=>X(U.target.value),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary",placeholder:b("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:U=>{U.key==="Enter"&&Lt(T.name),U.key==="Escape"&&Be()},onClick:U=>U.stopPropagation()}):r.jsx("div",{className:it(Qo,Me&&"font-semibold"),children:ut})})]}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:D===T.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:U=>{U.stopPropagation(),Lt(T.name)},title:b("tooltips.save"),children:r.jsx(vr,{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:U=>{U.stopPropagation(),Be()},title:b("tooltips.cancel"),children:r.jsx(sr,{className:"h-3.5 w-3.5"})})]}):r.jsxs(bs,{children:[r.jsx(ws,{asChild:!0,children:r.jsx("button",{className:it("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:U=>U.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(xs,{className:"h-4 w-4"})})}),r.jsx(ks,{children:r.jsxs(js,{side:Vt,align:Zt,sideOffset:Rt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:U=>U.stopPropagation(),children:[r.jsxs(hr,{className:gn,onSelect:U=>{U.preventDefault(),Qe(T)},children:[r.jsx(ll,{className:"h-4 w-4"}),b("tooltips.renameProject")]}),r.jsxs(hr,{className:gn,onSelect:U=>{U.preventDefault(),Oe(T.name)},children:[r.jsx(dl,{className:it("h-4 w-4",fe&&"fill-yellow-400 text-yellow-500")}),b(fe?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(pl,{className:"my-1 h-px bg-border"}),r.jsxs(hr,{className:Ss,onSelect:U=>{U.preventDefault(),$t(T)},children:[r.jsx(dr,{className:"h-4 w-4"}),b("tooltips.deleteProject")]})]})})]})})]})]}),ve&&r.jsxs("div",{className:it("space-y-1",F?"px-1 md:px-0":"px-0"),children:[ge.has(T.name)?ue(T).length===0&&!q[T.name]?r.jsx("div",{className:"px-3 py-2 text-left",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:b("sessions.noSessions")})}):ue(T).map(U=>{const ot=U.__provider==="codex",L=U.__provider==="gemini",W=U.__provider==="opencode",se=ot||L||W,E=ke===U.id&&!ot,J=n?.id===U.id,Q=ot?U.summary||U.name||b("projects.codexSession"):W?U.summary||U.name||b("projects.opencodeSession"):U.summary||U.name||b("projects.newSession"),he=se&&U.createdAt||U.lastActivity,be=ee===U.id||lt===U.id;return r.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>Ne(U.id),onMouseLeave:()=>Ne(te=>te===U.id?null:te),children:[r.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:r.jsxs("div",{className:it("mx-1 grid min-h-9 min-w-0 grid-cols-[auto,minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-lg px-2 py-2 transition-colors",J?"chat-sidebar-item-active":"chat-sidebar-item"),onClick:()=>{s(T),Ae(U,T.name)},onTouchEnd:oe(()=>{s(T),Ae(U,T.name)}),children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:r.jsx(fl,{provider:U.__provider})}),r.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:E?r.jsx("input",{type:"text",value:P,onChange:te=>ae(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"?updateSessionSummary(T.name,U.id,P):te.key==="Escape"&&(xe(null),ae(""))},onClick:te=>te.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:Qo,title:Q,children:Q})}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:E?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:te=>{te.stopPropagation(),updateSessionSummary(T.name,U.id,P)},title:b("tooltips.save"),children:r.jsx(vr,{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:te=>{te.stopPropagation(),xe(null),ae("")},title:b("tooltips.cancel"),children:r.jsx(sr,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:r.jsxs(bs,{children:[r.jsx(ws,{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:te=>te.stopPropagation(),"aria-label":b("actions.settings"),children:r.jsx(xs,{className:"h-4 w-4"})})}),r.jsx(ks,{children:r.jsxs(js,{side:Vt,align:Zt,sideOffset:Rt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:te=>te.stopPropagation(),children:[!ot&&r.jsxs(hr,{className:gn,onSelect:te=>{te.preventDefault(),xe(U.id),ae(U.summary||U.name||b("projects.newSession"))},children:[r.jsx(cl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),r.jsxs(hr,{className:Ss,onSelect:te=>{te.preventDefault(),Nt(T.name,U.id,Q,U.__provider)},children:[r.jsx(dr,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]})})})]})}),r.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:r.jsxs("div",{className:it("grid min-h-9 min-w-0 grid-cols-[minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-lg px-2 py-1 transition-colors",J?"chat-sidebar-item-active":"chat-sidebar-item"),children:[r.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 overflow-hidden text-left",onClick:()=>Ae(U,T.name),onTouchEnd:oe(()=>Ae(U,T.name)),children:[r.jsx("span",{className:it("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",J||E?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:r.jsx(fl,{provider:U.__provider})}),E?r.jsx("input",{type:"text",value:P,onChange:te=>ae(te.target.value),onKeyDown:te=>{te.stopPropagation(),te.key==="Enter"?updateSessionSummary(T.name,U.id,P):te.key==="Escape"&&(xe(null),ae(""))},onClick:te=>te.stopPropagation(),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}):r.jsx("span",{className:"block min-w-0 w-full flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-sm text-foreground",title:Q,children:Q})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end pl-1",children:E?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:te=>{te.stopPropagation(),updateSessionSummary(T.name,U.id,P)},title:b("tooltips.save"),children:r.jsx(vr,{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:te=>{te.stopPropagation(),xe(null),ae("")},title:b("tooltips.cancel"),children:r.jsx(sr,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:be?r.jsxs(bs,{onOpenChange:te=>Ge(te?U.id:null),children:[r.jsx(ws,{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:te=>te.stopPropagation(),onFocus:()=>Ne(U.id),"aria-label":b("actions.settings"),children:r.jsx(xs,{className:"h-4 w-4"})})}),r.jsx(ks,{children:r.jsxs(js,{side:Vt,align:Zt,sideOffset:Rt,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:te=>te.stopPropagation(),children:[!ot&&r.jsxs(hr,{className:gn,onSelect:te=>{te.preventDefault(),xe(U.id),ae(U.summary||U.name||b("projects.newSession"))},children:[r.jsx(cl,{className:"h-4 w-4"}),b("tooltips.editSessionName")]}),r.jsxs(hr,{className:Ss,onSelect:te=>{te.preventDefault(),Nt(T.name,U.id,Q,U.__provider)},children:[r.jsx(dr,{className:"h-4 w-4"}),b("tooltips.deleteSession")]})]})})]}):r.jsx("span",{className:"text-[11px] text-muted-foreground",children:Ox(he,H,b)})})})]})})]},U.id)}):Array.from({length:3}).map((U,ot)=>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+ot*15}%`}})},ot)),ue(T).length>0&&T.sessionMeta?.hasMore!==!1&&r.jsx(Re,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>ft(T),disabled:q[T.name],children:q[T.name]?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),b("sessions.loading")]}):r.jsxs(r.Fragment,{children:[r.jsx(Ar,{className:"w-3 h-3"}),b("sessions.showMore")]})})]})]},T.name)})})}),m&&r.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[r.jsx("div",{className:"hidden md:block",children:r.jsxs(Re,{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:S,children:[r.jsxs("div",{className:"relative",children:[r.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})}),r.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:x?.title||`Version ${h}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})}),r.jsx("div",{className:"md:hidden p-3 pb-2",children:r.jsxs("button",{className:"flex h-12 w-full items-center justify-start gap-3 rounded-xl bg-blue-50 dark:bg-blue-900/20 px-4 transition-all duration-150 active:scale-[0.98]",onClick:S,children:[r.jsxs("div",{className:"relative",children:[r.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})}),r.jsx("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-blue-500 rounded-full animate-pulse"})]}),r.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[r.jsx("div",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:x?.title||`Version ${h}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:b("version.updateAvailable")})]})]})})]}),r.jsx("div",{className:"md:p-2 flex-shrink-0",children:r.jsxs("div",{className:"hidden md:flex items-center justify-between gap-2",children:[!It&&r.jsxs(Re,{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:()=>C(!0),title:b("tooltips.createProject"),children:[r.jsx(tn,{className:"w-4 h-4"}),r.jsx("span",{className:"text-xs leading-none",children:b("projects.newProject").includes("Project")?"New":b("projects.newProject").substring(0,2)})]}),r.jsxs(Re,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:async()=>{ne(!0);try{await p()}finally{ne(!1)}},disabled:O,title:b("tooltips.refresh"),children:[r.jsx(Ir,{className:`w-4 h-4 ${O?"animate-spin":""}`}),r.jsx("span",{className:"text-xs leading-none",children:b("actions.refresh")||"Sync"})]})]})})]})]})}var Zo={exports:{}},ea,gl;function $x(){if(gl)return ea;gl=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ea=e,ea}var ta,xl;function Bx(){if(xl)return ta;xl=1;var e=$x();function t(){}function n(){}return n.resetWarningCache=t,ta=function(){function s(i,c,d,u,p,m){if(m!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}s.isRequired=s;function o(){return s}var a={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:o,element:s,elementType:s,instanceOf:o,node:s,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},ta}var vl;function zx(){return vl||(vl=1,Zo.exports=Bx()()),Zo.exports}var Ux=zx();const at=Nc(Ux),Wx=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 Nn(e,t,n){const s=Hx(e),{webkitRelativePath:o}=e,a=typeof t=="string"?t:typeof o=="string"&&o.length>0?o:`./${e.name}`;return typeof s.path!="string"&&yl(s,"path",a),yl(s,"relativePath",a),s}function Hx(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const s=t.split(".").pop().toLowerCase(),o=Wx.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}function yl(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const qx=[".DS_Store","Thumbs.db"];function Vx(e){return an(this,void 0,void 0,function*(){return Us(e)&&Gx(e.dataTransfer)?Xx(e.dataTransfer,e.type):Kx(e)?Jx(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?Yx(e):[]})}function Gx(e){return Us(e)}function Kx(e){return Us(e)&&Us(e.target)}function Us(e){return typeof e=="object"&&e!==null}function Jx(e){return Sa(e.target.files).map(t=>Nn(t))}function Yx(e){return an(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>Nn(n))})}function Xx(e,t){return an(this,void 0,void 0,function*(){if(e.items){const n=Sa(e.items).filter(o=>o.kind==="file");if(t!=="drop")return n;const s=yield Promise.all(n.map(Qx));return bl(Zd(s))}return bl(Sa(e.files).map(n=>Nn(n)))})}function bl(e){return e.filter(t=>qx.indexOf(t.name)===-1)}function Sa(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 Qx(e){if(typeof e.webkitGetAsEntry!="function")return wl(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?eu(t):wl(e,t)}function Zd(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?Zd(n):[n]],[])}function wl(e,t){return an(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,Nn(i)}}const s=e.getAsFile();if(!s)throw new Error(`${e} is not a File`);return Nn(s,(n=t?.fullPath)!==null&&n!==void 0?n:void 0)})}function Zx(e){return an(this,void 0,void 0,function*(){return e.isDirectory?eu(e):e0(e)})}function eu(e){const t=e.createReader();return new Promise((n,s)=>{const o=[];function a(){t.readEntries(i=>an(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(Zx));o.push(c),a()}else try{const c=yield Promise.all(o);n(c)}catch(c){s(c)}}),i=>{s(i)})}a()})}function e0(e){return an(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(s=>{const o=Nn(s,e.fullPath);t(o)},s=>{n(s)})})})}var Ns={},kl;function t0(){return kl||(kl=1,Ns.__esModule=!0,Ns.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}),Ns}var r0=t0();const ra=Nc(r0);function jl(e){return o0(e)||s0(e)||ru(e)||n0()}function n0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
232
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function s0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function o0(e){if(Array.isArray(e))return Na(e)}function Sl(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 Nl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Sl(Object(n),!0).forEach(function(s){tu(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sl(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function tu(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gn(e,t){return l0(e)||i0(e,t)||ru(e,t)||a0()}function a0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
233
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ru(e,t){if(e){if(typeof e=="string")return Na(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 Na(e,t)}}function Na(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 i0(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 l0(e){if(Array.isArray(e))return e}var c0=typeof ra=="function"?ra:ra.default,d0="file-invalid-type",u0="file-too-large",p0="file-too-small",m0="too-many-files",f0=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:d0,message:"File type must be ".concat(s)}},Cl=function(t){return{code:u0,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},El=function(t){return{code:p0,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},h0={code:m0,message:"Too many files"};function nu(e,t){var n=e.type==="application/x-moz-file"||c0(e,t);return[n,n?null:f0(t)]}function su(e,t,n){if(Zr(e.size))if(Zr(t)&&Zr(n)){if(e.size>n)return[!1,Cl(n)];if(e.size<t)return[!1,El(t)]}else{if(Zr(t)&&e.size<t)return[!1,El(t)];if(Zr(n)&&e.size>n)return[!1,Cl(n)]}return[!0,null]}function Zr(e){return e!=null}function g0(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=nu(d,n),p=Gn(u,1),m=p[0],h=su(d,s,o),g=Gn(h,1),x=g[0],S=c?c(d):null;return m&&x&&!S})}function Ws(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Cs(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 Il(e){e.preventDefault()}function x0(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function v0(e){return e.indexOf("Edge/")!==-1}function y0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return x0(e)||v0(e)}function gr(){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!Ws(s)&&c&&c.apply(void 0,[s].concat(a)),Ws(s)})}}function b0(){return"showOpenFilePicker"in window}function w0(e){if(Zr(e)){var t=Object.entries(e).filter(function(n){var s=Gn(n,2),o=s[0],a=s[1],i=!0;return ou(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(au))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,s){var o=Gn(s,2),a=o[0],i=o[1];return Nl(Nl({},n),{},tu({},a,i))},{});return[{description:"Files",accept:t}]}return e}function k0(e){if(Zr(e))return Object.entries(e).reduce(function(t,n){var s=Gn(n,2),o=s[0],a=s[1];return[].concat(jl(t),[o],jl(a))},[]).filter(function(t){return ou(t)||au(t)}).join(",")}function j0(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function S0(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function ou(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function au(e){return/^.*\.[\w]+$/.test(e)}var N0=["children"],C0=["open"],E0=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],I0=["refKey","onChange","onClick"];function A0(e){return M0(e)||_0(e)||iu(e)||T0()}function T0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
234
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function M0(e){if(Array.isArray(e))return Ca(e)}function na(e,t){return P0(e)||R0(e,t)||iu(e,t)||D0()}function D0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
235
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function iu(e,t){if(e){if(typeof e=="string")return Ca(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 Ca(e,t)}}function Ca(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 R0(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 P0(e){if(Array.isArray(e))return e}function Al(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 wt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Al(Object(n),!0).forEach(function(s){Ea(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Al(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Ea(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hs(e,t){if(e==null)return{};var n=L0(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 L0(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 ci=l.forwardRef(function(e,t){var n=e.children,s=Hs(e,N0),o=cu(s),a=o.open,i=Hs(o,C0);return l.useImperativeHandle(t,function(){return{open:a}},[a]),Tn.createElement(l.Fragment,null,n(wt(wt({},i),{},{open:a})))});ci.displayName="Dropzone";var lu={disabled:!1,getFilesFromEvent:Vx,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};ci.defaultProps=lu;ci.propTypes={children:at.func,accept:at.objectOf(at.arrayOf(at.string)),multiple:at.bool,preventDropOnDocument:at.bool,noClick:at.bool,noKeyboard:at.bool,noDrag:at.bool,noDragEventsBubbling:at.bool,minSize:at.number,maxSize:at.number,maxFiles:at.number,disabled:at.bool,getFilesFromEvent:at.func,onFileDialogCancel:at.func,onFileDialogOpen:at.func,useFsAccessApi:at.bool,autoFocus:at.bool,onDragEnter:at.func,onDragLeave:at.func,onDragOver:at.func,onDrop:at.func,onDropAccepted:at.func,onDropRejected:at.func,onError:at.func,validator:at.func};var Ia={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function cu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=wt(wt({},lu),e),n=t.accept,s=t.disabled,o=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,c=t.multiple,d=t.maxFiles,u=t.onDragEnter,p=t.onDragLeave,m=t.onDragOver,h=t.onDrop,g=t.onDropAccepted,x=t.onDropRejected,S=t.onFileDialogCancel,k=t.onFileDialogOpen,I=t.useFsAccessApi,A=t.autoFocus,w=t.preventDropOnDocument,M=t.noClick,C=t.noKeyboard,b=t.noDrag,R=t.noDragEventsBubbling,B=t.onError,D=t.validator,Z=l.useMemo(function(){return k0(n)},[n]),z=l.useMemo(function(){return w0(n)},[n]),X=l.useMemo(function(){return typeof k=="function"?k:Tl},[k]),q=l.useMemo(function(){return typeof S=="function"?S:Tl},[S]),re=l.useRef(null),Se=l.useRef(null),Ce=l.useReducer(O0,Ia),ge=na(Ce,2),de=ge[0],H=ge[1],Le=de.isFocused,$=de.isFileDialogActive,N=l.useRef(typeof window<"u"&&window.isSecureContext&&I&&b0()),O=function(){!N.current&&$&&setTimeout(function(){if(Se.current){var oe=Se.current.files;oe.length||(H({type:"closeDialog"}),q())}},300)};l.useEffect(function(){return window.addEventListener("focus",O,!1),function(){window.removeEventListener("focus",O,!1)}},[Se,$,q,N]);var ne=l.useRef([]),ke=function(oe){re.current&&re.current.contains(oe.target)||(oe.preventDefault(),ne.current=[])};l.useEffect(function(){return w&&(document.addEventListener("dragover",Il,!1),document.addEventListener("drop",ke,!1)),function(){w&&(document.removeEventListener("dragover",Il),document.removeEventListener("drop",ke))}},[re,w]),l.useEffect(function(){return!s&&A&&re.current&&re.current.focus(),function(){}},[re,A,s]);var xe=l.useCallback(function(Y){B?B(Y):console.error(Y)},[B]),P=l.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ve(Y),ne.current=[].concat(A0(ne.current),[Y.target]),Cs(Y)&&Promise.resolve(o(Y)).then(function(oe){if(!(Ws(Y)&&!R)){var Ee=oe.length,Ae=Ee>0&&g0({files:oe,accept:Z,minSize:i,maxSize:a,multiple:c,maxFiles:d,validator:D}),Oe=Ee>0&&!Ae;H({isDragAccept:Ae,isDragReject:Oe,isDragActive:!0,type:"setDraggedFiles"}),u&&u(Y)}}).catch(function(oe){return xe(oe)})},[o,u,xe,R,Z,i,a,c,d,D]),ae=l.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ve(Y);var oe=Cs(Y);if(oe&&Y.dataTransfer)try{Y.dataTransfer.dropEffect="copy"}catch{}return oe&&m&&m(Y),!1},[m,R]),ee=l.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ve(Y);var oe=ne.current.filter(function(Ae){return re.current&&re.current.contains(Ae)}),Ee=oe.indexOf(Y.target);Ee!==-1&&oe.splice(Ee,1),ne.current=oe,!(oe.length>0)&&(H({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Cs(Y)&&p&&p(Y))},[re,p,R]),Ne=l.useCallback(function(Y,oe){var Ee=[],Ae=[];Y.forEach(function(Oe){var tt=nu(Oe,Z),ue=na(tt,2),dt=ue[0],Ye=ue[1],Qe=su(Oe,i,a),Be=na(Qe,2),Lt=Be[0],Nt=Be[1],vt=D?D(Oe):null;if(dt&&Lt&&!vt)Ee.push(Oe);else{var $t=[Ye,Nt];vt&&($t=$t.concat(vt)),Ae.push({file:Oe,errors:$t.filter(function(rt){return rt})})}}),(!c&&Ee.length>1||c&&d>=1&&Ee.length>d)&&(Ee.forEach(function(Oe){Ae.push({file:Oe,errors:[h0]})}),Ee.splice(0)),H({acceptedFiles:Ee,fileRejections:Ae,isDragReject:Ae.length>0,type:"setFiles"}),h&&h(Ee,Ae,oe),Ae.length>0&&x&&x(Ae,oe),Ee.length>0&&g&&g(Ee,oe)},[H,c,Z,i,a,d,h,g,x,D]),lt=l.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ve(Y),ne.current=[],Cs(Y)&&Promise.resolve(o(Y)).then(function(oe){Ws(Y)&&!R||Ne(oe,Y)}).catch(function(oe){return xe(oe)}),H({type:"reset"})},[o,Ne,xe,R]),Ge=l.useCallback(function(){if(N.current){H({type:"openDialog"}),X();var Y={multiple:c,types:z};window.showOpenFilePicker(Y).then(function(oe){return o(oe)}).then(function(oe){Ne(oe,null),H({type:"closeDialog"})}).catch(function(oe){j0(oe)?(q(oe),H({type:"closeDialog"})):S0(oe)?(N.current=!1,Se.current?(Se.current.value=null,Se.current.click()):xe(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):xe(oe)});return}Se.current&&(H({type:"openDialog"}),X(),Se.current.value=null,Se.current.click())},[H,X,q,I,Ne,xe,z,c]),Ke=l.useCallback(function(Y){!re.current||!re.current.isEqualNode(Y.target)||(Y.key===" "||Y.key==="Enter"||Y.keyCode===32||Y.keyCode===13)&&(Y.preventDefault(),Ge())},[re,Ge]),qe=l.useCallback(function(){H({type:"focus"})},[]),ct=l.useCallback(function(){H({type:"blur"})},[]),Et=l.useCallback(function(){M||(y0()?setTimeout(Ge,0):Ge())},[M,Ge]),Xe=function(oe){return s?null:oe},kt=function(oe){return C?null:Xe(oe)},je=function(oe){return b?null:Xe(oe)},Ve=function(oe){R&&oe.stopPropagation()},jt=l.useMemo(function(){return function(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},oe=Y.refKey,Ee=oe===void 0?"ref":oe,Ae=Y.role,Oe=Y.onKeyDown,tt=Y.onFocus,ue=Y.onBlur,dt=Y.onClick,Ye=Y.onDragEnter,Qe=Y.onDragOver,Be=Y.onDragLeave,Lt=Y.onDrop,Nt=Hs(Y,E0);return wt(wt(Ea({onKeyDown:kt(gr(Oe,Ke)),onFocus:kt(gr(tt,qe)),onBlur:kt(gr(ue,ct)),onClick:Xe(gr(dt,Et)),onDragEnter:je(gr(Ye,P)),onDragOver:je(gr(Qe,ae)),onDragLeave:je(gr(Be,ee)),onDrop:je(gr(Lt,lt)),role:typeof Ae=="string"&&Ae!==""?Ae:"presentation"},Ee,re),!s&&!C?{tabIndex:0}:{}),Nt)}},[re,Ke,qe,ct,Et,P,ae,ee,lt,C,b,s]),St=l.useCallback(function(Y){Y.stopPropagation()},[]),Dt=l.useMemo(function(){return function(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},oe=Y.refKey,Ee=oe===void 0?"ref":oe,Ae=Y.onChange,Oe=Y.onClick,tt=Hs(Y,I0),ue=Ea({accept:Z,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:Xe(gr(Ae,lt)),onClick:Xe(gr(Oe,St)),tabIndex:-1},Ee,Se);return wt(wt({},ue),tt)}},[Se,n,c,lt,s]);return wt(wt({},de),{},{isFocused:Le&&!s,getRootProps:jt,getInputProps:Dt,rootRef:re,inputRef:Se,open:Xe(Ge)})}function O0(e,t){switch(t.type){case"focus":return wt(wt({},e),{},{isFocused:!0});case"blur":return wt(wt({},e),{},{isFocused:!1});case"openDialog":return wt(wt({},Ia),{},{isFileDialogActive:!0});case"closeDialog":return wt(wt({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return wt(wt({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return wt(wt({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"reset":return wt({},Ia);default:return e}}function Tl(){}const $n=({children:e,content:t,position:n="top",className:s="",delay:o=500})=>{const[a,i]=l.useState(!1),[c,d]=l.useState(null),u=()=>{const g=setTimeout(()=>{i(!0)},o);d(g)},p=()=>{c&&(clearTimeout(c),d(null)),i(!1)},m=()=>{switch(n){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},h=()=>{switch(n){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return t?r.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:p,children:[e,a&&r.jsxs("div",{className:it("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:it("absolute w-0 h-0 border-4 border-transparent",h())})]})]}):e};function F0(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function _l(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:F0(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function Ml(e,t){return e||""}function $0(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 B0(e,t,n){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof n=="string"?n:""}function z0(e,t,n,s){const o=B0(e,t,t),a=Ml(o);if(e==="Bash"){const i=t?.command||"";return{activityKind:"command",title:s("activity.actions.runCommand"),summary:$0(i)||s("activity.actions.commandPending"),filePath:o,icon:Vf,heavy:!0}}if(e==="Grep"||e==="Glob"){const i=t?.pattern||t?.glob||"",c=Ml(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:ya,heavy:!1}}return e==="Read"?{activityKind:"read",title:s("activity.actions.readFile"),summary:a||s("activity.actions.readPending"),filePath:o,icon:cf,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:s("activity.actions.updateFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:sf,heavy:!0}:e==="Write"?{activityKind:"write",title:s("activity.actions.createFile"),summary:a||s("activity.actions.filePending"),filePath:o,icon:af,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:s("activity.actions.updateTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:il,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:s("activity.actions.readTodo"),summary:s("activity.actions.todoSummary"),filePath:"",icon:il,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:s("activity.actions.generatePlan"),summary:s("activity.actions.planSummary"),filePath:"",icon:Xa,heavy:!0}:{activityKind:"tool",title:s("activity.actions.runTool"),summary:e,filePath:o,icon:Zf,heavy:!0}}function U0({children:e,tone:t="default"}){const n=t==="danger"?"border-red-200/70 bg-red-50/80 text-red-900 dark:border-red-900/70 dark:bg-red-950/20 dark:text-red-100":"border-border/70 bg-muted/40 text-foreground";return r.jsx("pre",{className:it("overflow-x-auto rounded-lg border px-3 py-2 text-xs whitespace-pre-wrap break-words font-mono",n),children:e})}function W0({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&&!_l(o.toolResult)){const a=Ja(o.toolInput)||{},i=_l(o.toolResult),c=z0(o.toolName,a,null,s);return{phaseText:i?.isError?s("activity.stage.toolFailed"):c.activityKind==="search"?s("activity.stage.searching"):c.activityKind==="command"?s("activity.stage.runningCommand"):c.activityKind==="edit"||c.activityKind==="write"?s("activity.stage.editingFile"):c.activityKind==="read"?s("activity.stage.readingFile"):c.activityKind.startsWith("todo")?s("activity.stage.updatingTodo"):s("activity.stage.working"),detailText:c.summary,canAbort:e?.canAbort??!0,startedAt:e?.startedAt||Date.now()}}return e||null}function H0({request:e,permissionEntry:t,alreadyAllowed:n,rawInput:s,onAllowOnce:o,onAllowRemember:a,onDeny:i,className:c}){const{t:d}=Mt("chat"),u=d(n?"activity.permission.rememberSaved":"activity.permission.remember"),p=Ic(e.toolName);return r.jsx("div",{className:it("rounded-2xl border border-amber-200/80 bg-amber-50/85 p-4 shadow-sm dark:border-amber-900/70 dark:bg-amber-950/20",c),children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-200",children:r.jsx(Sm,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("div",{className:"text-sm font-semibold text-amber-950 dark:text-amber-100",children:d("activity.permission.title")}),r.jsx("span",{className:"rounded-full border border-amber-300/70 px-2 py-0.5 text-[11px] text-amber-700 dark:border-amber-800 dark:text-amber-200",children:p})]}),r.jsx("div",{className:"mt-1 text-xs text-amber-800 dark:text-amber-200",children:d("activity.requestTool",{tool:p||d("messageTypes.tool")})}),t?r.jsxs("div",{className:"mt-2 text-xs text-amber-700/90 dark:text-amber-300/80",children:[d("activity.permission.rule")," ",r.jsx("span",{className:"font-mono",children:t})]}):null,s?r.jsxs("details",{className:"mt-3 group",children:[r.jsxs("summary",{className:"flex cursor-pointer items-center gap-2 text-xs font-medium text-amber-800 transition-colors hover:text-amber-900 dark:text-amber-200 dark:hover:text-amber-100",children:[r.jsx(Ar,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-180"}),d("activity.permission.viewInput")]}),r.jsx(U0,{tone:"default",children:s})]}):null,r.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[r.jsx("button",{type:"button",onClick:o,className:"inline-flex items-center gap-2 rounded-md bg-amber-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-amber-700",children:d("activity.permission.allowOnce")}),r.jsx("button",{type:"button",onClick:a,disabled:!t,className:it("inline-flex items-center gap-2 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors",t?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-100 dark:hover:bg-amber-900/30":"cursor-not-allowed border-border text-muted-foreground opacity-60"),children:u}),r.jsx("button",{type:"button",onClick:i,className:"inline-flex items-center gap-2 rounded-md border border-red-300 px-3 py-1.5 text-xs font-medium text-red-700 transition-colors hover:bg-red-50 dark:border-red-900 dark:text-red-200 dark:hover:bg-red-950/20",children:d("activity.permission.deny")})]})]})]})})}function _r(e){return Array.isArray?Array.isArray(e):pu(e)==="[object Array]"}function q0(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function V0(e){return e==null?"":q0(e)}function yr(e){return typeof e=="string"}function du(e){return typeof e=="number"}function G0(e){return e===!0||e===!1||K0(e)&&pu(e)=="[object Boolean]"}function uu(e){return typeof e=="object"}function K0(e){return uu(e)&&e!==null}function Yt(e){return e!=null}function sa(e){return!e.trim().length}function pu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const J0="Incorrect 'index' type",Y0=e=>`Invalid value for key ${e}`,X0=e=>`Pattern length exceeds max of ${e}.`,Q0=e=>`Missing ${e} property in key`,Z0=e=>`Property 'weight' in key '${e}' must be a positive integer`,Dl=Object.prototype.hasOwnProperty;class ev{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(s=>{let o=mu(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 mu(e){let t=null,n=null,s=null,o=1,a=null;if(yr(e)||_r(e))s=e,t=Rl(e),n=Aa(e);else{if(!Dl.call(e,"name"))throw new Error(Q0("name"));const i=e.name;if(s=i,Dl.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(Z0(i));t=Rl(i),n=Aa(i),a=e.getFn}return{path:t,id:n,weight:o,src:s,getFn:a}}function Rl(e){return _r(e)?e:e.split(".")}function Aa(e){return _r(e)?e.join("."):e}function tv(e,t){let n=[],s=!1;const o=(a,i,c)=>{if(Yt(a))if(!i[c])n.push(a);else{let d=i[c];const u=a[d];if(!Yt(u))return;if(c===i.length-1&&(yr(u)||du(u)||G0(u)))n.push(V0(u));else if(_r(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,yr(t)?t.split("."):t,0),s?n:n[0]}const rv={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},nv={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},sv={location:0,threshold:.6,distance:100},ov={useExtendedSearch:!1,getFn:tv,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Ie={...nv,...rv,...sv,...ov};const av=/[^ ]+/g;function iv(e=1,t=3){const n=new Map,s=Math.pow(10,t);return{get(o){const a=o.match(av).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 di{constructor({getFn:t=Ie.getFn,fieldNormWeight:n=Ie.fieldNormWeight}={}){this.norm=iv(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,yr(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();yr(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(!Yt(t)||sa(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(Yt(i)){if(_r(i)){let c=[];const d=[{nestedArrIndex:-1,value:i}];for(;d.length;){const{nestedArrIndex:u,value:p}=d.pop();if(Yt(p))if(yr(p)&&!sa(p)){let m={v:p,i:u,n:this.norm.get(p)};c.push(m)}else _r(p)&&p.forEach((m,h)=>{d.push({nestedArrIndex:h,value:m})})}s.$[a]=c}else if(yr(i)&&!sa(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 fu(e,t,{getFn:n=Ie.getFn,fieldNormWeight:s=Ie.fieldNormWeight}={}){const o=new di({getFn:n,fieldNormWeight:s});return o.setKeys(e.map(mu)),o.setSources(t),o.create(),o}function lv(e,{getFn:t=Ie.getFn,fieldNormWeight:n=Ie.fieldNormWeight}={}){const{keys:s,records:o}=e,a=new di({getFn:t,fieldNormWeight:n});return a.setKeys(s),a.setIndexRecords(o),a}function Es(e,{errors:t=0,currentLocation:n=0,expectedLocation:s=0,distance:o=Ie.distance,ignoreLocation:a=Ie.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 cv(e=[],t=Ie.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 en=32;function dv(e,t,n,{location:s=Ie.location,distance:o=Ie.distance,threshold:a=Ie.threshold,findAllMatches:i=Ie.findAllMatches,minMatchCharLength:c=Ie.minMatchCharLength,includeMatches:d=Ie.includeMatches,ignoreLocation:u=Ie.ignoreLocation}={}){if(t.length>en)throw new Error(X0(en));const p=t.length,m=e.length,h=Math.max(0,Math.min(s,m));let g=a,x=h;const S=c>1||d,k=S?Array(m):[];let I;for(;(I=e.indexOf(t,x))>-1;){let R=Es(t,{currentLocation:I,expectedLocation:h,distance:o,ignoreLocation:u});if(g=Math.min(R,g),x=I+p,S){let B=0;for(;B<p;)k[I+B]=1,B+=1}}x=-1;let A=[],w=1,M=p+m;const C=1<<p-1;for(let R=0;R<p;R+=1){let B=0,D=M;for(;B<D;)Es(t,{errors:R,currentLocation:h+D,expectedLocation:h,distance:o,ignoreLocation:u})<=g?B=D:M=D,D=Math.floor((M-B)/2+B);M=D;let Z=Math.max(1,h-D+1),z=i?m:Math.min(h+D,m)+p,X=Array(z+2);X[z+1]=(1<<R)-1;for(let re=z;re>=Z;re-=1){let Se=re-1,Ce=n[e.charAt(Se)];if(S&&(k[Se]=+!!Ce),X[re]=(X[re+1]<<1|1)&Ce,R&&(X[re]|=(A[re+1]|A[re])<<1|1|A[re+1]),X[re]&C&&(w=Es(t,{errors:R,currentLocation:Se,expectedLocation:h,distance:o,ignoreLocation:u}),w<=g)){if(g=w,x=Se,x<=h)break;Z=Math.max(1,2*h-x)}}if(Es(t,{errors:R+1,currentLocation:h,expectedLocation:h,distance:o,ignoreLocation:u})>g)break;A=X}const b={isMatch:x>=0,score:Math.max(.001,w)};if(S){const R=cv(k,c);R.length?d&&(b.indices=R):b.isMatch=!1}return b}function uv(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 qs=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 hu{constructor(t,{location:n=Ie.location,threshold:s=Ie.threshold,distance:o=Ie.distance,includeMatches:a=Ie.includeMatches,findAllMatches:i=Ie.findAllMatches,minMatchCharLength:c=Ie.minMatchCharLength,isCaseSensitive:d=Ie.isCaseSensitive,ignoreDiacritics:u=Ie.ignoreDiacritics,ignoreLocation:p=Ie.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?qs(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const m=(g,x)=>{this.chunks.push({pattern:g,alphabet:uv(g),startIndex:x})},h=this.pattern.length;if(h>en){let g=0;const x=h%en,S=h-x;for(;g<S;)m(this.pattern.substr(g,en),g),g+=en;if(x){const k=h-en;m(this.pattern.substr(k),k)}}else m(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:s,includeMatches:o}=this.options;if(t=n?t:t.toLowerCase(),t=s?qs(t):t,this.pattern===t){let S={isMatch:!0,score:0};return o&&(S.indices=[[0,t.length-1]]),S}const{location:a,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:p}=this.options;let m=[],h=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:k,startIndex:I})=>{const{isMatch:A,score:w,indices:M}=dv(t,S,k,{location:a+I,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:o,ignoreLocation:p});A&&(g=!0),h+=w,A&&M&&(m=[...m,...M])});let x={isMatch:g,score:g?h/this.chunks.length:1};return g&&o&&(x.indices=m),x}}class Hr{constructor(t){this.pattern=t}static isMultiMatch(t){return Pl(t,this.multiRegex)}static isSingleMatch(t){return Pl(t,this.singleRegex)}search(){}}function Pl(e,t){const n=e.match(t);return n?n[1]:null}class pv extends Hr{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 mv extends Hr{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 fv extends Hr{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 hv extends Hr{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 gv extends Hr{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 xv extends Hr{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 gu extends Hr{constructor(t,{location:n=Ie.location,threshold:s=Ie.threshold,distance:o=Ie.distance,includeMatches:a=Ie.includeMatches,findAllMatches:i=Ie.findAllMatches,minMatchCharLength:c=Ie.minMatchCharLength,isCaseSensitive:d=Ie.isCaseSensitive,ignoreDiacritics:u=Ie.ignoreDiacritics,ignoreLocation:p=Ie.ignoreLocation}={}){super(t),this._bitapSearch=new hu(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 xu extends Hr{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 Ta=[pv,xu,fv,hv,xv,gv,mv,gu],Ll=Ta.length,vv=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,yv="|";function bv(e,t={}){return e.split(yv).map(n=>{let s=n.trim().split(vv).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<Ll;){const p=Ta[u];let m=p.isMultiMatch(c);m&&(o.push(new p(m,t)),d=!0)}if(!d)for(u=-1;++u<Ll;){const p=Ta[u];let m=p.isSingleMatch(c);if(m){o.push(new p(m,t));break}}}return o})}const wv=new Set([gu.type,xu.type]);class kv{constructor(t,{isCaseSensitive:n=Ie.isCaseSensitive,ignoreDiacritics:s=Ie.ignoreDiacritics,includeMatches:o=Ie.includeMatches,minMatchCharLength:a=Ie.minMatchCharLength,ignoreLocation:i=Ie.ignoreLocation,findAllMatches:c=Ie.findAllMatches,location:d=Ie.location,threshold:u=Ie.threshold,distance:p=Ie.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?qs(t):t,this.pattern=t,this.query=bv(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?qs(t):t;let i=0,c=[],d=0;for(let u=0,p=n.length;u<p;u+=1){const m=n[u];c.length=0,i=0;for(let h=0,g=m.length;h<g;h+=1){const x=m[h],{isMatch:S,indices:k,score:I}=x.search(t);if(S){if(i+=1,d+=I,s){const A=x.constructor.type;wv.has(A)?c=[...c,...k]:c.push(k)}}else{d=0,i=0,c.length=0;break}}if(i){let h={isMatch:!0,score:d/i};return s&&(h.indices=c),h}}return{isMatch:!1,score:1}}}const _a=[];function jv(...e){_a.push(...e)}function Ma(e,t){for(let n=0,s=_a.length;n<s;n+=1){let o=_a[n];if(o.condition(e,t))return new o(e,t)}return new hu(e,t)}const Vs={AND:"$and",OR:"$or"},Da={PATH:"$path",PATTERN:"$val"},Ra=e=>!!(e[Vs.AND]||e[Vs.OR]),Sv=e=>!!e[Da.PATH],Nv=e=>!_r(e)&&uu(e)&&!Ra(e),Ol=e=>({[Vs.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function vu(e,t,{auto:n=!0}={}){const s=o=>{let a=Object.keys(o);const i=Sv(o);if(!i&&a.length>1&&!Ra(o))return s(Ol(o));if(Nv(o)){const d=i?o[Da.PATH]:a[0],u=i?o[Da.PATTERN]:o[d];if(!yr(u))throw new Error(Y0(d));const p={keyId:Aa(d),pattern:u};return n&&(p.searcher=Ma(u,t)),p}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=o[d];_r(u)&&u.forEach(p=>{c.children.push(s(p))})}),c};return Ra(e)||(e=Ol(e)),s(e)}function Cv(e,{ignoreFieldNorm:t=Ie.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 Ev(e,t){const n=e.matches;t.matches=[],Yt(n)&&n.forEach(s=>{if(!Yt(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 Iv(e,t){t.score=e.score}function Av(e,t,{includeMatches:n=Ie.includeMatches,includeScore:s=Ie.includeScore}={}){const o=[];return n&&o.push(Ev),s&&o.push(Iv),e.map(a=>{const{idx:i}=a,c={item:t[i],refIndex:i};return o.length&&o.forEach(d=>{d(a,c)}),c})}class _n{constructor(t,n={},s){this.options={...Ie,...n},this.options.useExtendedSearch,this._keyStore=new ev(this.options.keys),this.setCollection(t,s)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof di))throw new Error(J0);this._myIndex=n||fu(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Yt(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=yr(t)?yr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Cv(d,{ignoreFieldNorm:c}),a&&d.sort(i),du(n)&&n>-1&&(d=d.slice(0,n)),Av(d,this._docs,{includeMatches:s,includeScore:o})}_searchStringList(t){const n=Ma(t,this.options),{records:s}=this._myIndex,o=[];return s.forEach(({v:a,i,n:c})=>{if(!Yt(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=vu(t,this.options),s=(c,d,u)=>{if(!c.children){const{keyId:m,searcher:h}=c,g=this._findMatches({key:this._keyStore.get(m),value:this._myIndex.getValueForItemAtKeyId(d,m),searcher:h});return g&&g.length?[{idx:u,item:d,matches:g}]:[]}const p=[];for(let m=0,h=c.children.length;m<h;m+=1){const g=c.children[m],x=s(g,d,u);if(x.length)p.push(...x);else if(c.operator===Vs.AND)return[]}return p},o=this._myIndex.records,a={},i=[];return o.forEach(({$:c,i:d})=>{if(Yt(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=Ma(t,this.options),{keys:s,records:o}=this._myIndex,a=[];return o.forEach(({$:i,i:c})=>{if(!Yt(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(!Yt(n))return[];let o=[];if(_r(n))n.forEach(({v:a,i,n:c})=>{if(!Yt(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}}_n.version="7.1.0";_n.createIndex=fu;_n.parseIndex=lv;_n.config=Ie;_n.parseQuery=vu;jv(kv);const Tv=({commands:e=[],selectedIndex:t=-1,onSelect:n,onClose:s,position:o={top:0,left:0},isOpen:a=!1,frequentCommands:i=[]})=>{const c=l.useRef(null),d=l.useRef(null),p=(()=>{const A=window.innerWidth<640,w=window.innerHeight;return A?{position:"fixed",bottom:`${o.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(o.top,w-316))}px`,left:`${o.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(l.useEffect(()=>{const A=w=>{c.current&&!c.current.contains(w.target)&&a&&s()};if(a)return document.addEventListener("mousedown",A),()=>{document.removeEventListener("mousedown",A)}},[a,s]),l.useEffect(()=>{if(d.current&&c.current){const A=c.current.getBoundingClientRect(),w=d.current.getBoundingClientRect();w.bottom>A.bottom?d.current.scrollIntoView({block:"nearest",behavior:"smooth"}):w.top<A.top&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[t]),!a)return null;if(e.length===0)return r.jsx("div",{ref:c,className:"command-menu command-menu-empty",style:{...p,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"No commands available"});const m=i.length>0,h=e.reduce((A,w)=>{const M=w.namespace||w.type||"other";return A[M]||(A[M]=[]),A[M].push(w),A},{});m&&(h.frequent=i);const x=(m?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(A=>h[A]),S={frequent:"⭐ Frequently Used",builtin:"Built-in Commands",project:"Project Commands",user:"User Commands",other:"Other Commands"};let k=0;const I=[];return x.forEach(A=>{h[A].forEach(w=>{I.push({...w,globalIndex:k++,namespace:A})})}),r.jsxs("div",{ref:c,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...p,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:a?1:0,transform:a?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[x.map(A=>r.jsxs("div",{className:"command-group",children:[x.length>1&&r.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:S[A]||A}),h[A].map(w=>{const M=I.find(b=>b.name===w.name&&b.namespace===A),C=M&&M.globalIndex===t;return r.jsxs("div",{ref:C?d:null,role:"option","aria-selected":C,className:"command-item",onMouseEnter:()=>n&&n(w,M.globalIndex,!0),onClick:()=>n&&n(w,M.globalIndex,!1),style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:C?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:b=>b.preventDefault(),children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:w.description?"4px":0},children:[r.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[A==="builtin"&&"⚡",A==="project"&&"📁",A==="user"&&"👤",A==="other"&&"📝"]}),r.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:w.name}),w.metadata?.type&&r.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:w.metadata.type})]}),w.description&&r.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:w.description})]}),C&&r.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${A}-${w.name}`)})]},A)),r.jsx("style",{children:`
|
|
236
|
-
.command-menu {
|
|
237
|
-
background-color: white;
|
|
238
|
-
border: 1px solid #e5e7eb;
|
|
239
|
-
}
|
|
240
|
-
.command-menu-empty {
|
|
241
|
-
color: #6b7280;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
@media (prefers-color-scheme: dark) {
|
|
245
|
-
.command-menu {
|
|
246
|
-
background-color: #1f2937 !important;
|
|
247
|
-
border: 1px solid #374151 !important;
|
|
248
|
-
}
|
|
249
|
-
.command-menu-empty {
|
|
250
|
-
color: #9ca3af !important;
|
|
251
|
-
}
|
|
252
|
-
.command-item[aria-selected="true"] {
|
|
253
|
-
background-color: #1e40af !important;
|
|
254
|
-
}
|
|
255
|
-
.command-item span:not(.command-metadata-badge) {
|
|
256
|
-
color: #f3f4f6 !important;
|
|
257
|
-
}
|
|
258
|
-
.command-metadata-badge {
|
|
259
|
-
background-color: #f3f4f6 !important;
|
|
260
|
-
color: #6b7280 !important;
|
|
261
|
-
}
|
|
262
|
-
.command-item div {
|
|
263
|
-
color: #d1d5db !important;
|
|
264
|
-
}
|
|
265
|
-
.command-group > div:first-child {
|
|
266
|
-
color: #9ca3af !important;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
`})]})},_v={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"},yu={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"},Mv={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"},Dv={OPTIONS:[{value:"kimi-k2.5",label:"Kimi K2.5"}],DEFAULT:"kimi-k2.5"},De={USER_MESSAGE:"user_message",ASSISTANT_TEXT_START:"assistant_text_start",ASSISTANT_TEXT_DELTA:"assistant_text_delta",ASSISTANT_TEXT_END:"assistant_text_end",REASONING_START:"reasoning_start",REASONING_DELTA:"reasoning_delta",REASONING_END:"reasoning_end",TOOL_CALL_START:"tool_call_start",TOOL_CALL_INPUT:"tool_call_input",TOOL_CALL_END:"tool_call_end",TOOL_RESULT:"tool_result",APPROVAL_REQUEST:"approval_request",APPROVAL_RESOLVED:"approval_resolved",SESSION_STATE_CHANGED:"session_state_changed",SYSTEM_NOTICE:"system_notice",ERROR:"error"};function cr(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function bu(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 zt({kind:e,provider:t="claude",sessionId:n=null,timestamp:s,payload:o={},extensions:a={},rawRef:i=null,eventId:c=null}){return{eventId:c||cr(e),kind:e,provider:t,sessionId:n,timestamp:bu(s),payload:o,extensions:a,rawRef:i}}function wu(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function oa({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||cr(e),u={...i,messageId:d};return[zt({kind:`${e}_start`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c}),zt({kind:`${e}_delta`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d,text:t},extensions:u,rawRef:c}),zt({kind:`${e}_end`,provider:n,sessionId:s,timestamp:o,payload:{messageId:d},extensions:u,rawRef:c})]}function Rv(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
|
|
270
|
-
|
|
271
|
-
[USER MESSAGE]
|
|
272
|
-
`,o=t.indexOf(s);return o>=0?t.slice(o+s.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function aa(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 vn(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function Pv(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 Gs(e,t){for(let n=e.length-1;n>=0;n-=1)if(t(e[n],n))return n;return-1}function Fl(e="",t=""){return t?e?e.endsWith(t)?e:`${e}${t}`:t:e}function Is(e,{messageId:t,timestamp:n,provider:s,isThinking:o=!1,kind:a="assistant"}){const i=Gs(e,d=>d?.eventMessageId===t&&!!d?.isStreaming&&!d.isToolUse&&!!d.isThinking==!!o);if(i>=0){const d={...e[i]};return d.isStreaming=!0,s&&(d.provider=s),n&&(d.timestamp=d.timestamp||n),e[i]=d,{messages:e,index:i}}const c={type:a,content:"",timestamp:n,provider:s,isStreaming:!0,eventMessageId:t};return o&&(c.isThinking=!0),e.push(c),{messages:e,index:e.length-1}}function As(e,{toolCallId:t,toolName:n,timestamp:s,provider:o}){const a=Gs(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 Lv(e=[],t="claude",n=null){if(!Array.isArray(e))return[];const s=[],o=Pv(e);for(const a of e){const i=bu(a?.timestamp),c={provider:t,timestamp:i,type:a?.type||a?.message?.role||"unknown"};if(a?.message?.role==="user"&&a?.message?.content){let d="";Array.isArray(a.message.content)?d=a.message.content.filter(p=>p?.type==="text").map(p=>p?.text||"").join(`
|
|
273
|
-
`):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=Rv(d);u&&(!aa(d)||u!==d)&&s.push(zt({kind:De.USER_MESSAGE,provider:t,sessionId:n,timestamp:i,payload:{text:u},rawRef:c}));continue}if(a?.type==="thinking"&&a?.message?.content){s.push(...oa({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||cr("tool"),u=a.toolResult||null;s.push(zt({kind:De.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),s.push(zt({kind:De.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,input:a.toolInput||""},rawRef:c})),s.push(zt({kind:De.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),u&&s.push(zt({kind:De.TOOL_RESULT,provider:t,sessionId:n,timestamp:u.timestamp||i,payload:{toolCallId:d,content:vn(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:c}));continue}if(a?.type==="tool_result"){s.push(zt({kind:De.TOOL_RESULT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:a.toolCallId||null,content:vn(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"&&!aa(d.text))s.push(...oa({text:d.text,provider:t,sessionId:n,timestamp:i,rawRef:c}));else if(d?.type==="tool_use"){const u=d.id||cr("tool"),p=o.get(d.id);s.push(zt({kind:De.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),s.push(zt({kind:De.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,input:vn(d.input||{})},rawRef:c})),s.push(zt({kind:De.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),p&&s.push(zt({kind:De.TOOL_RESULT,provider:t,sessionId:n,timestamp:p.timestamp||i,payload:{toolCallId:u,content:vn(p.content),isError:!!p.isError,toolUseResult:p.toolUseResult||null},rawRef:c}))}}else aa(a.message.content)||s.push(...oa({text:a.message.content,provider:t,sessionId:n,timestamp:i,rawRef:c}));continue}a?.type&&/error/i.test(a.type)&&s.push(zt({kind:De.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 ku(e=[],t,n="claude"){const s=Array.isArray(e)?[...e]:[];if(!wu(t))return s;const o=t.provider||n,a=t.timestamp||new Date().toISOString(),i=t.payload||{};switch(t.kind){case De.USER_MESSAGE:s.push({type:"user",content:i.text||"",timestamp:a,provider:o});break;case De.ASSISTANT_TEXT_START:{const c=i.messageId||t.extensions?.messageId||cr("assistant_text");Is(s,{messageId:c,timestamp:a,provider:o,isThinking:!1});break}case De.ASSISTANT_TEXT_DELTA:{const c=i.messageId||t.extensions?.messageId||cr("assistant_text"),{index:d}=Is(s,{messageId:c,timestamp:a,provider:o,isThinking:!1}),u={...s[d]};u.content=Fl(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,s[d]=u;break}case De.ASSISTANT_TEXT_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Gs(s,u=>u?.eventMessageId===c&&!u.isToolUse&&!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1});break}case De.REASONING_START:{const c=i.messageId||t.extensions?.messageId||cr("reasoning");Is(s,{messageId:c,timestamp:a,provider:o,isThinking:!0});break}case De.REASONING_DELTA:{const c=i.messageId||t.extensions?.messageId||cr("reasoning"),{index:d}=Is(s,{messageId:c,timestamp:a,provider:o,isThinking:!0}),u={...s[d]};u.content=Fl(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||o,u.isThinking=!0,s[d]=u;break}case De.REASONING_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Gs(s,u=>u?.eventMessageId===c&&!!u.isThinking);d>=0&&(s[d]={...s[d],isStreaming:!1,isThinking:!0});break}case De.TOOL_CALL_START:{const c=i.toolCallId||cr("tool"),{index:d}=As(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:i.toolName||s[d].toolName};break}case De.TOOL_CALL_INPUT:{const c=i.toolCallId||cr("tool"),{index:d}=As(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolInput:vn(i.input||""),provider:s[d].provider||o};break}case De.TOOL_CALL_END:{const c=i.toolCallId||t.extensions?.toolCallId;if(!c)break;const{index:d}=As(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolName:i.toolName||s[d].toolName};break}case De.TOOL_RESULT:{const c=i.toolCallId||t.extensions?.toolCallId||cr("tool"),{index:d}=As(s,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:o});s[d]={...s[d],toolResult:{content:vn(i.content||""),isError:!!i.isError,toolUseResult:i.toolUseResult||null,timestamp:a},toolError:!!i.isError,provider:s[d].provider||o};break}case De.APPROVAL_REQUEST:i.message&&s.push({type:"assistant",content:i.message,timestamp:a,provider:o,isApprovalRequest:!0,approvalRequest:i});break;case De.APPROVAL_RESOLVED:i.message&&s.push({type:"assistant",content:i.message,timestamp:a,provider:o,approvalResolution:i});break;case De.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 De.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 ju(e=[],t="claude"){return Array.isArray(e)?e.length>0&&!wu(e[0])?ju(Lv(e,t),t):e.reduce((n,s)=>ku(n,s,t),[]):[]}const $l={claude:{defaultMode:"default",modes:["default","acceptEdits","bypassPermissions","plan"]},codex:{defaultMode:"default",modes:["default","acceptEdits","bypassPermissions"]},gemini:{defaultMode:"default",modes:["default","acceptEdits","bypassPermissions"]},opencode:{defaultMode:"default",modes:["default","acceptEdits","bypassPermissions","plan"]}},Bl={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 zl(e){return $l[e]||$l.claude}function Ul(e){return Bl[e]||Bl.claude}function Ov(e){return e==="claude"||e==="codex"}function Fv(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}const ie={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},Ks=new Set([ie.CONNECTING,ie.QUEUED,ie.STREAMING,ie.AWAITING_APPROVAL]);function Er(e){return e==null?"":String(e).replace(/\r\n/g,`
|
|
274
|
-
`).trim()}function Wl(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:Er(e.content),isError:!!e.isError}}function $v(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=Wl(e.toolResult),c=Wl(t.toolResult);return Er(e.toolName)===Er(t.toolName)&&Er(e.toolInput)===Er(t.toolInput)&&i.content===c.content&&i.isError===c.isError}return!!e.isThinking!=!!t.isThinking?!1:Er(e.content)===Er(t.content)}function Bv(e,t){const n=Math.min(e.length,t.length);let s=0;for(;s<n&&$v(e[s],t[s]);)s+=1;return s}function zv(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=Bv(s,o);return i===s.length&&i===o.length?o:a&&i===o.length&&s.length>o.length?s:o}function Ts(e,t){return typeof t=="function"?t(e):t}function Hl(e,t={}){const n=Ks.has(e),s=Ks.has(e);return{isLoading:n,canAbortSession:s,...t}}function Pa(e,t=ie.IDLE){const n=String(e||"").trim().toLowerCase();return Object.values(ie).includes(n)?n:t}function Uv(e,t){return!e||typeof e!="object"?t:e.kind===De.SESSION_STATE_CHANGED?Pa(e.payload?.state,t):e.kind===De.APPROVAL_REQUEST?ie.AWAITING_APPROVAL:e.kind===De.APPROVAL_RESOLVED?ie.STREAMING:e.kind===De.ERROR?ie.ERRORED:e.kind===De.ASSISTANT_TEXT_START||e.kind===De.ASSISTANT_TEXT_DELTA||e.kind===De.REASONING_START||e.kind===De.REASONING_DELTA||e.kind===De.TOOL_CALL_START||e.kind===De.TOOL_CALL_INPUT||e.kind===De.TOOL_CALL_END||e.kind===De.TOOL_RESULT||e.kind===De.SYSTEM_NOTICE?ie.STREAMING:t}function Wv(e,t){const n=t?.payload||{},s=n.requestId||t?.extensions?.requestId||null;return!s||e.some(o=>o?.requestId===s)?e:[...e,{requestId:s,toolName:n.toolName||"UnknownTool",input:n.input,context:n.context,sessionId:t?.sessionId||n.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function Hv(e,t){const s=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return s?e.filter(o=>o?.requestId!==s):e}function qv(e,t){return t?e===ie.AWAITING_APPROVAL||Ks.has(e)?e:ie.STREAMING:e===ie.COMPLETED||e===ie.ABORTED||e===ie.ERRORED?e:ie.IDLE}function Vv(e=[]){return{messages:e,pendingPermissionRequests:[],phase:ie.IDLE,isLoading:!1,canAbortSession:!1}}function Gv(e,t){switch(t.type){case"replace_messages":return{...e,messages:Ts(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Ts(e.pendingPermissionRequests,t.value)};case"set_phase":{const n=Pa(t.phase,e.phase);return{...e,phase:n,...Hl(n,t.overrides)}}case"set_loading":{const n=!!Ts(e.isLoading,t.value),s=qv(e.phase,n);return{...e,phase:s,isLoading:n,canAbortSession:n?e.canAbortSession||Ks.has(s):!1}}case"set_can_abort":return{...e,canAbortSession:!!Ts(e.canAbortSession,t.value)};case"apply_conversation_event":{const n=ku(e.messages,t.event,t.provider),s=Uv(t.event,e.phase);let o=e.pendingPermissionRequests;if(t.event?.kind===De.APPROVAL_REQUEST)o=Wv(o,t.event);else if(t.event?.kind===De.APPROVAL_RESOLVED)o=Hv(o,t.event);else if(t.event?.kind===De.SESSION_STATE_CHANGED){const a=Pa(t.event?.payload?.state,"");(a===ie.COMPLETED||a===ie.ABORTED||a===ie.ERRORED||a===ie.IDLE)&&(o=[])}return{...e,messages:n,pendingPermissionRequests:o,phase:s,...Hl(s)}}default:return e}}const Kv=["claude","codex","gemini","opencode"];function nr(e){const t=String(e||"").trim().toLowerCase();return Kv.includes(t)?t:"claude"}function Jv(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 Yv(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(n,s)=>{const o=await Jv(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 Xv(e){switch(e){case"codex":return yu;case"gemini":return Mv;case"opencode":return Dv;case"claude":default:return _v}}function co(e){return`${nr(e)}-model`}function ui(e){return`${co(e)}-selection-source`}function _s(e){const t=nr(e),n=co(t),s=ui(t);return localStorage.getItem(s)!=="manual"?"":localStorage.getItem(n)||""}function Qv(e,t){const n=nr(e);localStorage.setItem(co(n),t),localStorage.setItem(ui(n),"manual")}function Zv(e){const t=nr(e);localStorage.removeItem(co(t)),localStorage.removeItem(ui(t))}function ey(e,t){return!e||!t?!1:e.eventId&&t.eventId?e.eventId===t.eventId:e.kind===t.kind&&e.provider===t.provider&&e.sessionId===t.sessionId&&e.timestamp===t.timestamp&&JSON.stringify(e.payload||{})===JSON.stringify(t.payload||{})}function Qr(e){return e&&e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function ty(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function ry(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function La(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function ny(e,t){if(e?.__threadMessageId)return String(e.__threadMessageId);const n=e?.id||e?.eventMessageId||e?.messageId||e?.toolCallId||e?.toolId||e?.requestId;if(n)return String(n);const s=(()=>{const c=e?.timestamp instanceof Date?e.timestamp.getTime():new Date(e?.timestamp||Date.now()).getTime();return Number.isNaN(c)?Date.now():c})(),o=String(e?.content||e?.toolName||e?.type||"").slice(0,32),a=String(e?.role||e?.type||"assistant"),i=String(e?.provider||e?.__provider||"");return`${a}:${i}:${s}:${t}:${o}`}const Cn="1",ql=5,Vl="replace",Oa="append",Ms="unknown",sy="installed",ia="not_installed",oy="checking",ay=["claude","codex","gemini","opencode"],iy=300*1e3,ly=15e3;function Tr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function br(e){return typeof e=="string"&&e.trim().length>0}function Su(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const cy=new Set(yu.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function dy(e){if(!Su(e))return!1;const t=e.trim().toLowerCase();return cy.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function uy(e,t){return nr(e)==="codex"?dy(t):Su(t)}function Ds(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}function py(e){if(typeof e!="string")return"";const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]||e}function uo(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!Tr(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 bn(e){return uo(e)?.path||""}function my(e){const t=uo(e);return t?br(t.displayName)?t.displayName:py(t.path):""}function fy(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 Gl(e){if(!e)return"";const t=[];br(e.label)&&t.push(e.label.trim());const n=fy(e.selector);return n&&t.push(n),t.join(" · ")}function hy(e){return e?br(e.systemContext)||br(bn(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:Tr(e.extensions)&&Object.keys(e.extensions).length>0:!1}function gy(e){return e?br(e.systemContext)||br(bn(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function Nu(e){if(!Tr(e)||e.version!==Cn||typeof e.systemContext!="string")return null;const t=uo(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const n=[];for(const o of e.selectedElements){if(!Tr(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&&!Tr(e.extensions))return null;const s={version:Cn,systemContext:e.systemContext,currentFile:t,selectedElements:n};return e.extensions!==void 0&&(s.extensions={...e.extensions}),s}function xy(e){if(!Tr(e)||e.version!==void 0&&e.version!==Cn||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=uo(e.currentFile);if(!n)return null;t.currentFile=n}if(e.selectedElements!==void 0){const n=[];for(const s of e.selectedElements){if(!Tr(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(!Tr(e.extensions))return null;t.extensions={...e.extensions}}return t}function vy(e){return`${e.tag}::${e.selector}::${e.label}`}function yy(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,n=[];for(const s of e){const o=vy(s);t.has(o)||(t.add(o),n.push(s))}return n}function by(){return{version:Cn,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function wy(e,t){const n=Nu(e)||by(),s=xy(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=yy([...Array.isArray(n.selectedElements)?n.selectedElements:[],...s.selectedElements])),s.extensions!==void 0&&(o.extensions=s.extensions),o}function ky(e){return typeof e!="string"?Vl:e.trim().toLowerCase()===Oa?Oa:Vl}function Kl(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const s=La(e);if(!s)return null;try{t=JSON.parse(s)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const n=Nu(t);return n||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function jy(e){if(!e)return null;const t={version:Cn,systemContext:e.systemContext||"",currentFile:bn(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(t.extensions=e.extensions),t}function Sy(e,t){return`<dynamic_context version="${Cn}">
|
|
275
|
-
${JSON.stringify(e,null,2)}
|
|
276
|
-
</dynamic_context>
|
|
277
|
-
|
|
278
|
-
<user_message>
|
|
279
|
-
${t}
|
|
280
|
-
</user_message>`}let Jl=!1;function Ny(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const s=`
|
|
281
|
-
|
|
282
|
-
[USER MESSAGE]
|
|
283
|
-
`,o=t.indexOf(s);return o>=0?t.slice(o+s.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function la(e=[]){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];if(typeof t.content!="string")return[t];const n=Ny(t.content);return n?n===t.content?[t]:[{...t,content:n}]:[]}):[]}function Cy(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const s=e[n],o=t[n];if(s?.type!==o?.type||s?.role!==o?.role||s?.content!==o?.content||s?.timestamp!==o?.timestamp||!!s?.isToolUse!=!!o?.isToolUse)return!1}return!0}const Fa=({children:e,className:t})=>{const n=ty(String(e??"")),s=l.useMemo(()=>[Mm,Dm],[]),o=l.useMemo(()=>[Rm],[]);return r.jsx("div",{className:t,children:r.jsx(Pm,{remarkPlugins:s,rehypePlugins:o,components:_y,children:n})})};function $a(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(t,n)=>{let s=parseInt(n,10);if(!Number.isFinite(s))return t;s<1e12&&(s*=1e3);const o=new Date(s),a=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(o),i=-o.getTimezoneOffset(),c=i>=0?"+":"-",d=Math.abs(i),u=Math.floor(d/60),p=d%60,m=`GMT${c}${u}${p?":"+String(p).padStart(2,"0"):""}`,x=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,A=>A.toUpperCase()),S=x?`${m} (${x})`:m,k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],I=`${o.getDate()} ${k[o.getMonth()]} ${o.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${S}** - ${I}`})}catch{return e}}const At={setItem:(e,t)=>{try{if(e.startsWith("chat_messages_")&&typeof t=="string")try{const n=JSON.parse(t);if(Array.isArray(n)&&n.length>50){console.warn(`Truncating chat history for ${e} from ${n.length} to 50 messages`);const s=n.slice(-50);t=JSON.stringify(s)}}catch(n){console.warn("Could not parse chat messages for truncation:",n)}localStorage.setItem(e,t)}catch(n){if(n.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const s=Object.keys(localStorage),o=s.filter(i=>i.startsWith("chat_messages_")).sort();o.length>3&&o.slice(0,o.length-3).forEach(i=>{localStorage.removeItem(i),console.log(`Removed old chat data: ${i}`)}),s.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(e,t)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),e.startsWith("chat_messages_")&&typeof t=="string")try{const c=JSON.parse(t);if(Array.isArray(c)&&c.length>10){const d=c.slice(-10);localStorage.setItem(e,JSON.stringify(d)),console.warn("Saved only last 10 messages due to quota constraints")}}catch(c){console.error("Final save attempt failed:",c)}}}else console.error("localStorage error:",n)}},getItem:e=>{try{return localStorage.getItem(e)}catch(t){return console.error("localStorage getItem error:",t),null}},removeItem:e=>{try{localStorage.removeItem(e)}catch(t){console.error("localStorage removeItem error:",t)}}},Cu="claude-settings";function pi(){const e=At.getItem(Cu);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 Ba(e,t){if(!e)return null;if(e!=="Bash")return e;const n=Ja(t),s=typeof n?.command=="string"?n.command.trim():"";if(!s)return e;const o=s.split(/\s+/);return o.length===0?e:o[0]==="git"&&o[1]?`Bash(${o[0]} ${o[1]}:*)`:`Bash(${o[0]}:*)`}function Yl(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ey(e,t){if(t!=="claude"||!e?.toolResult?.isError)return null;const n=e?.toolName,s=Ba(n,e.toolInput);if(!s)return null;const a=pi().allowedTools.includes(s);return{toolName:n,entry:s,isAllowed:a}}function Iy(e){if(!e)return{success:!1};const t=pi(),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 At.setItem(Cu,JSON.stringify(a)),{success:!0,alreadyAllowed:n,updatedSettings:a}}function za({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 Ay(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")),za({phaseText:c,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:s,elapsedSeconds:e?.elapsedSeconds})}const Ty=({node:e,inline:t,className:n,children:s,...o})=>{const{t:a}=Mt("chat"),[i,c]=Tn.useState(!1),d=Array.isArray(s)?s.join(""):String(s??""),u=/[\r\n]/.test(d);if(t||e&&e.type==="inlineCode"||!u)return r.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${n||""}`,...o,children:s});const h=/language-(\w+)/.exec(n||""),g=h?h[1]:"text",x=d,S=()=>{const k=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(x).then(k).catch(()=>{const I=document.createElement("textarea");I.value=x,I.style.position="fixed",I.style.opacity="0",document.body.appendChild(I),I.select();try{document.execCommand("copy")}catch{}document.body.removeChild(I),k()});else{const I=document.createElement("textarea");I.value=x,I.style.position="fixed",I.style.opacity="0",document.body.appendChild(I),I.select();try{document.execCommand("copy")}catch{}document.body.removeChild(I),k()}}catch{}};return r.jsxs("div",{className:"relative group my-2",children:[g&&g!=="text"&&r.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:g}),r.jsx("button",{type:"button",onClick:S,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(Lm,{language:g,style:Om,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:g&&g!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},_y={code:Ty,blockquote:({children:e})=>r.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:e}),a:({href:e,children:t})=>r.jsx("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:t}),p:({children:e})=>r.jsx("div",{className:"mb-2 last:mb-0",children:e}),table:({children:e})=>r.jsx("div",{className:"overflow-x-auto my-2",children:r.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:e})}),thead:({children:e})=>r.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e}),th:({children:e})=>r.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:e}),td:({children:e})=>r.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:e})};l.memo(({message:e,index:t,prevMessage:n,createDiff:s,onFileOpen:o,onShowSettings:a,onGrantToolPermission:i,autoExpandTools:c,showRawParameters:d,showThinking:u,selectedProject:p,provider:m,isActiveStreamingCard:h})=>{const{t:g}=Mt("chat"),x=e.provider||e.__provider||m||"claude",S=x==="codex",k=x==="gemini",I=x==="opencode",A=n&&n.type===e.type&&(n.type==="assistant"||n.type==="user"||n.type==="tool"||n.type==="error");return Ey(e,m),r.jsx("div",{className:`chat-message ${e.type} ${A?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?r.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[r.jsxs("div",{className:"bg-primary text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[r.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&r.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((w,M)=>r.jsx("img",{src:w.data,alt:w.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(w.data,"_blank")},M))}),r.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!A&&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:[!A&&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:S?r.jsx(ao,{className:"w-full h-full"}):k?r.jsx(io,{className:"w-full h-full"}):I?r.jsx(lo,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):r.jsx(es,{className:"w-full h-full"})}),r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.type==="error"?g("messageTypes.error"):e.type==="tool"?g("messageTypes.tool"):S?g("messageTypes.codex"):k?g("messageTypes.gemini"):I?"OpenCode":g("messageTypes.claude")})]}),r.jsxs("div",{className:"w-full",children:[e.isToolUse?r.jsx(Fm,{toolName:e.toolName||"Tool",argsText:typeof e.toolInput=="string"?e.toolInput:JSON.stringify(e.toolInput??{},null,2),result:e.toolResult,isError:!!(e.toolResult?.isError||e.isError),status:e.isStreaming||e.toolResult==null?{type:"running"}:e.toolResult?.isError||e.isError?{type:"incomplete",reason:"error"}:{type:"complete"}}):e.isThinking?r.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:r.jsxs("details",{className:"group",open:h,children:[r.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[r.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r.jsx("span",{children:g("thinking.emoji")})]}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:r.jsx(Fa,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):r.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[u&&e.reasoning&&r.jsxs("details",{className:"mb-3",open:h,children:[r.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:g("thinking.emoji")}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:r.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const w=$a(String(e.content||"")),M=w.trim();if((M.startsWith("{")||M.startsWith("["))&&(M.endsWith("}")||M.endsWith("]")))try{const C=JSON.parse(M),b=JSON.stringify(C,null,2);return r.jsxs("div",{className:"my-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),r.jsx("span",{className:"font-medium",children:"JSON Response"})]}),r.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:r.jsx("pre",{className:"p-4 overflow-x-auto",children:r.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:b})})})]})}catch{}return e.type==="assistant"?r.jsx(Fa,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:w}):r.jsx("div",{className:"whitespace-pre-wrap",children:w})})()]}),r.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${A?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});const My=({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 Dy({selectedProject:e,selectedSession:t,ws:n,sendMessage:s,latestMessage:o,onFileOpen:a,onInputFocusChange:i,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:p,processingSessions:m,onReplaceTemporarySession:h,onNavigateToSession:g,onShowSettings:x,autoExpandTools:S,showRawParameters:k,showThinking:I,autoScrollToBottom:A,sendByCtrlEnter:w,externalMessageUpdate:M,urlContext:C,urlPrompt:b,integrationClientId:R,latestIntegrationMessage:B,sendIntegrationMessage:D,newSessionResetNonce:Z=0}){const{t:z}=Mt("chat"),[X,q]=l.useState(()=>typeof window<"u"&&e&&At.getItem(`draft_input_${e.name}`)||""),re=l.useMemo(()=>{if(typeof window<"u"&&e){const f=At.getItem(`chat_messages_${e.name}`);return f?la(JSON.parse(f)):[]}return[]},[e]),[Se,Ce]=l.useReducer(Gv,re,Vv),ge=Se.messages,de=Se.phase,H=Se.isLoading,Le=Se.canAbortSession,$=Se.pendingPermissionRequests,N=e?.fullPath||e?.path||null,O=l.useRef(!1),ne=l.useRef(ge),ke=l.useRef(e),xe=l.useRef(!1),P=l.useRef(Z),ae=l.useRef(Jl),[ee,Ne]=l.useState(t?.id||null),[lt,Ge]=l.useState(!1),[Ke,qe]=l.useState([]),[ct,Et]=l.useState(!1),[Xe,kt]=l.useState(!1),[je,Ve]=l.useState(0),[jt,St]=l.useState(!1),[Dt,Y]=l.useState(0),oe=100,[Ee,Ae]=l.useState(!1),[Oe,tt]=l.useState(()=>{const f=nr(localStorage.getItem("selected-provider"));return zl(f).defaultMode}),ue=l.useCallback(f=>{Ce({type:"replace_messages",value:f})},[]),dt=l.useCallback(f=>{Ce({type:"replace_permissions",value:f})},[]),Ye=l.useCallback(f=>{Ce({type:"set_loading",value:f})},[]),Qe=l.useCallback(f=>{Ce({type:"set_can_abort",value:f})},[]),Be=l.useCallback((f,v)=>{Ce({type:"set_phase",phase:f,overrides:v})},[]),Lt=l.useCallback((f,v)=>{Ce({type:"apply_conversation_event",event:f,provider:v})},[]),Nt=l.useCallback(f=>{!f||typeof f!="object"||qe(v=>{const y=Array.isArray(v)?v:[];return y.some(_=>ey(_,f))?y:[...y,f]})},[]),vt=l.useRef({sessionId:null,startedAt:0}),$t=l.useCallback(f=>{vt.current={sessionId:f||null,startedAt:Date.now()}},[]),rt=l.useCallback(f=>{!f||!vt.current.startedAt||(vt.current={...vt.current,sessionId:f})},[]),ft=l.useCallback((f=null)=>{const v=vt.current;v.startedAt&&(f&&v.sessionId&&v.sessionId!==f||(vt.current={sessionId:null,startedAt:0}))},[]),qt=l.useCallback((f,v=null)=>{if(v&&v!=="session-status")return!1;const y=vt.current;return!!(y.startedAt&&f&&y.sessionId===f&&Date.now()-y.startedAt<ly&&(de===ie.CONNECTING||de===ie.QUEUED||de===ie.STREAMING||de===ie.AWAITING_APPROVAL||de===ie.COMPLETED||de===ie.ABORTED||de===ie.ERRORED))},[de]),[It,ht]=l.useState([]),[Qt,Vt]=l.useState(new Map),[Zt,Rt]=l.useState(new Map),T=l.useRef(null),G=l.useRef(null),Me=l.useRef(null),fe=l.useRef(null),j=l.useRef(null),F=l.useRef(!1),ve=l.useRef(!1),ye=l.useRef(0),ut=l.useRef(!1),U=l.useRef(null),ot=l.useRef(""),L=l.useRef(null),W=l.useCallback(()=>{L.current&&(clearTimeout(L.current),L.current=null),ot.current=""},[]),se=l.useRef(null),E=l.useRef(new Set),J=l.useRef(new Map),Q=l.useRef(M),he=l.useRef(null),[be,te]=l.useState(""),[Je,gt]=l.useState(!1),[yt,nt]=l.useState([]),[We,Ot]=l.useState([]),[Ct,qr]=l.useState([]),[pr,Ft]=l.useState(-1),[Mn,ts]=l.useState(0),[vi,rs]=l.useState(-1),[fo,Dn]=l.useState(!1),ho=l.useRef({height:0,top:0}),[go,Rr]=l.useState(!1),[Pr,xo]=l.useState([]),[Vr,vo]=l.useState([]),[ns,Lr]=l.useState(""),[ep,Gr]=l.useState(!1),[mr,Or]=l.useState(null),[yo,Fr]=l.useState(-1),[yi,$r]=l.useState(-1),[Rn,tp]=l.useState(100),[bo,bt]=l.useState(null),bi=l.useRef(null),[Kr,ss]=l.useState("none"),[wo,rp]=l.useState(!1),[wi,np]=l.useState(!1),ko=l.useRef(null),jo=l.useRef(null),[me,ki]=l.useState(()=>nr(localStorage.getItem("selected-provider"))),Br=l.useMemo(()=>zl(me),[me]),Jr=l.useMemo(()=>Ul(me),[me]),So=l.useCallback((f,{short:v=!1}={})=>{let y=z("codex.modes.default");return f==="acceptEdits"?y=z("codex.modes.acceptEdits"):f==="bypassPermissions"?y=z("codex.modes.bypassPermissions"):f==="plan"&&(y=z("codex.modes.plan")),v?y.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):y},[z]),sp=l.useMemo(()=>So(Oe,{short:!0}),[So,Oe]),ji=l.useMemo(()=>z("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[z]),[No,Co]=l.useState({});l.useEffect(()=>{bi.current=bo},[bo]),l.useEffect(()=>()=>{J.current.forEach(f=>clearTimeout(f)),J.current.clear()},[]);const[op,Si]=l.useState({}),[ap,Ni]=l.useState({}),Eo=l.useCallback(async(f,{force:v=!1}={})=>{if(!ay.includes(f))return null;Si(y=>({...y,[f]:!0})),Ni(y=>({...y,[f]:null})),Co(y=>({...y,[f]:{status:oy}}));try{const _=await le(`/api/cli/providers/${f}/installation-status${v?"?force=true":""}`),K=await _.json().catch(()=>({}));if(!_.ok||K?.success!==!0)throw new Error(K?.error||`Failed to check ${f} installation`);const ce=K.installed?sy:ia;return Co(we=>({...we,[f]:{status:ce,command:K.command||null,resolvedPath:K.resolvedPath||null,reason:K.reason||null,installHint:K.installHint||null,checkedAt:K.checkedAt||null,cacheHit:!!K.cacheHit}})),ce}catch(y){return Co(_=>({..._,[f]:{status:Ms}})),Ni(_=>({..._,[f]:y.message})),Ms}finally{Si(y=>({...y,[f]:!1}))}},[]),[Io,Ci]=l.useState(()=>_s("claude")),[Ao,Ei]=l.useState(()=>_s("codex")),[To,Ii]=l.useState(()=>_s("gemini")),[_o,Ai]=l.useState(()=>_s("opencode")),[Ti,Mo]=l.useState({}),[nw,_i]=l.useState({}),[ip,Mi]=l.useState({}),os=me==="claude"?Io:me==="codex"?Ao:me==="gemini"?To:_o,Di=l.useMemo(()=>Xv(me).OPTIONS,[me]),Do=l.useMemo(()=>(Ti[me]||[]).map(f=>({value:f,label:f})),[Ti,me]),Yr=t?.__provider===me&&uy(me,t?.model)?t.model.trim():"",Gt=Yr||os,as=l.useMemo(()=>{const f=Do.length>0?Do:Di;return!Yr||f.some(v=>v.value===Yr)?f:[{value:Yr,label:Yr},...f]},[Do,Di,Yr]),lp=as.find(f=>f.value===Gt)?.label||Gt||z("providerSelection.selectModel"),cp=!!Yr,is=me==="opencode"&&!!ip.opencode,ls=l.useCallback(f=>{if(!f)return;const v=nr(f);ki(v),localStorage.setItem("selected-provider",v),Eo(v)},[Eo]),dn=l.useMemo(()=>Kl(C),[C]),[sw,Ro]=l.useState(dn),[jr,un]=l.useState(dn),[cs,ds]=l.useState(!1),Ri=l.useRef(dn),Pi=l.useRef(me);l.useEffect(()=>{const f=as.map(v=>v.value);os&&(f.includes(os)||(me==="claude"?Ci(""):me==="codex"?Ei(""):me==="gemini"?Ii(""):me==="opencode"&&Ai(""),Zv(me)))},[me,os,as]),l.useEffect(()=>{if(!e)return;const f=e.fullPath||e.path;if(!f)return;const v=`runtime-models:v2:${me}:${f}`,y=Ja(At.getItem(v)),_=Array.isArray(y?.models)?y.models:[],K=typeof y?.currentModel=="string"?y.currentModel.trim():"",ce=Number(y?.timestamp||0);if(_.length>0&&Date.now()-ce<iy){Mo(Fe=>({...Fe,[me]:_})),K&&_i(Fe=>({...Fe,[me]:{...Fe?.[me]||{},currentModel:K}}));return}let ze=!1;return Mi(Fe=>({...Fe,[me]:!0})),mt.providerDiscovery(me,f).then(async Fe=>{if(!Fe.ok)throw new Error(`HTTP ${Fe.status}`);return Fe.json()}).then(Fe=>{if(ze)return;const xt=Array.isArray(Fe?.models)?Fe.models.map(Ze=>Ze.id):[],_t=typeof Fe?.currentModel=="string"?Fe.currentModel.trim():"";_i(Ze=>({...Ze,[me]:Fe})),Mo(Ze=>({...Ze,[me]:xt})),xt.length>0&&At.setItem(v,JSON.stringify({models:xt,currentModel:_t||"",timestamp:Date.now()}))}).catch(()=>{ze||Mo(Fe=>({...Fe,[me]:_}))}).finally(()=>{ze||Mi(Fe=>({...Fe,[me]:!1}))}),()=>{ze=!0}},[me,e,wo]),l.useEffect(()=>{if(!wo)return;const f=v=>{ko.current&&!ko.current.contains(v.target)&&rp(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[wo]),l.useEffect(()=>{if(!wi)return;const f=v=>{jo.current&&!jo.current.contains(v.target)&&np(!1)};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[wi]),l.useEffect(()=>{O.current=H},[H]),l.useEffect(()=>{ne.current=ge},[ge]),l.useEffect(()=>{ke.current=e},[e]),l.useEffect(()=>{P.current!==Z&&(P.current=Z,!t&&(W(),ft(),se.current=null,sessionStorage.removeItem("pendingSessionId"),Ne(null),qe([]),ue([]),dt([]),Ae(!1),Be(ie.IDLE),bt(null),Qe(!1),q(""),Or(null),Dn(!1),e?.name&&(At.removeItem(`chat_messages_${e.name}`),At.removeItem(`draft_input_${e.name}`))))},[ft,Z,W,e?.name,t,Qe,ue,dt,Be]),l.useEffect(()=>{Ri.current=jr},[jr]),l.useEffect(()=>{if(ae.current)return;const f=La(b);f&&(q(f),xe.current=!0,ae.current=!0,Jl=!0)},[b]),l.useEffect(()=>{Ro(dn),un(dn),ds(!1)},[dn]);const lr=l.useCallback((f,v,y={})=>{!v||typeof D!="function"||D({type:f,requestId:v,payload:{...y,clientId:R||null}})},[R,D]),Li=l.useCallback((f,v=null)=>{if(!Tr(f?.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),lr("integration.error",v,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(ky(f.mode)===Oa){const K=wy(Ri.current,f.context);if(!K){console.warn("[DynamicContext] Ignored invalid append context payload."),lr("integration.error",v,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Ro(K),un(K),ds(!1),lr("integration.ack",v,{accepted:!0,applied:!0});return}const _=Kl(f.context);if(!_){lr("integration.error",v,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Ro(_),un(_),ds(!1),lr("integration.ack",v,{accepted:!0,applied:!0})},[lr]),Oi=l.useCallback((f,v=null)=>{if(typeof f?.prompt!="string"){lr("integration.error",v,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const y=La(f.prompt);if(q(y),xe.current=!0,f.autoSend===!0&&y&&ke.current&&!O.current&&Pn.current){const _={preventDefault:()=>{}};Pn.current(_,y)}lr("integration.ack",v,{accepted:!0,applied:!0})},[lr]),Fi=l.useCallback((f=null)=>{lr("integration.ack",f,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,lr]);l.useEffect(()=>{if(!B?.__messageSeq)return;const v=B?.type;if(v==="integration.context.update"){Li(B.payload||{},B.requestId||null);return}if(v==="integration.prompt.update"){Oi(B.payload||{},B.requestId||null);return}v==="integration.ping"&&Fi(B.requestId||null)},[Li,Oi,B,Fi]);const er=l.useMemo(()=>cs||!jr||!gy(jr)?null:jr,[cs,jr]),dp=l.useMemo(()=>er?.selectedElements?.length?er.selectedElements.slice(0,ql):[],[er]),Po=l.useMemo(()=>er?.selectedElements?.length?er.selectedElements.slice(ql):[],[er]),up=l.useCallback(()=>{un(f=>!f||!br(f.systemContext)?f:{...f,systemContext:""})},[]),pp=l.useCallback(()=>{un(f=>!f||!br(bn(f.currentFile))?f:{...f,currentFile:{path:"",displayName:""}})},[]),mp=l.useCallback(f=>{un(v=>{if(!v||!Array.isArray(v.selectedElements)||v.selectedElements.length===0)return v;const y=v.selectedElements.findIndex(_=>_.tag===f.tag&&_.selector===f.selector&&_.label===f.label);return y<0?v:{...v,selectedElements:v.selectedElements.filter((_,K)=>K!==y)}})},[]);l.useEffect(()=>{if(t?.id){const f=localStorage.getItem(`permissionMode-${t.id}`);f&&Br.modes.includes(f)?tt(f):tt(Br.defaultMode)}},[t?.id,Br]),l.useEffect(()=>{Br.modes.includes(Oe)||tt(Br.defaultMode)},[Oe,Br]),l.useEffect(()=>{if(!Jr.enabled){Kr!==Jr.defaultMode&&ss(Jr.defaultMode);return}Jr.modes.includes(Kr)||ss(Jr.defaultMode)},[Jr,Kr]),l.useEffect(()=>{if(t&&t.__provider&&t.__provider!==me){const f=nr(t.__provider);ki(f),localStorage.setItem("selected-provider",f)}if(t?.id&&t?.__provider)try{const f=localStorage.getItem("session-provider-map"),v=f?JSON.parse(f):{};v[t.id]!==t.__provider&&(v[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify(v)))}catch{}},[t]),l.useEffect(()=>{Pi.current!==me&&(dt([]),Pi.current=me)},[me]),l.useEffect(()=>{dt(f=>f.filter(v=>!v.sessionId||v.sessionId===t?.id))},[t?.id]),l.useEffect(()=>{(async()=>{if(e)try{const v=await le("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!v.ok)throw new Error("Failed to fetch commands");const y=await v.json(),_=[...(y.builtIn||[]).map(we=>({...we,type:"built-in"})),...(y.custom||[]).map(we=>({...we,type:"custom"}))];xo(_);const K=`command_history_${e.name}`,ce=At.getItem(K);if(ce)try{const we=JSON.parse(ce),ze=_.sort((Fe,xt)=>{const _t=we[Fe.name]||0;return(we[xt.name]||0)-_t});xo(ze)}catch(we){console.error("Error parsing command history:",we)}}catch(v){console.error("Error fetching slash commands:",v),xo([])}})()},[e]);const Lo=l.useMemo(()=>Pr.length?new _n(Pr,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Pr]);l.useEffect(()=>{if(!ns){vo(Pr);return}if(!Lo){vo([]);return}const f=Lo.search(ns);vo(f.map(v=>v.item))},[ns,Pr,Lo]);const fp=l.useMemo(()=>{if(!e||Pr.length===0)return[];const f=`command_history_${e.name}`,v=At.getItem(f);if(!v)return[];try{const y=JSON.parse(v);return Pr.map(K=>({...K,usageCount:y[K.name]||0})).filter(K=>K.usageCount>0).sort((K,ce)=>ce.usageCount-K.usageCount).slice(0,5)}catch(y){return console.error("Error parsing command history:",y),[]}},[e,Pr]),hp=l.useCallback((f,v,y)=>{if(!f||!e)return;if(y){Fr(v);return}const _=`command_history_${e.name}`,K=At.getItem(_);let ce={};try{ce=K?JSON.parse(K):{}}catch(we){console.error("Error parsing command history:",we)}ce[f.name]=(ce[f.name]||0)+1,At.setItem(_,JSON.stringify(ce)),$i(f)},[e]),gp=l.useCallback(f=>{const{action:v,data:y}=f;switch(v){case"clear":ue([]),qe([]);break;case"help":ue(_=>[..._,{role:"assistant",content:y.content,timestamp:Date.now()}]);break;case"model":{const _=Object.entries(y.available||{}).filter(([,ce])=>Array.isArray(ce)&&ce.length>0).map(([ce,we])=>`**${ce.charAt(0).toUpperCase()+ce.slice(1)}**: ${we.join(", ")}`).join(`
|
|
284
|
-
|
|
285
|
-
`),K=y.current.provider==="opencode"?y.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";ue(ce=>[...ce,{role:"assistant",content:`**Current Model**: ${y.current.model}
|
|
286
|
-
|
|
287
|
-
**Available Models**:
|
|
288
|
-
|
|
289
|
-
${_}${K?`
|
|
290
|
-
|
|
291
|
-
${K}`:""}`,timestamp:Date.now()}])}break;case"cost":{const _=`**Token Usage**: ${y.tokenUsage.used.toLocaleString()} / ${y.tokenUsage.total.toLocaleString()} (${y.tokenUsage.percentage}%)
|
|
292
|
-
|
|
293
|
-
**Estimated Cost**:
|
|
294
|
-
- Input: $${y.cost.input}
|
|
295
|
-
- Output: $${y.cost.output}
|
|
296
|
-
- **Total**: $${y.cost.total}
|
|
297
|
-
|
|
298
|
-
**Model**: ${y.model}`;ue(K=>[...K,{role:"assistant",content:_,timestamp:Date.now()}]);break}case"status":{const _=`**System Status**
|
|
299
|
-
|
|
300
|
-
- Version: ${y.version}
|
|
301
|
-
- Uptime: ${y.uptime}
|
|
302
|
-
- Model: ${y.model}
|
|
303
|
-
- Provider: ${y.provider}
|
|
304
|
-
- Node.js: ${y.nodeVersion}
|
|
305
|
-
- Platform: ${y.platform}`;ue(K=>[...K,{role:"assistant",content:_,timestamp:Date.now()}]);break}case"memory":y.error?ue(_=>[..._,{role:"assistant",content:`⚠️ ${y.message}`,timestamp:Date.now()}]):(ue(_=>[..._,{role:"assistant",content:`📝 ${y.message}
|
|
306
|
-
|
|
307
|
-
Path: \`${y.path}\``,timestamp:Date.now()}]),y.exists&&a&&a(y.path));break;case"config":x&&x();break;case"rewind":y.error?ue(_=>[..._,{role:"assistant",content:`⚠️ ${y.message}`,timestamp:Date.now()}]):(ue(_=>_.slice(0,-y.steps*2)),ue(_=>[..._,{role:"assistant",content:`⏪ ${y.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",v)}},[a,x]),Pn=l.useRef(null),xp=l.useCallback(async(f,v)=>{const{content:y,hasBashCommands:_,hasFileIncludes:K}=f;if(_&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){ue(we=>[...we,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}q(y),setTimeout(()=>{if(Pn.current){const ce={preventDefault:()=>{}};Pn.current(ce)}},50)},[]),$i=l.useCallback(async f=>{if(!(!f||!e))try{const v=X.match(new RegExp(`${f.name}\\s*(.*)`)),y=v&&v[1]?v[1].trim().split(/\s+/):[],_={projectPath:e.path,projectName:e.name,sessionId:ee,provider:me,...Gt?{model:Gt}:{},tokenUsage:mr},K=await le("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:f.name,commandPath:f.path,args:y,context:_})});if(!K.ok)throw new Error("Failed to execute command");const ce=await K.json();ce.type==="builtin"?gp(ce):ce.type==="custom"&&await xp(ce,y),q(""),Rr(!1),$r(-1),Lr(""),Fr(-1)}catch(v){console.error("Error executing command:",v),ue(y=>[...y,{role:"assistant",content:`Error executing command: ${v.message}`,timestamp:Date.now()}])}},[X,e,ee,me,Ao,To,_o,Io,mr]),vp=l.useMemo(()=>{const f=new Map;return(v,y)=>{const _=`${v.length}-${y.length}-${v.slice(0,50)}`;if(f.has(_))return f.get(_);const K=yp(v,y);if(f.set(_,K),f.size>100){const ce=f.keys().next().value;f.delete(ce)}return K}},[]),Sr=l.useCallback(async(f,v,y=!1,_="claude",K=null)=>{if(!f||!v)return[];const ce=!y;ce?Et(!0):kt(!0);try{const we=K??(y?ye.current:0),ze=N,Fe=await mt.sessionEvents(_,v,f,ze,oe,we);if(!Fe.ok)throw new Error("Failed to load session messages");const xt=await Fe.json();if(ce&&xt.tokenUsage&&Or(xt.tokenUsage),xt.hasMore!==void 0){St(xt.hasMore),Y(xt.total);const _t=we+(xt.events?.length||0);return ye.current=_t,Ve(_t),xt.events||[]}else{const _t=xt.events||xt.messages||[];return St(!1),Y(_t.length),ye.current=_t.length,Ve(_t.length),_t}}catch(we){return console.error("Error loading session messages:",we),[]}finally{ce?Et(!1):kt(!1)}},[N]),yp=(f,v)=>{const y=f.split(`
|
|
308
|
-
`),_=v.split(`
|
|
309
|
-
`),K=[];let ce=0,we=0;for(;ce<y.length||we<_.length;){const ze=y[ce],Fe=_[we];ce>=y.length?(K.push({type:"added",content:Fe,lineNum:we+1}),we++):we>=_.length?(K.push({type:"removed",content:ze,lineNum:ce+1}),ce++):ze===Fe?(ce++,we++):(K.push({type:"removed",content:ze,lineNum:ce+1}),K.push({type:"added",content:Fe,lineNum:we+1}),ce++,we++)}return K},bp=(f,v="claude")=>ju(f,v).map(y=>({...y,provider:y.provider||v})),Bt=t?.__provider||me||"claude",Bi=l.useMemo(()=>bp(Ke,Bt),[Ke,Bt]),zr=l.useCallback((f=[])=>{let v=null;for(const y of f)if(!(!y||typeof y!="object")){if(y.kind==="error"){v=ie.ERRORED;continue}if(y.kind==="session_state_changed"){const _=String(y.payload?.state||"").trim().toLowerCase();Object.values(ie).includes(_)&&(v=_);continue}if(y.kind==="approval_request"){v=ie.AWAITING_APPROVAL;continue}if(y.kind==="approval_resolved"){v=ie.STREAMING;continue}(y.kind==="assistant_text_start"||y.kind==="assistant_text_delta"||y.kind==="reasoning_start"||y.kind==="reasoning_delta"||y.kind==="tool_call_start"||y.kind==="tool_call_input"||y.kind==="tool_call_end"||y.kind==="tool_result"||y.kind==="system_notice")&&(v=ie.STREAMING)}return v},[]),us=l.useCallback((f=[])=>{const v=zr(f);return v===ie.COMPLETED||v===ie.ABORTED||v===ie.ERRORED?v:null},[zr]),zi=l.useCallback(f=>!(f===ie.COMPLETED||f===ie.ABORTED||f===ie.ERRORED),[]),pn=l.useCallback((f,v)=>v&&(Be(v),(v===ie.COMPLETED||v===ie.ABORTED||v===ie.ERRORED)&&(ft(f),bt(null),f&&(d&&d(f),p&&p(f))),v),[ft,d,p,Be]),Ui=l.useCallback(async(f,v)=>{const y=ke.current;if(!y?.name||!f)return null;const _=await Sr(y.name,f,!1,v||Bt);return Array.isArray(_)&&_.length>0&&qe(_),zr(_)},[Bt,zr,Sr]),Ur=l.useCallback(async(f,v)=>{const y=await Ui(f,v);return pn(f,y)},[Ui,pn]),Wi=l.useCallback((f,v=[])=>{const y=zr(v);return pn(f,y),y},[zr,pn]),Hi=l.useCallback((f,v)=>v===ie.COMPLETED||v===ie.ABORTED||v===ie.ERRORED?(pn(f,v),v):null,[pn]),Oo=l.useCallback((f,v)=>{if(!f)return;const y=J.current.get(f);y&&clearTimeout(y);const _=setTimeout(()=>{J.current.delete(f);const K=t?.id||ee||null;!K||K!==f||(Ur(f,v),s&&s({type:"check-session-status",sessionId:f,provider:v||Bt}))},1200);J.current.set(f,_)},[Bt,ee,Ur,t?.id,s]),Nr=l.useCallback(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[]),ps=l.useCallback(()=>{if(!j.current)return!1;const{scrollTop:f,scrollHeight:v,clientHeight:y}=j.current;return v-f-y<50},[]),ms=l.useCallback(async(f=null)=>{const v=f||j.current;if(!v||ve.current||Xe||!jt||!t||!e)return!1;const y=t.__provider||me||"claude";ve.current=!0;const _=v.scrollHeight,K=v.scrollTop,ce=ye.current;try{const we=await Sr(e.name,t.id,!0,y,ce);return we.length>0&&(U.current={height:_,top:K},qe(ze=>[...we,...ze])),!0}finally{ve.current=!1}},[jt,Xe,t,e,Sr,me]),fs=l.useCallback(async()=>{if(j.current){const f=j.current,v=ps();Dn(!v),f.scrollTop<100?ut.current||await ms(f)&&(ut.current=!0):ut.current=!1}},[ps,ms]);l.useLayoutEffect(()=>{if(!U.current||!j.current)return;const{height:f,top:v}=U.current,y=j.current,K=y.scrollHeight-f;y.scrollTop=v+Math.max(K,0),U.current=null},[ge.length]),l.useEffect(()=>{(async()=>{if(t&&e){const v=t.__provider||nr(localStorage.getItem("selected-provider"));F.current=!0,sessionStorage.removeItem("pendingSessionId");const y=ee!==null&&ee!==t.id;let _=null;if(y?(Ee||(W(),ft(),se.current=null,ue([]),qe([]),bt(null),Qe(!1)),ye.current=0,Ve(0),St(!1),Y(0),Or(null),Ye(!1)):ee===null&&(ye.current=0,Ve(0),St(!1),Y(0)),Ne(t.id),Ee)Ae(!1);else{const K=await Sr(e.name,t.id,!1,t.__provider||v||"claude");qe(K),_=Wi(t.id,K),_||Be(ie.IDLE),n&&s&&zi(_)&&s({type:"check-session-status",sessionId:t.id,provider:v})}}else{const y=se.current?.sessionId||null||O.current&&(ee||vt.current.sessionId)||null,_=!!(y||O.current);Ee||_||(W(),ft(),se.current=null,ue([]),qe([]),bt(null),Qe(!1),Ye(!1)),Ne(y),ye.current=0,Ve(0),St(!1),Y(0),Or(null)}setTimeout(()=>{F.current=!1},250)})()},[t?.id,t?.__provider,e?.name,e?.fullPath,e?.path,Sr,Nr,Ee,W,ft,Wi,s,Be,zi,n]),l.useEffect(()=>{const f=Q.current;if(M<=f||(Q.current=M,!t||!e))return;(async()=>{try{const y=t.__provider||nr(localStorage.getItem("selected-provider")),_=await Sr(e.name,t.id,!1,t.__provider||y||"claude");qe(_),A&&ps()&&setTimeout(()=>Nr(),200)}catch(y){console.error("Error reloading messages from external update:",y)}})()},[M,t,e,Sr,ps,A,Nr]),l.useEffect(()=>{Q.current=M},[M,e?.name,t?.id]),l.useEffect(()=>{t?.id&&(se.current=null)},[t?.id]),l.useEffect(()=>{const f=t?.id||ee||null,v=vt.current,y=!!(v.startedAt&&(!v.sessionId||!f||v.sessionId===f)&&de!==ie.IDLE);ue(_=>zv(_,Bi,{preserveLocalTail:y}))},[Bi,ee,de,t?.id,ue]),l.useEffect(()=>{i&&i(lt)},[lt,i]),l.useEffect(()=>{e&&X!==""?At.setItem(`draft_input_${e.name}`,X):e&&X===""&&At.removeItem(`draft_input_${e.name}`)},[X,e]),l.useEffect(()=>{e&&ge.length>0&&At.setItem(`chat_messages_${e.name}`,JSON.stringify(la(ge)))},[ge,e]),l.useEffect(()=>{const f=la(ge);Cy(ge,f)||ue(f)},[ge,ue]),l.useEffect(()=>{if(e){if(xe.current){xe.current=!1;return}const f=At.getItem(`draft_input_${e.name}`)||"";f!==X&&q(f)}},[e?.name]),l.useEffect(()=>{ee&&H&&u&&u(ee)},[H,ee,u]),l.useEffect(()=>{if(ee&&m){const f=m.has(ee),v=us(Ke);if(f&&v){p&&p(ee);return}f&&!H&&de!==ie.COMPLETED&&de!==ie.ABORTED&&de!==ie.ERRORED&&Be(ie.STREAMING,{canAbortSession:!0})}},[ee,us,H,p,m,de,Ke]),l.useEffect(()=>{if(o){const f=o.data?.message||o.data,y=["projects_updated","session-created"].includes(o.type),_=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),ce=o.type==="claude-response"&&f&&f.type==="system"&&f.subtype==="init"?f?.session_id:null,we=sessionStorage.getItem("pendingSessionId");let ze=t?.id||ee||se.current?.sessionId||null;const Fe=ce&&(!ze||ce===ze),xt=y||Fe,_t=!o.sessionId&&se.current&&!se.current.sessionId&&(/error/i.test(o.type||"")||o.type==="conversation-event"&&o.event?.kind==="error"),Ze=Ue=>{Ue&&(d&&d(Ue),p&&p(Ue))};if(!xt){if(!ze&&o.sessionId&&!Ds(o.sessionId)&&se.current&&!se.current.sessionId&&(ze=o.sessionId,se.current.sessionId=o.sessionId,Ne(o.sessionId)),!ze&&(o.sessionId&&_.has(o.type)&&Ze(o.sessionId),!_t)||!o.sessionId&&!_t)return;if(!_t&&o.sessionId!==ze){const Ue=Ds(ze),pt=!!(o.sessionId&&we&&o.sessionId===we);if(Ue&&(pt||!Ds(o.sessionId||"")))Ne(o.sessionId),se.current&&(se.current.sessionId=o.sessionId);else{o.sessionId&&_.has(o.type)&&Ze(o.sessionId),console.log("??-?,? Skipping message for different session:",o.sessionId,"current:",ze);return}}}const gs=o?.event?.sessionId||o.sessionId||ze||null,tr=!!(gs&&E.current.has(gs));if(o.type==="conversation-event"&&o.event){const Ue=o.event.sessionId||o.sessionId||ze||null,pt=o.event.rawRef?.type||null,rr=o.event.kind==="session_state_changed"?String(o.event.payload?.state||"").trim().toLowerCase():"";if(Ue&&E.current.add(Ue),rr==="idle"&&qt(Ue,pt)){Oo(Ue,o.event.provider||Bt);return}if(!!(Ue&&(Ue===(t?.id||null)||Ue===(ee||null)||Ue===(se.current?.sessionId||null)))&&Nt(o.event),Lt(o.event,o.event.provider||Bt),o.event.kind==="approval_request"&&Be(ie.AWAITING_APPROVAL),o.event.kind==="approval_resolved"&&Be(ie.STREAMING),(o.event.kind==="assistant_text_start"||o.event.kind==="assistant_text_delta"||o.event.kind==="reasoning_start"||o.event.kind==="reasoning_delta"||o.event.kind==="tool_call_start"||o.event.kind==="tool_call_input"||o.event.kind==="tool_call_end"||o.event.kind==="tool_result")&&Be(ie.STREAMING),(o.event.kind==="error"||o.event.payload?.state==="errored")&&(ft(Ue),Be(ie.ERRORED),bt(null),Ue&&(Ze(Ue),Ur(Ue,o.event.provider||Bt))),o.event.kind==="session_state_changed"){const Kt=rr;Kt==="streaming"?(Be(ie.STREAMING),Ue&&u&&u(Ue)):Kt==="awaiting_approval"?(Be(ie.AWAITING_APPROVAL),Ue&&u&&u(Ue)):Kt==="completed"?(ft(Ue),Be(ie.COMPLETED),bt(null),Ue&&(Ze(Ue),Ur(Ue,o.event.provider||Bt))):Kt==="aborted"?(ft(Ue),Be(ie.ABORTED),bt(null),Ue&&(Ze(Ue),Ur(Ue,o.event.provider||Bt))):Kt==="errored"&&(ft(Ue),Be(ie.ERRORED),bt(null),Ue&&(Ze(Ue),Ur(Ue,o.event.provider||Bt)))}return}switch(o.type){case"ws-connection-state":o.state==="connecting"&&(de===ie.QUEUED||H)?Be(ie.CONNECTING,{canAbortSession:!1}):o.state==="connected"&&de===ie.CONNECTING&&Be(ie.QUEUED);break;case"connection-error":Be(ie.ERRORED),bt(null),ue(V=>[...V,{type:"error",content:o.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":Be(ie.ERRORED),Qe(!1),bt(null),ue(V=>[...V,{type:"error",content:o.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(o.sessionId){const V=nr(o.provider||Bt),pe=se.current?.sessionId||ee||null,_e=Ds(o.sessionId);if(!(!ee||V==="codex"&&o.sessionId!==ee)||_e)break;sessionStorage.setItem("pendingSessionId",o.sessionId);try{const et=localStorage.getItem("session-provider-map"),st=et?JSON.parse(et):{};st[o.sessionId]=V,localStorage.setItem("session-provider-map",JSON.stringify(st))}catch{}se.current&&(se.current.sessionId=o.sessionId),Ne(o.sessionId),rt(o.sessionId),u&&u(o.sessionId),Ae(!0),h&&h(o.sessionId,pe),dt(et=>et.map(st=>st.sessionId?st:{...st,sessionId:o.sessionId})),g&&g(o.sessionId),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":o.data&&Or(o.data);break;case"claude-response":const Ue=tr&&!(o.data?.type==="system"&&o.data?.subtype==="init");if(!Ue&&f&&typeof f=="object"&&f.type){if(f.type==="content_block_delta"&&f.delta?.text){const V=Qr(f.delta.text);ot.current+=V,L.current||(L.current=setTimeout(()=>{const pe=ot.current;ot.current="",L.current=null,pe&&ue(_e=>{const He=[..._e],et=He[He.length-1];return et&&et.type==="assistant"&&!et.isToolUse&&et.isStreaming?et.content=(et.content||"")+pe:He.push({type:"assistant",content:pe,timestamp:new Date,isStreaming:!0}),He})},100));return}if(f.type==="content_block_stop"){L.current&&(clearTimeout(L.current),L.current=null);const V=ot.current;ot.current="",V&&ue(pe=>{const _e=[...pe],He=_e[_e.length-1];return He&&He.type==="assistant"&&!He.isToolUse&&He.isStreaming?He.content=(He.content||"")+V:_e.push({type:"assistant",content:V,timestamp:new Date,isStreaming:!0}),_e}),ue(pe=>{const _e=[...pe],He=_e[_e.length-1];return He&&He.type==="assistant"&&He.isStreaming&&(He.isStreaming=!1),_e});return}}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&ee&&o.data.session_id!==ee&&Fe){console.log("🔄 Claude CLI session duplication detected:",{originalSession:ee,newSession:o.data.session_id}),Ae(!0),g&&g(o.data.session_id);return}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&!ee&&Fe){console.log("🔄 New session init detected:",{newSession:o.data.session_id}),Ae(!0),g&&g(o.data.session_id);return}if(o.data.type==="system"&&o.data.subtype==="init"&&o.data.session_id&&ee&&o.data.session_id===ee&&Fe){console.log("🔄 System init message for current session, ignoring");return}if(Ue)break;if(Array.isArray(f.content)){for(const V of f.content)if(V.type==="tool_use"){const pe=V.input?JSON.stringify(V.input,null,2):"";ue(_e=>[..._e,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:V.name,toolInput:pe,toolId:V.id,toolResult:null}])}else if(V.type==="text"&&V.text?.trim()){let pe=Qr(V.text);pe=$a(pe),ue(_e=>[..._e,{type:"assistant",content:pe,timestamp:new Date}])}}else if(typeof f.content=="string"&&f.content.trim()){let V=Qr(f.content);V=$a(V),ue(pe=>[...pe,{type:"assistant",content:V,timestamp:new Date}])}if(f.role==="user"&&Array.isArray(f.content))for(const V of f.content)V.type==="tool_result"&&ue(pe=>pe.map(_e=>_e.isToolUse&&_e.toolId===V.tool_use_id?{..._e,toolResult:{content:V.content,isError:V.is_error,timestamp:new Date}}:_e));break;case"claude-output":if(tr)break;{const V=String(o.data||"");V.trim()&&(ot.current+=ot.current?`
|
|
310
|
-
${V}`:V,L.current||(L.current=setTimeout(()=>{const pe=ot.current;ot.current="",L.current=null,pe&&ue(_e=>{const He=[..._e],et=He[He.length-1];return et&&et.type==="assistant"&&!et.isToolUse&&et.isStreaming?et.content=et.content?`${et.content}
|
|
311
|
-
${pe}`:pe:He.push({type:"assistant",content:pe,timestamp:new Date,isStreaming:!0}),He})},100)))}break;case"claude-interactive-prompt":ue(V=>[...V,{type:"assistant",content:o.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(tr||me!=="claude"||!o.requestId)break;dt(V=>V.some(pe=>pe.requestId===o.requestId)?V:[...V,{requestId:o.requestId,toolName:o.toolName||"UnknownTool",input:o.input,context:o.context,sessionId:o.sessionId||null,receivedAt:new Date}]),Ye(!0),Qe(!0),bt(za({phaseText:z("activity.stage.waitingPermission"),detailText:o.toolName?z("activity.requestTool",{tool:Ic(o.toolName)}):z("activity.permission.title"),canAbort:!0}));break}case"claude-permission-cancelled":{if(tr||!o.requestId)break;dt(V=>{const pe=V.filter(_e=>_e.requestId!==o.requestId);return pe.length===0&&bt(null),pe});break}case"claude-error":if(tr)break;ft(o.sessionId||ee||null),Ye(!1),Qe(!1),bt(null),ue(V=>[...V,{type:"error",content:`出错了:${o.error}`,timestamp:new Date}]);break;case"claude-complete":if(tr)break;const pt=o.sessionId||ee||sessionStorage.getItem("pendingSessionId");ft(pt),(pt===ee||!ee)&&(Ye(!1),Qe(!1),bt(null)),pt&&(d&&d(pt),p&&p(pt));const rr=sessionStorage.getItem("pendingSessionId");rr&&!ee&&o.exitCode===0&&(Ne(rr),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",rr)),e&&o.exitCode===0&&At.removeItem(`chat_messages_${e.name}`),dt([]);break;case"codex-response":const $e=o.data;if($e){if(tr)break;if($e.type==="item_delta"&&$e.delta){const V=Qr(String($e.delta));if(V){const pe=`codex:${$e.itemType||"item"}:${$e.itemId||"unknown"}`;ue(_e=>{const He=[..._e];let et=-1;for(let st=He.length-1;st>=0;st--){const fr=He[st];if(fr?.codexItemKey===pe&&fr.type==="assistant"&&!fr.isToolUse){et=st;break}}if(et===-1)He.push({type:"assistant",content:V,timestamp:new Date,isStreaming:!0,isThinking:!!$e.isReasoning,codexItemKey:pe});else{const st=He[et],fr=st.content||"";fr.endsWith(V)||(st.content=fr+V),st.isStreaming=!0}return He})}break}if($e.type==="item_done"){const V=`codex:${$e.itemType||"item"}:${$e.itemId||"unknown"}`,pe=typeof $e.content=="string"?Qr($e.content):"";ue(_e=>{const He=[..._e];let et=-1;for(let st=He.length-1;st>=0;st--){const fr=He[st];if(fr?.codexItemKey===V&&fr.type==="assistant"&&!fr.isToolUse){et=st;break}}if(et!==-1){const st=He[et];pe&&pe!==(st.content||"")&&(st.content=pe),st.isStreaming=!1}else pe.trim()&&He.push({type:"assistant",content:pe,timestamp:new Date,isStreaming:!1,isThinking:!!$e.isReasoning});return He});break}if($e.type==="item")switch($e.itemType){case"agent_message":if($e.message?.content?.trim()){const V=Qr($e.message.content);ue(pe=>{const _e=pe[pe.length-1];return _e&&_e.type==="assistant"&&!_e.isToolUse&&!_e.isThinking&&(_e.content||"").trim()===V.trim()?pe:[...pe,{type:"assistant",content:V,timestamp:new Date}]})}break;case"reasoning":if($e.message?.content?.trim()){const V=Qr($e.message.content);ue(pe=>{const _e=pe[pe.length-1];return _e&&_e.type==="assistant"&&!_e.isToolUse&&_e.isThinking&&(_e.content||"").trim()===V.trim()?pe:[...pe,{type:"assistant",content:V,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":$e.command&&ue(V=>[...V,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:$e.command,toolResult:$e.output||null,exitCode:$e.exitCode}]);break;case"file_change":if($e.changes?.length>0){const V=$e.changes.map(pe=>`${pe.kind}: ${pe.path}`).join(`
|
|
312
|
-
`);ue(pe=>[...pe,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:V,toolResult:`Status: ${$e.status}`}])}break;case"mcp_tool_call":ue(V=>[...V,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${$e.server}:${$e.tool}`,toolInput:JSON.stringify($e.arguments,null,2),toolResult:$e.result?JSON.stringify($e.result,null,2):$e.error?.message||null}]);break;case"error":$e.message?.content&&ue(V=>[...V,{type:"error",content:$e.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",$e.itemType,$e)}$e.type==="turn_complete"&&Ye(!1),$e.type==="turn_failed"&&(Ye(!1),ue(V=>[...V,{type:"error",content:$e.error?.message||"Turn failed",timestamp:new Date}]))}break;case"codex-complete":if(tr)break;const Kt=o.sessionId||ee||sessionStorage.getItem("pendingSessionId");ft(Kt),(Kt===ee||!ee)&&(Ye(!1),Qe(!1),bt(null),ue(V=>V.map(pe=>pe?.codexItemKey&&pe.isStreaming?{...pe,isStreaming:!1}:pe))),Kt&&(d&&d(Kt),p&&p(Kt));const Ho=sessionStorage.getItem("pendingSessionId"),Zi=o.actualSessionId||Ho;Ho&&!ee&&(Ne(Zi),Ae(!0),g&&g(Zi),sessionStorage.removeItem("pendingSessionId"),console.log("Codex session complete, ID set to:",Ho)),e&&Kt&&Sr(e.name,Kt,!1,"codex").then(V=>{Array.isArray(V)&&V.length>0&&qe(V)}).catch(V=>{console.error("Error reloading Codex session after completion:",V)}),e&&At.removeItem(`chat_messages_${e.name}`);break;case"codex-error":if(tr)break;ft(o.sessionId||ee||null),Ye(!1),Qe(!1),ue(V=>V.map(pe=>pe?.codexItemKey&&pe.isStreaming?{...pe,isStreaming:!1}:pe)),ue(V=>[...V,{type:"error",content:o.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(tr)break;const V=o.sessionId||ee;ft(V),V===ee&&(Ye(!1),Qe(!1),bt(null)),V&&(d&&d(V),p&&p(V)),dt([]),ue(pe=>[...pe,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(tr)break;const V=o.sessionId,pe=o.provider||t?.__provider||Bt,_e=V===ee||t&&V===t.id,He=zr(Ke),et=us(Ke);if(_e&&o.isProcessing){if(et){Hi(V,et);break}Ye(!0),Qe(!0),u&&u(V)}else if(_e&&o.isProcessing===!1){if(qt(V,"session-status")){Oo(V,pe);break}Ur(V,pe).then(st=>{if(!(st===ie.COMPLETED||st===ie.ABORTED||st===ie.ERRORED)){if(He===ie.STREAMING||He===ie.AWAITING_APPROVAL){Be(He);return}Ye(!1),Qe(!1),bt(null)}})}break}case"claude-status":const Ht=o.data;if(Ht){let V={text:"Working...",tokens:0,can_interrupt:!0};Ht.message?V.text=Ht.message:Ht.status?V.text=Ht.status:typeof Ht=="string"&&(V.text=Ht),Ht.tokens?V.tokens=Ht.tokens:Ht.token_count&&(V.tokens=Ht.token_count),Ht.can_interrupt!==void 0&&(V.can_interrupt=Ht.can_interrupt),bt(Ay(Ht,z,bi.current)),Ye(!0),Qe(V.can_interrupt)}break}}},[Bt,Nt,ft,ee,zr,us,H,o,Ur,Hi,de,Oo,t,qt,rt,z]),l.useEffect(()=>{e&&wp()},[e]);const wp=async()=>{try{const f=await mt.getFiles(e.name);if(f.ok){const v=await f.json(),y=qi(v);nt(y)}}catch(f){console.error("Error fetching files:",f)}},qi=(f,v="")=>{let y=[];for(const _ of f){const K=v?`${v}/${_.name}`:_.name;_.type==="directory"&&_.children?y=y.concat(qi(_.children,K)):_.type==="file"&&y.push({name:_.name,path:K,relativePath:_.path})}return y};l.useEffect(()=>{const f=X.slice(0,Mn),v=f.lastIndexOf("@");if(v!==-1){const y=f.slice(v+1);if(y.includes(" "))gt(!1),rs(-1);else{rs(v),gt(!0);const _=yt.filter(K=>K.name.toLowerCase().includes(y.toLowerCase())||K.path.toLowerCase().includes(y.toLowerCase())).slice(0,10);qr(_),Ft(-1)}}else gt(!1),rs(-1)},[X,Mn,yt]);const Fo=l.useMemo(()=>!X||We.length===0?[]:We.filter(f=>X.includes(f)),[We,X]),Ln=l.useMemo(()=>Fo.length===0?[]:Array.from(new Set(Fo)).sort((v,y)=>y.length-v.length),[Fo]),$o=l.useMemo(()=>{if(Ln.length===0)return null;const f=Ln.map(ry).join("|");return new RegExp(`(${f})`,"g")},[Ln]),Vi=l.useMemo(()=>new Set(Ln),[Ln]),kp=l.useCallback(f=>f?$o?f.split($o).map((y,_)=>Vi.has(y)?r.jsx("span",{className:"bg-primary/20 -ml-0.5 dark:bg-primary/25 px-0.5 rounded-md box-decoration-clone text-transparent",children:y},`mention-${_}`):r.jsx("span",{children:y},`text-${_}`)):f:"",[$o,Vi]);l.useEffect(()=>{const f=setTimeout(()=>{te(X)},150);return()=>clearTimeout(f)},[X]);const mn=l.useMemo(()=>t||ge.length<=Rn?ge:ge.slice(-Rn),[ge,Rn,t]),jp=l.useMemo(()=>{const f=mn.map((y,_)=>({...y,__threadMessageId:ny(y,_)}));return f.length===0||!H||f.some(y=>y?.type!=="assistant"?!1:!!(y.isStreaming||y.isToolUse||y.isThinking||y.reasoning))?f:[...f,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:t?.__provider||me||"claude"}]},[mn,H,t?.__provider,me]);l.useMemo(()=>{if(!H||mn.length===0)return-1;for(let f=mn.length-1;f>=0;f--){const v=mn[f];if(v.type==="assistant"&&(v.isStreaming||v.isToolUse||v.isThinking||v.reasoning))return f}return-1},[mn,H]),l.useEffect(()=>{if(!A&&j.current){const f=j.current;ho.current={height:f.scrollHeight,top:f.scrollTop}}}),l.useEffect(()=>{if(j.current&&ge.length>0)if(A)fo||setTimeout(()=>Nr(),50);else{const f=j.current,v=ho.current.height,y=ho.current.top,K=f.scrollHeight-v;K>0&&y>0&&(f.scrollTop=y+K)}},[ge.length,fo,Nr,A]),l.useEffect(()=>{j.current&&ge.length>0&&!F.current&&(Dn(!1),setTimeout(()=>{Nr()},200))},[t?.id,e?.name]),l.useEffect(()=>{const f=j.current;if(f)return f.addEventListener("scroll",fs),()=>f.removeEventListener("scroll",fs)},[fs]),l.useEffect(()=>{if(G.current){G.current.style.height="auto",G.current.style.height=G.current.scrollHeight+"px";const f=parseInt(window.getComputedStyle(G.current).lineHeight),v=G.current.scrollHeight>f*2;Gr(v)}},[]),l.useEffect(()=>{G.current&&!X.trim()&&(G.current.style.height="auto",Gr(!1))},[X]),l.useEffect(()=>{if(!e||!t?.id||t.id.startsWith("new-session-")){Or(null);return}if((t.__provider||me||"claude")!=="claude")return;(async()=>{try{const y=`/api/projects/${e.name}/sessions/${t.id}/token-usage`,_=await le(y);if(_.ok){const K=await _.json();Or(K)}else Or(null)}catch(y){console.error("Failed to fetch initial token usage:",y)}})()},[t?.id,t?.__provider,e?.path]),l.useCallback(f=>{f.trim()&&q(v=>{const y=v.trim()?`${v} ${f}`:f;return setTimeout(()=>{if(G.current){G.current.style.height="auto",G.current.style.height=G.current.scrollHeight+"px";const _=parseInt(window.getComputedStyle(G.current).lineHeight),K=G.current.scrollHeight>_*2;Gr(K)}},0),y})},[]);const Sp=l.useCallback(()=>{tp(f=>f+100)},[]),Np=l.useCallback(()=>{ms()},[ms]),hs=l.useCallback(f=>{const v=f.filter(y=>{try{if(!y||typeof y!="object")return console.warn("Invalid file object:",y),!1;if(!y.type||!y.type.startsWith("image/"))return!1;if(!y.size||y.size>5242880){const _=y.name||"Unknown file";return Rt(K=>{const ce=new Map(K);return ce.set(_,"File too large (max 5MB)"),ce}),!1}return!0}catch(_){return console.error("Error validating file:",_,y),!1}});v.length>0&&ht(y=>[...y,...v].slice(0,5))},[]),Cp=l.useCallback(async f=>{const v=Array.from(f.clipboardData.items);for(const y of v)if(y.type.startsWith("image/")){const _=y.getAsFile();_&&hs([_])}if(v.length===0&&f.clipboardData.files.length>0){const _=Array.from(f.clipboardData.files).filter(K=>K.type.startsWith("image/"));_.length>0&&hs(_)}},[hs]),{getRootProps:Ep,getInputProps:Ip,isDragActive:Ap,open:Tp}=cu({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:hs,noClick:!0,noKeyboard:!0}),Xr=l.useCallback(async(f,v=null)=>{f.preventDefault();const y=typeof v=="string"?v:X,_=t?.__provider||me||"claude";if((No[_]?.status||Ms)===ia||!y.trim()||H||!e)return;let ce=y;const we=Ul(_),ze=we.enabled?Nm.find(pt=>pt.id===Kr):null;we.strategy==="prompt-prefix"&&ze&&ze.prefix&&(ce=`${ze.prefix}: ${y}`);const Fe=!cs&&hy(jr)?jy(jr):null;Fe&&(ce=Sy(Fe,ce)),Be(ie.QUEUED),bt(za({phaseText:z("activity.stage.generatingReply"),detailText:z("activity.detail.preparingReply"),canAbort:!0}));let xt=[];if(It.length>0){if(!Ov(_)){Be(ie.IDLE),Qe(!1),bt(null),ue(pt=>[...pt,{type:"error",content:`${_} 当前不支持图片输入`,timestamp:new Date}]);return}try{xt=await Yv(It)}catch(pt){console.error("Image preparation failed:",pt),Be(ie.IDLE),Qe(!1),bt(null),ue(rr=>[...rr,{type:"error",content:`图片处理失败:${pt.message}`,timestamp:new Date}]);return}}const _t={type:"user",content:y,images:xt,timestamp:new Date};ue(pt=>[...pt,_t]),Dn(!1),setTimeout(()=>Nr(),100);const Ze=ee||t?.id;$t(Ze||t?.id||null),Ze&&Nt(zt({kind:"user_message",provider:_,sessionId:Ze,timestamp:_t.timestamp,payload:{text:y}}));const gs=Ze||`new-session-${Date.now()}`;!Ze&&!t?.id&&(se.current={sessionId:null,startedAt:Date.now()}),c&&c(gs);const Ue=(()=>{try{const pt=me==="codex"?"codex-settings":"claude-settings",rr=At.getItem(pt);if(rr)return JSON.parse(rr)}catch(pt){console.error("Error loading tools settings:",pt)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(_==="codex"){const pt=we.enabled&&we.strategy==="native-effort"?Fv(Kr):void 0;s({type:"codex-command",command:ce,sessionId:Ze,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Ze,resume:!!Ze,permissionMode:Oe==="plan"?"default":Oe,...Gt?{model:Gt}:{},...pt?{modelReasoningEffort:pt}:{},images:xt}})}else s(_==="gemini"?{type:"gemini-command",command:ce,sessionId:Ze,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Ze,resume:!!Ze,permissionMode:Oe==="plan"?"default":Oe,...Gt?{model:Gt}:{}}}:_==="opencode"?{type:"opencode-command",command:ce,sessionId:Ze,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Ze,resume:!!Ze,permissionMode:Oe==="plan"?"default":Oe,...Gt?{model:Gt}:{}}}:{type:"claude-command",command:ce,options:{projectPath:e.path,cwd:e.fullPath,sessionId:Ze,resume:!!Ze,toolsSettings:Ue,permissionMode:Oe,...Gt?{model:Gt}:{},images:xt}});Fe&&ds(!0),q(""),ht([]),Vt(new Map),Rt(new Map),Gr(!1),ss("none"),G.current&&(G.current.style.height="auto"),e&&At.removeItem(`draft_input_${e.name}`)},[X,H,e,It,ee,t,me,No,Oe,c,Io,Ao,To,_o,s,q,ht,Vt,Rt,Gr,G,ue,Ye,Qe,bt,Dn,Nr,Kr,jr,cs,$t,Nt]),Gi=l.useCallback(f=>!f||me!=="claude"?{success:!1}:Iy(f.entry),[me]),Bo=l.useCallback((f,v)=>{const _=(Array.isArray(f)?f:[f]).filter(Boolean);_.length!==0&&(_.forEach(K=>{s({type:"claude-permission-response",requestId:K,allow:!!v?.allow,updatedInput:v?.updatedInput,message:v?.message,rememberEntry:v?.rememberEntry})}),dt(K=>{const ce=K.filter(we=>!_.includes(we.requestId));return ce.length===0&&bt(null),ce}))},[s]);l.useEffect(()=>{Pn.current=Xr},[Xr]);const Ki=f=>{if(!f)return;const v=X.slice(0,yi),y=X.slice(yi),_=y.indexOf(" "),K=_!==-1?y.slice(_):"",ce=v+f.name+" "+K;q(ce),Rr(!1),$r(-1),Lr(""),Fr(-1),he.current&&clearTimeout(he.current),$i(f)},_p=f=>{if(go&&Vr.length>0){if(f.key==="ArrowDown"){f.preventDefault(),Fr(v=>v<Vr.length-1?v+1:0);return}if(f.key==="ArrowUp"){f.preventDefault(),Fr(v=>v>0?v-1:Vr.length-1);return}if(f.key==="Tab"||f.key==="Enter"){f.preventDefault(),yo>=0?Ki(Vr[yo]):Vr.length>0&&Ki(Vr[0]);return}if(f.key==="Escape"){f.preventDefault(),Rr(!1),$r(-1),Lr(""),Fr(-1),he.current&&clearTimeout(he.current);return}}if(Je&&Ct.length>0){if(f.key==="ArrowDown"){f.preventDefault(),Ft(v=>v<Ct.length-1?v+1:0);return}if(f.key==="ArrowUp"){f.preventDefault(),Ft(v=>v>0?v-1:Ct.length-1);return}if(f.key==="Tab"||f.key==="Enter"){f.preventDefault(),pr>=0?zo(Ct[pr]):Ct.length>0&&zo(Ct[0]);return}if(f.key==="Escape"){f.preventDefault(),gt(!1);return}}if(f.key==="Tab"&&!Je&&!go){f.preventDefault();const v=Br.modes,_=(v.indexOf(Oe)+1)%v.length,K=v[_];tt(K),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,K);return}if(f.key==="Enter"){if(f.nativeEvent.isComposing)return;(f.ctrlKey||f.metaKey)&&!f.shiftKey?(f.preventDefault(),Xr(f)):!f.shiftKey&&!f.ctrlKey&&!f.metaKey&&(w||(f.preventDefault(),Xr(f)))}},zo=f=>{const v=X.slice(0,vi),y=X.slice(vi),_=y.indexOf(" "),K=_!==-1?y.slice(_):"",ce=v+f.path+" "+K,we=v.length+f.path.length+1;G.current&&!G.current.matches(":focus")&&G.current.focus(),q(ce),ts(we),Ot(ze=>ze.includes(f.path)?ze:[...ze,f.path]),gt(!1),rs(-1),G.current&&requestAnimationFrame(()=>{G.current&&(G.current.setSelectionRange(we,we),G.current.matches(":focus")||G.current.focus())})},Mp=f=>{const v=f.target.value,y=f.target.selectionStart;if(!ee&&v.trim(),q(v),ts(y),!v.trim()){f.target.style.height="auto",Gr(!1),Rr(!1),$r(-1),Lr("");return}const _=v.slice(0,y);if((_.match(/```/g)||[]).length%2===1){Rr(!1),$r(-1),Lr("");return}const we=/(^|\s)\/(\S*)$/,ze=_.match(we);if(ze){const Fe=ze.index+ze[1].length,xt=ze[2];$r(Fe),Rr(!0),Fr(-1),he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{Lr(xt)},150)}else Rr(!1),$r(-1),Lr(""),he.current&&clearTimeout(he.current)},Ji=l.useCallback(f=>{!fe.current||!f||(fe.current.scrollTop=f.scrollTop,fe.current.scrollLeft=f.scrollLeft)},[]),Dp=f=>{ts(f.target.selectionStart)},Rp=()=>{ee&&Le&&s({type:"abort-session",sessionId:ee,provider:me})};if(!e)return r.jsx("div",{className:"flex h-full items-center justify-center px-4 py-8 sm:px-6",children:r.jsxs("div",{className:"max-w-lg px-8 py-10 text-center text-muted-foreground",children:[r.jsx("div",{className:"mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-3xl bg-primary/10 text-primary",children:r.jsx(Hn,{className:"h-7 w-7"})}),r.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})});const Cr=t?.__provider||me||"claude",Uo=No[Cr],Wo=(Uo?.status||Ms)===ia,Pp=Uo?.reason||ap[Cr]||null,Yi=Uo?.installHint||null,Xi=!!op[Cr],fn=H||Wo,hn=W0({status:bo,messages:ge,pendingPermissionRequests:$,t:z}),Lp=H&&!!hn,Op=Cr==="opencode"?"OpenCode":z(`messageTypes.${Cr}`),Qi=z("input.providerNotInstalledWithName",{provider:Op}),Fp=me==="codex"?"Codex":me==="gemini"?"Gemini":me==="opencode"?"OpenCode":"Claude",$p=ge.length===0?null:r.jsxs(r.Fragment,{children:[Xe&&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:z("session.loading.olderMessages")})]})}),jt&&!Xe&&r.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:Dt>0&&r.jsxs("span",{children:[z("session.messages.showingOf",{shown:Ke.length,total:Dt})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:Np,children:z("session.messages.loadEarlier")}),r.jsx("span",{className:"ml-1 text-xs",children:z("session.messages.scrollToLoad")})]})}),!t&&!jt&&ge.length>Rn&&r.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[z("session.messages.showingLast",{count:Rn,total:ge.length})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:Sp,children:z("session.messages.loadEarlier")})]})]}),Bp=ge.length===0?null:r.jsx(r.Fragment,{children:$.map(f=>{const v=Yl(f.input),y=Ba(f.toolName,v),_=pi(),K=y?_.allowedTools.includes(y):!1,ce=y?$.filter(we=>Ba(we.toolName,Yl(we.input))===y).map(we=>we.requestId):[f.requestId];return r.jsx(H0,{request:f,permissionEntry:y,alreadyAllowed:K,rawInput:v,className:"mx-1 my-3 sm:mx-0",onAllowOnce:()=>Bo(f.requestId,{allow:!0}),onAllowRemember:()=>{y&&!K&&Gi({entry:y,toolName:f.toolName}),Bo(ce,{allow:!0,rememberEntry:y})},onDeny:()=>Bo(f.requestId,{allow:!1,message:z("activity.permission.deniedMessage")})},f.requestId)})});return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
313
|
-
details[open] .details-chevron {
|
|
314
|
-
transform: rotate(180deg);
|
|
315
|
-
}
|
|
316
|
-
`}),r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:ct&&ge.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:z("session.loading.sessionMessages")})]})}):ge.length===0?r.jsxs("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:[!t&&!ee&&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:z("providerSelection.title")}),r.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:z("providerSelection.description")}),r.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:[r.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{ls("claude")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${me==="claude"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(es,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left",children:r.jsx("p",{className:"text-base font-medium text-foreground",children:"Claude Code"})})]})}),r.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{ls("codex")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${me==="codex"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ao,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left",children:r.jsx("p",{className:"text-base font-medium text-foreground",children:"Codex"})})]})}),r.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{ls("gemini")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${me==="gemini"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(io,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left",children:r.jsx("p",{className:"text-base font-medium text-foreground",children:"Gemini"})})]})}),r.jsx("button",{onMouseDown:f=>f.preventDefault(),onClick:()=>{ls("opencode")},className:`group relative w-full h-auto rounded-xl px-3 py-3 transition-colors duration-150 ${me==="opencode"?"border-foreground bg-accent/70 text-foreground":"text-muted-foreground hover:bg-accent/40 hover:text-foreground"}`,children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(lo,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}),r.jsx("div",{className:"text-left",children:r.jsx("p",{className:"text-base font-medium text-foreground",children:"OpenCode"})})]})})]})]}),t&&r.jsxs("div",{className:"px-6 text-center text-muted-foreground sm:px-4",children:[r.jsx("p",{className:"mb-3 text-2xl font-semibold text-foreground",children:z("session.continue.title")}),r.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:z("session.continue.description")})]})]}):r.jsx(Cm,{messages:jp,convertMessage:Em,isRunning:H,scrollContainerRef:j,onScroll:fs,messagesEndRef:T,provider:me,providerLabel:Fp,createDiff:vp,onFileOpen:a,onShowSettings:x,onGrantToolPermission:Gi,showRawParameters:k,autoExpandTools:S,selectedProject:e,markdownRenderer:Fa,topContent:$p,bottomContent:Bp})}),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(Im,{phaseText:hn?.phaseText,detailText:hn?.detailText,elapsedSeconds:hn?.elapsedSeconds,startedAt:hn?.startedAt,canAbort:hn?.canAbort,isLoading:Lp,onAbort:Rp,provider:me})}),r.jsx("div",{ref:Me,className:"mx-auto mb-3 w-full max-w-4xl"}),r.jsxs("form",{onSubmit:Xr,className:"relative mx-auto w-full max-w-4xl",children:[fo&&ge.length>0&&r.jsx("button",{type:"button",onClick:Nr,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"})})}),Ap&&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:"将图片拖到这里"})]})}),It.length>0&&r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsx("div",{className:"flex flex-wrap gap-2",children:It.map((f,v)=>r.jsx(My,{file:f,onRemove:()=>{ht(y=>y.filter((_,K)=>K!==v))},uploadProgress:Qt.get(f.name),error:Zt.get(f.name)},v))})}),er&&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:[br(er.systemContext)&&r.jsx($n,{content:er.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:z("input.dynamicContext.systemChip")}),r.jsx("button",{type:"button",onClick:up,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:z("input.dynamicContext.removeSystem"),"aria-label":z("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"})})})]})}),br(bn(er.currentFile))&&r.jsx($n,{content:bn(er.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:my(er.currentFile)}),r.jsx("button",{type:"button",onClick:pp,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:z("input.dynamicContext.removeCurrentFile"),"aria-label":z("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"})})})]})}),dp.map((f,v)=>r.jsx($n,{content:Gl(f),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-normal break-words",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[min(22rem,calc(100vw-4rem))] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",title:f.selector,children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 15l2 5L7 17l3-10 10 3-5 2z"})}),r.jsx("span",{className:"truncate",children:f.tag||z("input.dynamicContext.elementFallback")}),r.jsx("button",{type:"button",onClick:()=>mp(f),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:z("input.dynamicContext.removeElement"),"aria-label":z("input.dynamicContext.removeElement"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},`${f.selector}-${v}`)),Po.length>0&&r.jsx($n,{content:Po.map(Gl).join(`
|
|
317
|
-
`),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:r.jsxs("div",{className:"inline-flex items-center gap-1 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-muted-foreground",children:["+",Po.length]})})]})}),Je&&Ct.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:Ct.map((f,v)=>r.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${v===pr?"bg-primary/10 dark:bg-primary/20 text-primary":"hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,onMouseDown:y=>{y.preventDefault(),y.stopPropagation()},onClick:y=>{y.preventDefault(),y.stopPropagation(),zo(f)},children:[r.jsx("div",{className:"font-medium text-sm",children:f.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:f.path})]},f.path))}),r.jsx(Tv,{commands:Vr,selectedIndex:yo,onSelect:hp,onClose:()=>{Rr(!1),$r(-1),Lr(""),Fr(-1)},position:{top:G.current?Math.max(16,G.current.getBoundingClientRect().top-316):0,left:G.current?G.current.getBoundingClientRect().left:16,bottom:G.current?window.innerHeight-G.current.getBoundingClientRect().top+8:90},isOpen:go,frequentCommands:ns?[]:fp}),r.jsxs("div",{...Ep(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${ep?"chat-input-expanded":""} ${lt?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[r.jsx("input",{...Ip()}),r.jsx("div",{ref:fe,"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:kp(X)})}),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:G,value:X,onChange:Mp,onClick:Dp,onKeyDown:_p,onPaste:Cp,onScroll:f=>Ji(f.target),onFocus:()=>Ge(!0),onBlur:()=>Ge(!1),onInput:f=>{f.target.style.height="auto",f.target.style.height=f.target.scrollHeight+"px",ts(f.target.selectionStart),Ji(f.target);const v=parseInt(window.getComputedStyle(f.target).lineHeight),y=f.target.scrollHeight>v*2;Gr(y)},placeholder:Wo?Qi:z("input.placeholder",{provider:Cr==="codex"?z("messageTypes.codex"):Cr==="gemini"?z("messageTypes.gemini"):Cr==="opencode"?"OpenCode":z("messageTypes.claude")}),disabled:fn,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"}})}),Wo&&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:Pp||Qi}),Yi&&r.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:Yi}),r.jsx("div",{className:"mt-2",children:r.jsx("button",{type:"button",onClick:()=>Eo(Cr,{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:Xi,children:z(Xi?"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:()=>{fn||Tp()},disabled:fn,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:z("input.attachImages"),children:[r.jsx(jn,{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:ko,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:r.jsxs(tl,{value:Gt||void 0,onValueChange:f=>{me==="claude"?Ci(f):me==="codex"?Ei(f):me==="gemini"?Ii(f):me==="opencode"&&Ai(f),Qv(me,f)},disabled:fn||is||cp,children:[r.jsx(rl,{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:[is&&r.jsx(Wn,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),r.jsx("span",{className:"truncate text-xs font-normal text-muted-foreground",children:is?z("input.loadingModels"):lp}),r.jsx(Ar,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(nl,{children:is?r.jsx(Go,{value:"__loading",disabled:!0,children:z("input.loadingModels")}):as.map(({value:f,label:v})=>r.jsx(Go,{value:f,children:v},f))})]})}),r.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:jo,children:r.jsxs(tl,{value:Oe,onValueChange:f=>{tt(f),t&&localStorage.setItem(`permissionMode-${t.id}`,f)},disabled:fn,children:[r.jsx(rl,{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:sp||ji||z("input.clickToChangeMode")}),r.jsx(Ar,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(nl,{children:r.jsxs(Am,{children:[r.jsx(Tm,{children:ji}),Br.modes.map(f=>r.jsx(Go,{value:f,children:So(f,{short:!0})},f))]})})]})}),Jr.enabled&&r.jsx(_m,{selectedMode:Kr,onModeChange:ss,className:"sm:flex-none"}),mr!==null&&r.jsxs("div",{className:"hidden cursor-help items-center gap-1.5 px-2 py-1.5 text-xs text-muted-foreground sm:flex",title:"Token Budget",children:[r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})}),r.jsx("span",{children:(()=>{if(typeof mr?.percentage=="number")return`${Math.min(100,Math.max(0,mr.percentage))}%`;if(typeof mr?.used=="number"&&typeof mr?.total=="number"&&mr.total>0){const f=Math.round(mr.used/mr.total*100);return`${Math.min(100,Math.max(0,f))}%`}return"0%"})()})]}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700 mx-1 hidden sm:block"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative group hidden sm:block",children:[r.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:z("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:z(w?"input.hintText.ctrlEnter":"input.hintText.enter")})})]}),r.jsx("button",{type:"submit",disabled:!X.trim()||fn,onMouseDown:f=>{f.preventDefault(),Xr(f)},onTouchStart:f=>{f.preventDefault(),Xr(f)},className:"flex h-9 w-9 items-center justify-center rounded-full bg-foreground text-background transition-colors hover:opacity-90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",children:r.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h12m-5-5 5 5-5 5"})})})]})]})]})]})]})]})]})]})}const Ry=Tn.memo(Dy);class Tt{constructor(t,n,s,o){this.fromA=t,this.toA=n,this.fromB=s,this.toB=o}offset(t,n=t){return new Tt(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}}function sn(e,t,n,s,o,a){if(e==s)return[];let i=fi(e,t,n,s,o,a),c=hi(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 Tt(t,n,o,a)];if(d>u){let m=e.slice(t,n).indexOf(s.slice(o,a));if(m>-1)return[new Tt(t,t+m,o,o),new Tt(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 Tt(t,t,o,o+m),new Tt(n,n,o+m+d,a)]}if(d==1||u==1)return[new Tt(t,n,o,a)];let p=Au(e,t,n,s,o,a);if(p){let[m,h,g]=p;return sn(e,t,m,s,o,h).concat(sn(e,m+g,n,s,h+g,a))}return Py(e,t,n,s,o,a)}let Bn=1e9,zn=0,mi=!1;function Py(e,t,n,s,o,a){let i=n-t,c=a-o;if(Bn<1e9&&Math.min(i,c)>Bn*16||zn>0&&Date.now()>zn)return Math.min(i,c)>Bn*64?[new Tt(t,n,o,a)]:Xl(e,t,n,s,o,a);let d=Math.ceil((i+c)/2);ca.reset(d),da.reset(d);let u=(g,x)=>e.charCodeAt(t+g)==s.charCodeAt(o+x),p=(g,x)=>e.charCodeAt(n-g-1)==s.charCodeAt(a-x-1),m=(i-c)%2!=0?da:null,h=m?null:ca;for(let g=0;g<d;g++){if(g>Bn||zn>0&&!(g&63)&&Date.now()>zn)return Xl(e,t,n,s,o,a);let x=ca.advance(g,i,c,d,m,!1,u)||da.advance(g,i,c,d,h,!0,p);if(x)return Ly(e,t,n,t+x[0],s,o,a,o+x[1])}return[new Tt(t,n,o,a)]}class Eu{constructor(){this.vec=[]}reset(t){this.len=t<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[t+1]=0,this.start=this.end=0}advance(t,n,s,o,a,i,c){for(let d=-t+this.start;d<=t-this.end;d+=2){let u=o+d,p=d==-t||d!=t&&this.vec[u-1]<this.vec[u+1]?this.vec[u+1]:this.vec[u-1]+1,m=p-d;for(;p<n&&m<s&&c(p,m);)p++,m++;if(this.vec[u]=p,p>n)this.end+=2;else if(m>s)this.start+=2;else if(a){let h=o+(n-s)-d;if(h>=0&&h<this.len&&a.vec[h]!=-1)if(i){let g=a.vec[h];if(g>=n-p)return[g,o+g-h]}else{let g=n-a.vec[h];if(p>=g)return[p,m]}}}return null}}const ca=new Eu,da=new Eu;function Ly(e,t,n,s,o,a,i,c){let d=!1;return!En(e,s)&&++s==n&&(d=!0),!En(o,c)&&++c==i&&(d=!0),d?[new Tt(t,n,a,i)]:sn(e,t,s,o,a,c).concat(sn(e,s,n,o,c,i))}function Iu(e,t){let n=1,s=Math.min(e,t);for(;n<s;)n=n<<1;return n}function fi(e,t,n,s,o,a){if(t==n||t==a||e.charCodeAt(t)!=s.charCodeAt(o))return 0;let i=Iu(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-(En(e,c)?0:1);i=i>>1}else{if(u==n||p==a)return u-t;c=u,d=p}}}function hi(e,t,n,s,o,a){if(t==n||o==a||e.charCodeAt(n-1)!=s.charCodeAt(a-1))return 0;let i=Iu(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-(En(e,c)?0:1);i=i>>1}else{if(u==t||p==o)return n-u;c=u,d=p}}}function Ua(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;;){En(e,p)||p++;let m=p+i;if(En(e,m)||(m+=m==p+1?1:-1),m>=n)break;let h=e.slice(p,m),g=-1;for(;(g=d.indexOf(h,g+1))!=-1;){let x=fi(e,m,n,s,o+g+h.length,a),S=hi(e,t,p,s,o,o+g),k=h.length+x+S;(!u||u[2]<k)&&(u=[p-S,o+g-S,k])}p=m}if(c<0)return u;i=i>>1}}function Au(e,t,n,s,o,a){let i=n-t,c=a-o;if(i<c){let d=Au(s,o,a,e,t,n);return d&&[d[1],d[0],d[2]]}return i<4||c*2<i?null:Ua(e,t,n,s,o,a,Math.floor(i/4),-1)}function Xl(e,t,n,s,o,a){mi=!0;let i=n-t,c=a-o,d;if(i<c){let h=Ua(s,o,a,e,t,n,Math.floor(i/6),50);d=h&&[h[1],h[0],h[2]]}else d=Ua(e,t,n,s,o,a,Math.floor(c/6),50);if(!d)return[new Tt(t,n,o,a)];let[u,p,m]=d;return sn(e,t,u,s,o,p).concat(sn(e,u+m,n,s,p+m,a))}function Tu(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 Tt(s.fromA,o.toA,s.fromB,o.toB),e.splice(n--,1))}}function Oy(e,t,n){for(;;){Tu(n,1);let s=!1;for(let o=0;o<n.length;o++){let a=n[o],i,c;(i=fi(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new Tt(a.fromA+i,a.toA,a.fromB+i,a.toB)),(c=hi(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new Tt(a.fromA,a.toA-c,a.fromB,a.toB-c));let d=a.toA-a.fromA,u=a.toB-a.fromB;if(d&&u)continue;let p=a.fromA-(o?n[o-1].toA:0),m=(o<n.length-1?n[o+1].fromA:e.length)-a.toA;if(!p||!m)continue;let h=d?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);p<=h.length&&e.slice(a.fromA-p,a.fromA)==h.slice(h.length-p)?(n[o]=new Tt(a.fromA-p,a.toA-p,a.fromB-p,a.toB-p),s=!0):m<=h.length&&e.slice(a.toA,a.toA+m)==h.slice(0,m)&&(n[o]=new Tt(a.fromA+m,a.toA+m,a.fromB+m,a.toB+m),s=!0)}if(!s)break}return n}function Fy(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=Zl(t,a.fromA,u),h=Ql(t,a.toA,p),g=a.fromA-m,x=h-a.toA;if((!i||!c)&&g&&x){let S=Math.max(i,c),[k,I,A]=i?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];S>g&&t.slice(m,a.fromA)==k.slice(A-g,A)?(a=e[o]=new Tt(m,m+i,a.fromB-g,a.toB-g),m=a.fromA,h=Ql(t,a.toA,d-a.toA)):S>x&&t.slice(a.toA,h)==k.slice(I,I+x)&&(a=e[o]=new Tt(h-i,h,a.fromB+x,a.toB+x),h=a.toA,m=Zl(t,a.fromA,a.fromA-s)),g=a.fromA-m,x=h-a.toA}if(g||x)a=e[o]=new Tt(a.fromA-g,a.toA+x,a.fromB-g,a.toB+x);else if(i){if(!c){let S=tc(t,a.fromA,a.toA),k,I=S<0?-1:ec(t,a.toA,a.fromA);S>-1&&(k=S-a.fromA)<=p&&t.slice(a.fromA,S)==t.slice(a.toA,a.toA+k)?a=e[o]=a.offset(k):I>-1&&(k=a.toA-I)<=u&&t.slice(a.fromA-k,a.fromA)==t.slice(I,a.toA)&&(a=e[o]=a.offset(-k))}}else{let S=tc(n,a.fromB,a.toB),k,I=S<0?-1:ec(n,a.toB,a.fromB);S>-1&&(k=S-a.fromB)<=p&&n.slice(a.fromB,S)==n.slice(a.toB,a.toB+k)?a=e[o]=a.offset(k):I>-1&&(k=a.toB-I)<=u&&n.slice(a.fromB-k,a.fromB)==n.slice(I,a.toB)&&(a=e[o]=a.offset(-k))}}s=a.toA}return Tu(e,3),e}let nn;try{nn=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function _u(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function Mu(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?_u(n)?1:0:nn?!Pu(n)||t==e.length-1?nn.test(String.fromCharCode(n))?1:0:nn.test(e.slice(t,t+2))?2:0:0}function Du(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?_u(n)?1:0:nn?!Lu(n)||t==1?nn.test(String.fromCharCode(n))?1:0:nn.test(e.slice(t-2,t))?2:0:0}const Ru=8;function Ql(e,t,n){if(t==e.length||!Du(e,t))return t;for(let s=t,o=t+n,a=0;a<Ru;a++){let i=Mu(e,s);if(!i||s+i>o)return s;s+=i}return t}function Zl(e,t,n){if(!t||!Mu(e,t))return t;for(let s=t,o=t-n,a=0;a<Ru;a++){let i=Du(e,s);if(!i||s-i<o)return s;s-=i}return t}function ec(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function tc(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}const Pu=e=>e>=55296&&e<=56319,Lu=e=>e>=56320&&e<=57343;function En(e,t){return!t||t==e.length||!Pu(e.charCodeAt(t-1))||!Lu(e.charCodeAt(t))}function $y(e,t,n){var s;return Bn=((s=n?.scanLimit)!==null&&s!==void 0?s:1e9)>>1,zn=n?.timeout?Date.now()+n.timeout:0,mi=!1,Oy(e,t,sn(e,0,e.length,t,0,t.length))}function Ou(){return!mi}function Fu(e,t,n){return Fy($y(e,t,n),e,t)}const Mr=Js.define({combine:e=>e[0]}),By=Ha.define(),$u=Js.define(),ar=Kn.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(By)&&(e=n.value);for(let n of t.state.facet($u))e=n(e,t);return e}});function ua(e){let t=e.field(ar,!1);if(!t)return null;let n=e.facet(Mr);return{chunks:t,side:n?n.side:null}}class wn{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 wn(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=Fu(t.toString(),n.toString(),s);return Bu(o,t,n,0,0,Ou())}static updateA(t,n,s,o,a){return ac(oc(t,o,!0,s.length),t,n,s,a)}static updateB(t,n,s,o,a){return ac(oc(t,o,!1,n.length),t,n,s,a)}}function rc(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 nc(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 Bu(e,t,n,s,o,a){let i=[];for(let c=0;c<e.length;c++){let d=e[c],[u,p]=rc(d.fromA+s,d.fromB+o,t,n),[m,h]=nc(d.toA+s,d.toB+o,t,n),g=[d.offset(-u+s,-p+o)];for(;c<e.length-1;){let x=e[c+1],[S,k]=rc(x.fromA+s,x.fromB+o,t,n);if(S>m+1&&k>h+1)break;g.push(x.offset(-u+s,-p+o)),[m,h]=nc(x.toA+s,x.toB+o,t,n),c++}i.push(new wn(g,u,Math.max(u,m),p,Math.max(p,h),a))}return i}const Rs=1e3;function sc(e,t,n,s){let o=0,a=e.length;for(;;){if(o==a){let p=0,m=0;o&&({toA:p,toB:m}=e[o-1]);let h=t-(n?p:m);return[p+h,m+h]}let i=o+a>>1,c=e[i],[d,u]=n?[c.fromA,c.toA]:[c.fromB,c.toB];if(d>t)a=i;else if(u<=t)o=i+1;else return s?[c.fromA,c.fromB]:[c.toA,c.toB]}}function oc(e,t,n,s){let o=[];return t.iterChangedRanges((a,i,c,d)=>{let u=0,p=n?t.length:s,m=0,h=n?s:t.length;a>Rs&&([u,m]=sc(e,a-Rs,n,!0)),i<t.length-Rs&&([p,h]=sc(e,i+Rs,n,!1));let g=d-c-(i-a),x,[S,k]=n?[g,0]:[0,g];o.length&&(x=o[o.length-1]).toA>=u?o[o.length-1]={fromA:x.fromA,fromB:x.fromB,toA:p,toB:h,diffA:x.diffA+S,diffB:x.diffB+k}:o.push({fromA:u,toA:p,fromB:m,toB:h,diffA:S,diffB:k})}),o}function ac(e,t,n,s,o){if(!e.length)return t;let a=[];for(let i=0,c=0,d=0,u=0;;i++){let p=i==e.length?null:e[i],m=p?p.fromA+c:n.length,h=p?p.fromB+d:s.length;for(;u<t.length;){let k=t[u];if(k.toA+c>m||k.toB+d>h)break;a.push(k.offset(c,d)),u++}if(!p)break;let g=p.toA+c+p.diffA,x=p.toB+d+p.diffB,S=Fu(n.sliceString(m,g),s.sliceString(h,x),o);for(let k of Bu(S,n,s,m,h,Ou()))a.push(k);for(c+=p.diffA,d+=p.diffB;u<t.length;){let k=t[u];if(k.fromA+c>g&&k.fromB+d>x)break;u++}}return a}const zy={scanLimit:500},zu=Ys.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=cc(e))}update(e){(e.docChanged||e.viewportChanged||Uy(e.startState,e.state)||Wy(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=cc(e.view))}},{decorations:e=>e.deco});function Uy(e,t){return e.field(ar,!1)!=t.field(ar,!1)}function Wy(e,t){return e.facet(Mr)!=t.facet(Mr)}const ic=Dr.line({class:"cm-changedLine"}),Uu=Dr.mark({class:"cm-changedText"}),Hy=Dr.mark({tagName:"ins",class:"cm-insertedLine"}),qy=Dr.mark({tagName:"del",class:"cm-deletedLine"}),lc=new class extends qa{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Vy(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,ic),o.add(i,c,n?qy:Hy),a&&a.add(i,i,lc);for(let u=t.iterRange(i,c-1),p=i;!u.next().done;){if(u.lineBreak){p++,o.add(p,p,ic),a&&a.add(p,p,lc);continue}let m=p+u.value.length;if(s)for(;d<e.changes.length;){let h=e.changes[d],g=i+(n?h.fromA:h.fromB),x=i+(n?h.toA:h.toB),S=Math.max(p,g),k=Math.min(m,x);if(S<k&&o.add(S,k,Uu),x<m)d++;else break}p=m}}}function cc(e){let t=e.state.field(ar),{side:n,highlightChanges:s,markGutter:o,overrideChunk:a}=e.state.facet(Mr),i=n=="a",c=new Ls,d=o?new Ls: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))&&Vy(m,e.state.doc,i,s,c,d)}return{deco:c.finish(),gutter:d&&d.finish()}}const Wa=Ha.define({map:(e,t)=>t.mapPos(e)});class Gy extends Va{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:Wa.of(o)});let{side:a,sibling:i}=t.state.facet(Mr);i&&i().dispatch({effects:Wa.of(Ky(o,t.state.field(ar),a=="a"))})}),n}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function Ky(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 Jy=Kn.define({create(e){return Dr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Wa)&&(e=e.update({filter:s=>s!=n.value}));return e},provide:e=>ur.decorations.from(e)});function Yy({margin:e=3,minSize:t=4}){return Jy.init(n=>Xy(n,e,t))}function Xy(e,t,n){let s=new Ls,o=e.facet(Mr).side=="a",a=e.field(ar),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,Dr.replace({widget:new Gy(m),block:!0})),!d)break;i=e.doc.lineAt(Math.min(e.doc.length,o?d.toA:d.toB)).number}return s.finish()}const Qy=ur.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"}}),Zy=new class extends qa{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},eb=kc.low(zp({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(zu))===null||t===void 0?void 0:t.gutter)||Wp.empty},widgetMarker:(e,t)=>t instanceof Wu?Zy:null}));function tb(e){var t;let n=typeof e.original=="string"?wc.of(e.original.split(/\r?\n/)):e.original,s=e.diffConfig||zy;return[kc.low(zu),ob,Qy,ur.editorAttributes.of({class:"cm-merge-b"}),$u.of((o,a)=>{let i=a.effects.find(c=>c.is(gi));return i&&(o=wn.updateA(o,i.value.doc,a.startState.doc,i.value.changes,s)),a.docChanged&&(o=wn.updateB(o,a.state.field(In),a.newDoc,a.changes,s)),o}),Mr.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?cb:void 0,side:"b"}),In.init(()=>n),e.gutter!==!1?eb:[],e.collapseUnchanged?Yy(e.collapseUnchanged):[],ar.init(o=>wn.build(n,o.doc,s))]}const gi=Ha.define(),In=Kn.define({create:()=>wc.empty,update(e,t){for(let n of t.effects)n.is(gi)&&(e=n.value.doc);return e}}),dc=new WeakMap;class Wu extends Va{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 rb(e,t,n){let s=dc.get(t.changes);if(s)return s;let o=i=>{let{highlightChanges:c,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:u,mergeControls:p}=e.facet(Mr),m=document.createElement("div");if(m.className="cm-deletedChunk",p){let M=m.appendChild(document.createElement("div"));M.className="cm-chunkButtons";let C=R=>{R.preventDefault(),nb(i,i.posAtDOM(m))},b=R=>{R.preventDefault(),sb(i,i.posAtDOM(m))};if(typeof p=="function")M.appendChild(p("accept",C)),M.appendChild(p("reject",b));else{let R=M.appendChild(document.createElement("button"));R.name="accept",R.textContent=e.phrase("Accept"),R.onmousedown=C;let B=M.appendChild(document.createElement("button"));B.name="reject",B.textContent=e.phrase("Reject"),B.onmousedown=b}}if(n||t.fromA>=t.toA)return m;let h=i.state.field(In).sliceString(t.fromA,t.endA),g=d&&e.facet(jc),x=A(),S=t.changes,k=0,I=!1;function A(){let M=m.appendChild(document.createElement("div"));return M.className="cm-deletedLine",M.appendChild(document.createElement("del"))}function w(M,C,b){for(let R=M;R<C;){if(h.charAt(R)==`
|
|
318
|
-
`){x.firstChild||x.appendChild(document.createElement("br")),x=A(),R++;continue}let B=C,D=b+(I?" cm-deletedText":""),Z=!1,z=h.indexOf(`
|
|
319
|
-
`,R);if(z>-1&&z<C&&(B=z),c&&k<S.length){let X=Math.max(0,I?S[k].toA:S[k].fromA);X<=B&&(B=X,I&&k++,Z=!0)}if(B>R){let X=document.createTextNode(h.slice(R,B));if(D){let q=x.appendChild(document.createElement("span"));q.className=D,q.appendChild(X)}else x.appendChild(X);R=B}Z&&(I=!I)}}if(g&&t.toA-t.fromA<=u){let M=g.parser.parse(h),C=0;fa(M,{style:b=>Sc(e,b)},(b,R,B)=>{b>C&&w(C,b,""),w(b,R,B),C=R}),w(C,h.length,"")}else w(0,h.length,"");return x.firstChild||x.appendChild(document.createElement("br")),m},a=Dr.widget({block:!0,side:-1,widget:new Wu(o)});return dc.set(t.changes,a),a}function nb(e,t){let{state:n}=e,s=t??n.selection.main.head,o=e.state.field(ar).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(In);o.fromB!=o.toB&&o.toA<=i.length&&(a+=e.state.lineBreak);let c=Up.of({from:o.fromA,to:Math.min(i.length,o.toA),insert:a},i.length);return e.dispatch({effects:gi.of({doc:c.apply(i),changes:c}),userEvent:"accept"}),!0}function sb(e,t){let{state:n}=e,s=t??n.selection.main.head,o=n.field(ar).find(c=>c.fromB<=s&&c.endB>=s);if(!o)return!1;let i=n.field(In).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 uc(e){let t=new Ls;for(let n of e.field(ar)){let s=e.facet(Mr).overrideChunk&&Hu(e,n);t.add(n.fromB,n.fromB,rb(e,n,!!s))}return t.finish()}const ob=Kn.define({create:e=>uc(e),update(e,t){return t.state.field(ar,!1)!=t.startState.field(ar,!1)?uc(t.state):e},provide:e=>ur.decorations.from(e)}),pc=new WeakMap;function Hu(e,t){let n=pc.get(t);if(n!==void 0)return n;n=null;let s=e.field(In),o=e.doc,a=s.lineAt(t.endA).number-s.lineAt(t.fromA).number+1,i=o.lineAt(t.endB).number-o.lineAt(t.fromB).number+1;e:if(a==i&&a<10){let c=[],d=0,u=t.fromA,p=t.fromB;for(let m of t.changes){if(m.fromA<m.toA){d+=m.toA-m.fromA;let h=s.sliceString(u+m.fromA,u+m.toA);if(/\n/.test(h))break e;c.push(Dr.widget({widget:new ab(h),side:-1}).range(p+m.fromB))}m.fromB<m.toB&&c.push(Uu.range(p+m.fromB,p+m.toB))}d<t.endA-t.fromA-a*2&&(n=c)}return pc.set(t,n),n}class ab extends Va{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 ib=new class extends qa{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},lb=Dr.line({class:"cm-inlineChangedLine"});function cb(e,t,n,s){let o=Hu(e,t),a=0;if(!o)return!1;for(let i=e.doc.lineAt(t.fromB);;){for(s&&s.add(i.from,i.from,ib),n.add(i.from,i.from,lb);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 db=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 Ut=Js.define({combine:e=>{const t=[];for(let n of e){if(!n)continue;const{create:s,gutters:o}=n,a=db(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 Hp(t,{enabled:t.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),Jt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},ub=ur.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"}}}}),Wr=Jt.PixelMultiplier*Jt.SizeRatio,pb=Ys.fromClass(class{constructor(e){this.view=e,this._isDragging=!1,e.state.facet(Ut).enabled&&this.create(e)}create(e){this.container=kn("div",{class:"cm-minimap-overlay-container"}),this.dom=kn("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(Ut).enabled,n=e.state.facet(Ut).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/Wr;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/Wr,a=e/Wr,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(Ut);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)*Wr,d=a/(o-s),p=(s*Wr-s)*d,m=Math.max(0,a-p);this.view.scrollDOM.scrollTop=m+c-s/2}onMouseUp(e){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(e){if(!this._isDragging||!this.dom)return;if(e.preventDefault(),e.stopPropagation(),!this._dragStartY){this._dragStartY=e.clientY;return}const t=e.clientY-this._dragStartY,n=t<0,s=t>0;this._dragStartY=e.clientY;const o=this.dom.getBoundingClientRect().height,a=this.dom.getBoundingClientRect().y,i=a+o,c=parseFloat(this.dom.style.top),d=this.view.scrollDOM.scrollTop,u=this.view.scrollDOM.clientHeight,p=this.view.scrollDOM.scrollHeight,m=d===0,h=Math.round(d)>=Math.round(p-u);if(m&&n||m&&e.clientY<a||h&&s||h&&e.clientY>i)return;const g=this.view.scrollDOM.scrollHeight,x=this.view.scrollDOM.clientHeight,S=(g-x)/Wr,k=x-x/Wr,I=c+t,A=I/k,w=(g-x)*A,M=I*Wr;this.view.scrollDOM.scrollTop=Math.max(w,M);const C=Math.min(Math.max(0,I),Math.min(k,S));this.dom.style.top=C+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),mb=[ub,pb];class xi{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 mc(e){var t;if(!e.facet(Ut).enabled)return[];const n=[],s=e.doc.iterLines(),o=qp(e).iter();let a=0;for(s.next();!s.done;){const i=s.value;let c=a,d=c+i.length;for(;o.value&&o.to<c;)o.next();const{from:u,to:p}=o,m=c>=u&&c<p,h=d>u&&d<=p;if(m){let g=(t=n.pop())!==null&&t!==void 0?t:[],x=g.pop();x&&x.folded&&(x.to=p),x&&g.push(x),(!x||!x.folded)&&g.push({from:u,to:p,folded:!0}),h||g.push({from:p,to:d,folded:!1}),n.push(g)}else h?n.push([{from:c,to:u,folded:!1},{from:u,to:p,folded:!0}]):n.push([{from:c,to:d,folded:!1}]);a=d+1,s.next()}return n}const An=Kn.define({create:e=>mc(e),update:(e,t)=>po([t])||t.docChanged?mc(t.state):e});function po(e){return e.find(t=>t.effects.find(n=>n.is(Vp)||n.is(Gp)))}class fb extends xi{constructor(t){super(t),this.count=void 0}shouldUpdate(t){if(!t.state.facet(Ut).enabled)return!1;if(t.docChanged)return!0;for(const n of t.transactions)for(const s of n.effects)if(s.is(Kp))return!0;return!!(po(t.transactions)||this.count===void 0)}update(t){if(!this.shouldUpdate(t))return;this.map.clear();const n=t.state.field(An);this.count=Jp(t.state),Yp(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 hb(e){return new fb(e)}class gb extends xi{constructor(t){super(t),this.getDrawInfo(),this._themeClasses=t.dom.classList.value}shouldUpdate(t){return t.state.facet(Ut).enabled?!!(t.docChanged||t.selectionSet||this._themeClasses!==this.view.dom.classList.value||po(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(An).entries()){const i=[];let c=0;for(const u of a){do{if(s>=n.length||u.to<n[s].from)continue;if(n[s].from===n[s].to){s++;continue}const p=n[s],m={from:c+Math.max(u.from,p.from)-u.from,to:c+Math.min(u.to,p.to)-u.from,extends:p.to>u.to},h=i.slice(-1)[0];if(h&&h.to===m.from){let{to:g}=m;u.folded&&m.extends?g=m.from+1:u.folded&&!m.extends&&(g=h.to),i[i.length-1]=Object.assign(Object.assign({},h),{to:g,extends:m.extends})}else u.folded||i.push(m);if(m.extends)break;s++}while(s<n.length&&u.to>=n[s].from);c+=u.folded?1:u.to-u.from}if(i.length===0)continue;const d=o+1;this.map.set(d,i)}}drawLine(t,n){let{context:s,lineHeight:o,charWidth:a,offsetX:i,offsetY:c}=t;const d=this.get(n);if(d)for(const u of d){const p=i+u.from*a,m=(u.to-u.from)*a,h=s.canvas.width-p;u.extends&&(s.globalAlpha=.65,s.beginPath(),s.rect(p,c,h,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()),s.globalAlpha=1,s.beginPath(),s.rect(p,c,m,o),s.fillStyle=this.getDrawInfo().backgroundColor,s.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const t=document.createElement("span");t.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(t);const s={backgroundColor:window.getComputedStyle(t).backgroundColor};return this._drawInfo=s,this.view.dom.removeChild(t),s}}function xb(e){return new gb(e)}class vb extends xi{constructor(t){super(t),this._fontInfoMap=new Map,this._themeClasses=new Set(t.dom.classList.values()),t.state.facet(Ut).enabled&&this.updateImpl(t.state)}shouldUpdate(t){return!!(t.docChanged||t.state.facet(Ut)!==t.startState.facet(Ut)||this.themeChanged()||po(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(Ut).displayText,this.themeChanged()&&this._fontInfoMap.clear();let o;if(this._previousTree&&n){const m=el.addTree(this._previousTree),h=[];n.iterChangedRanges((g,x,S,k)=>h.push({fromA:g,toA:x,fromB:S,toB:k})),o=el.applyChanges(m,h)}const a=t.doc.toString(),i=(s=t.facet(jc))===null||s===void 0?void 0:s.parser,c=i?i.parse(a,o):void 0;this._previousTree=c;const d={style:m=>Sc(t,m)};let u=[];if(c){const m=t.doc.lineAt(this.view.viewport.from).number,h=t.doc.lineAt(this.view.viewport.to).number,g=h-m,x=m/(t.doc.lines-g),{SizeRatio:S,PixelMultiplier:k}=Jt,I=g*S*k,A=x*I,w=Math.max(1,Math.floor(m-A)),M=Math.min(h+Math.floor(I-A),t.doc.lines);fa(c,d,(C,b,R)=>{u.push({from:C,to:b,tags:R})},t.doc.line(w).from,t.doc.line(M).to)}this.updateMapImpl(t,u),u=[];const p=()=>{c&&(fa(c,d,(m,h,g)=>{u.push({from:m,to:h,tags:g})}),this.updateMapImpl(t,u),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(p):setTimeout(p)}updateMapImpl(t,n){this.map.clear();const s=t.doc.toString(),o=n.values();let a=o.next();for(const[i,c]of t.field(An).entries()){const d=[];for(const p of c){if(p.from===p.to)continue;if(p.folded){d.push({text:"…",tags:""});continue}let m=p.from;for(;!a.done&&a.value.from<p.to;){const{from:h,to:g,tags:x}=a.value;if(g<m){a=o.next();continue}h>m&&d.push({text:s.slice(m,h),tags:""});const S=Math.max(h,p.from),k=Math.min(g,p.to);if(d.push({text:s.slice(S,k),tags:x}),m=k,g>k)break;a=o.next()}m!==p.to&&d.push({text:s.slice(m,p.to),tags:""})}const u=i+1;this.map.set(u,d)}}measure(t){const{color:n,font:s,lineHeight:o}=this.getFontInfo("");return t.textBaseline="ideographic",t.fillStyle=n,t.font=s,{charWidth:t.measureText("_").width,lineHeight:o}}beforeDraw(){this._fontInfoMap.clear()}drawLine(t,n){const s=this.get(n);if(!s)return;let{context:o,charWidth:a,lineHeight:i,offsetX:c,offsetY:d}=t,u;o.textBaseline="ideographic";for(const p of s){const m=this.getFontInfo(p.tags);switch((!u||u.color!==m.color)&&(o.fillStyle=m.color),(!u||u.font!==m.font)&&(o.font=m.font),u=m,i=Math.max(i,m.lineHeight),this._displayText){case"characters":{o.fillText(p.text,c,d+i),c+=p.text.length*a;break}case"blocks":{const h=/\S+/g;let g;for(;(g=h.exec(p.text))!==null;){const x=c+g.index*a;let S=(h.lastIndex-g.index)*a;if(x>o.canvas.width)break;x+S>o.canvas.width&&(S=o.canvas.width-x);const k=2/Jt.SizeRatio,I=i-k;o.fillStyle=m.color,o.globalAlpha=.65,o.beginPath(),o.rect(x,d,S,I),o.fill()}c+=p.text.length*a;break}}}}getFontInfo(t){const n=this._fontInfoMap.get(t);if(n)return n;const s=kn("span",{class:t}),o=kn("div",{class:"cm-line",style:"display: none"},s);this.view.contentDOM.appendChild(o);const a=window.getComputedStyle(s),i=parseFloat(a.lineHeight)/Jt.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 yb(e){return new vb(e)}const qu=4;function bb(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,qu,t.lineHeight),t.context.fill())}const wb=ur.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"}}),fc=6,kb=Ys.fromClass(class{constructor(e){this.view=e,this.text=yb(e),this.selection=xb(e),this.diagnostic=hb(e),e.state.facet(Un)&&this.create(e)}create(e){const t=e.state.facet(Un);if(!t)throw Error("Expected nonnull");this.inner=kn("div",{class:"cm-minimap-inner"}),this.canvas=kn("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(Ut).eventHandlers){const s=this.view.state.facet(Ut).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(Un),n=e.state.facet(Un);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<=Jt.MaxWidth*fc){const t=e/(Jt.MaxWidth*fc);return Jt.MaxWidth*t}return Jt.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()*Jt.PixelMultiplier;const e=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=e+"px",this.canvas.height=e*Jt.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(Ut).gutters;for(let d=o;d<a;d++){const u=this.view.state.field(An);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)bb(m,p,d+1),p.offsetX+=qu;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/=Jt.SizeRatio,s/=Jt.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(An).length,p=n+s+u*t,m=Math.max(0,d*(p-o)),h=Math.max(0,n-m),g=Math.round(Math.max(0,m-n)/t),x=Math.round((o-h)/t);return{startIndex:g,endIndex:g+x,offsetY:h}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:e,scrollWidth:t,scrollLeft:n}=this.view.scrollDOM;e+n<t?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:e=>ur.scrollMargins.of(t=>{var n;const s=(n=t.plugin(e))===null||n===void 0?void 0:n.getWidth();return s?{right:s}:null})}),Un=Js.define({combine:e=>{var t;return(t=e.find(n=>n!==null))!==null&&t!==void 0?t:null},enables:e=>[[Ut.compute([e],t=>t.facet(e)),wb,An,kb,mb]]});function hc({file:e,onClose:t,projectPath:n,isSidebar:s=!1,isExpanded:o=!1,onToggleExpand:a=null}){const{t:i}=Mt("codeEditor"),[c,d]=l.useState(""),[u,p]=l.useState(!0),[m,h]=l.useState(!1),[g,x]=l.useState(!1),[S,k]=l.useState(()=>{const $=localStorage.getItem("codeEditorTheme");return $?$==="dark":!0}),[I,A]=l.useState(!1),[w,M]=l.useState(!!e.diffInfo),[C,b]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[R,B]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[D,Z]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[z,X]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),q=l.useRef(null),re=l.useMemo(()=>{if(!e.diffInfo||!w||!R)return[];const $={};return[Un.compute(["doc"],N=>{const ne=ua(N)?.chunks||[];return Object.keys($).forEach(ke=>delete $[ke]),ne.forEach(ke=>{const xe=N.doc.lineAt(ke.fromB).number,P=N.doc.lineAt(Math.min(ke.toB,N.doc.length)).number;for(let ae=xe;ae<=P;ae++)$[ae]=S?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[$]}})]},[e.diffInfo,w,R,S]),Se=l.useMemo(()=>!e.diffInfo||!w?[]:[Ys.fromClass(class{constructor($){setTimeout(()=>{const O=ua($.state)?.chunks||[];if(O.length>0){const ne=O[0];$.dispatch({effects:ur.scrollIntoView(ne.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[e.diffInfo,w]),Ce=l.useMemo(()=>{const $=N=>{const O=document.createElement("div");O.className="cm-editor-toolbar-panel";let ne=0;const ke=()=>{const xe=e.diffInfo&&w,ae=(xe?ua(N.state):null)?.chunks||[],ee=ae.length;let Ne='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(Ne+='<div style="display: flex; align-items: center; gap: 8px;">',xe&&(Ne+=`
|
|
320
|
-
<span style="font-weight: 500;">${ee>0?`${ne+1}/${ee}`:"0"} ${i("toolbar.changes")}</span>
|
|
321
|
-
<button class="cm-diff-nav-btn cm-diff-nav-prev" title="${i("toolbar.previousChange")}" ${ee===0?"disabled":""}>
|
|
322
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
323
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
|
|
324
|
-
</svg>
|
|
325
|
-
</button>
|
|
326
|
-
<button class="cm-diff-nav-btn cm-diff-nav-next" title="${i("toolbar.nextChange")}" ${ee===0?"disabled":""}>
|
|
327
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
328
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
329
|
-
</svg>
|
|
330
|
-
</button>
|
|
331
|
-
`),Ne+="</div>",Ne+='<div style="display: flex; align-items: center; gap: 4px;">',e.diffInfo&&(Ne+=`
|
|
332
|
-
<button class="cm-toolbar-btn cm-toggle-diff-btn" title="${i(w?"toolbar.hideDiff":"toolbar.showDiff")}">
|
|
333
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
334
|
-
${w?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />'}
|
|
335
|
-
</svg>
|
|
336
|
-
</button>
|
|
337
|
-
`),Ne+=`
|
|
338
|
-
<button class="cm-toolbar-btn cm-settings-btn" title="${i("toolbar.settings")}">
|
|
339
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
340
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
341
|
-
</svg>
|
|
342
|
-
</button>
|
|
343
|
-
`,s&&a&&(Ne+=`
|
|
344
|
-
<button class="cm-toolbar-btn cm-expand-btn" title="${i(o?"toolbar.collapse":"toolbar.expand")}">
|
|
345
|
-
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
346
|
-
${o?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
|
|
347
|
-
</svg>
|
|
348
|
-
</button>
|
|
349
|
-
`),Ne+="</div>",Ne+="</div>",O.innerHTML=Ne,xe){const Ge=O.querySelector(".cm-diff-nav-prev"),Ke=O.querySelector(".cm-diff-nav-next");Ge?.addEventListener("click",()=>{if(ae.length===0)return;ne=ne>0?ne-1:ae.length-1;const qe=ae[ne];qe&&N.dispatch({effects:ur.scrollIntoView(qe.fromB,{y:"center"})}),ke()}),Ke?.addEventListener("click",()=>{if(ae.length===0)return;ne=ne<ae.length-1?ne+1:0;const qe=ae[ne];qe&&N.dispatch({effects:ur.scrollIntoView(qe.fromB,{y:"center"})}),ke()})}e.diffInfo&&O.querySelector(".cm-toggle-diff-btn")?.addEventListener("click",()=>{M(!w)}),O.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),s&&a&&O.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{a()})};return ke(),{top:!0,dom:O,update:ke}};return[Xp.of($)]},[e.diffInfo,w,s,o,a]),ge=$=>{const N=$.split(".").pop()?.toLowerCase();switch(N){case"js":case"jsx":case"ts":case"tsx":return[om({jsx:!0,typescript:N.includes("ts")})];case"py":return[sm()];case"html":case"htm":return[nm()];case"css":case"scss":case"less":return[rm()];case"json":return[tm()];case"md":case"markdown":return[em()];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 N=await mt.readFile(e.projectName,e.path);if(!N.ok)throw new Error(`Failed to load file: ${N.status} ${N.statusText}`);const O=await N.json();d(O.content)}catch(N){console.error("Error loading file:",N),d(`// Error loading file: ${N.message}
|
|
350
|
-
// File: ${e.name}
|
|
351
|
-
// Path: ${e.path}`)}finally{p(!1)}})()},[e,n]);const de=async()=>{h(!0);try{console.log("Saving file:",{projectName:e.projectName,path:e.path,contentLength:c?.length});const $=await mt.saveFile(e.projectName,e.path,c);if(console.log("Save response:",{status:$.status,ok:$.ok,contentType:$.headers.get("content-type")}),!$.ok){const O=$.headers.get("content-type");if(O&&O.includes("application/json")){const ne=await $.json();throw new Error(ne.error||`Save failed: ${$.status}`)}else{const ne=await $.text();throw console.error("Non-JSON error response:",ne),new Error(`Save failed: ${$.status} ${$.statusText}`)}}const N=await $.json();console.log("Save successful:",N),A(!0),setTimeout(()=>A(!1),2e3)}catch($){console.error("Error saving file:",$),alert(`Error saving file: ${$.message}`)}finally{h(!1)}},H=()=>{const $=new Blob([c],{type:"text/plain"}),N=URL.createObjectURL($),O=document.createElement("a");O.href=N,O.download=e.name,document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL(N)},Le=()=>{x(!g)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",S?"dark":"light")},[S]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",C.toString())},[C]),l.useEffect(()=>{const $=()=>{const N=localStorage.getItem("codeEditorTheme");N&&k(N==="dark");const O=localStorage.getItem("codeEditorWordWrap");O!==null&&b(O==="true");const ne=localStorage.getItem("codeEditorShowMinimap");ne!==null&&B(ne!=="false");const ke=localStorage.getItem("codeEditorLineNumbers");ke!==null&&Z(ke!=="false");const xe=localStorage.getItem("codeEditorFontSize");xe&&X(xe)};return window.addEventListener("storage",$),window.addEventListener("codeEditorSettingsChanged",$),()=>{window.removeEventListener("storage",$),window.removeEventListener("codeEditorSettingsChanged",$)}},[]),l.useEffect(()=>{const $=N=>{(N.ctrlKey||N.metaKey)&&(N.key==="s"?(N.preventDefault(),de()):N.key==="Escape"&&(N.preventDefault(),t()))};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[c]),u?r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
352
|
-
.code-editor-loading {
|
|
353
|
-
background-color: ${S?"#111827":"#ffffff"} !important;
|
|
354
|
-
}
|
|
355
|
-
.code-editor-loading:hover {
|
|
356
|
-
background-color: ${S?"#111827":"#ffffff"} !important;
|
|
357
|
-
}
|
|
358
|
-
`}),s?r.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:i("loading",{fileName:e.name})})]})}):r.jsx("div",{className:"fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center",children:r.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-primary"}),r.jsx("span",{className:"text-gray-900 dark:text-white",children:i("loading",{fileName:e.name})})]})})})]}):r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
359
|
-
/* Light background for full line changes */
|
|
360
|
-
.cm-deletedChunk {
|
|
361
|
-
background-color: ${S?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
|
|
362
|
-
border-left: 3px solid ${S?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
|
|
363
|
-
padding-left: 4px !important;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
.cm-insertedChunk {
|
|
367
|
-
background-color: ${S?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
|
|
368
|
-
border-left: 3px solid ${S?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
|
|
369
|
-
padding-left: 4px !important;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/* Override linear-gradient underline and use solid darker background for partial changes */
|
|
373
|
-
.cm-editor.cm-merge-b .cm-changedText {
|
|
374
|
-
background: ${S?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
|
|
375
|
-
padding-top: 2px !important;
|
|
376
|
-
padding-bottom: 2px !important;
|
|
377
|
-
margin-top: -2px !important;
|
|
378
|
-
margin-bottom: -2px !important;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
.cm-editor .cm-deletedChunk .cm-changedText {
|
|
382
|
-
background: ${S?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
|
|
383
|
-
padding-top: 2px !important;
|
|
384
|
-
padding-bottom: 2px !important;
|
|
385
|
-
margin-top: -2px !important;
|
|
386
|
-
margin-bottom: -2px !important;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/* Minimap gutter styling */
|
|
390
|
-
.cm-gutter.cm-gutter-minimap {
|
|
391
|
-
background-color: ${S?"#1e1e1e":"#f5f5f5"};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/* Editor toolbar panel styling */
|
|
395
|
-
.cm-editor-toolbar-panel {
|
|
396
|
-
padding: 8px 12px;
|
|
397
|
-
background-color: ${S?"#1f2937":"#ffffff"};
|
|
398
|
-
border-bottom: 1px solid ${S?"#374151":"#e5e7eb"};
|
|
399
|
-
color: ${S?"#d1d5db":"#374151"};
|
|
400
|
-
font-size: 14px;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
.cm-diff-nav-btn,
|
|
404
|
-
.cm-toolbar-btn {
|
|
405
|
-
padding: 4px;
|
|
406
|
-
background: transparent;
|
|
407
|
-
border: none;
|
|
408
|
-
cursor: pointer;
|
|
409
|
-
border-radius: 4px;
|
|
410
|
-
display: inline-flex;
|
|
411
|
-
align-items: center;
|
|
412
|
-
justify-content: center;
|
|
413
|
-
color: inherit;
|
|
414
|
-
transition: background-color 0.2s;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
.cm-diff-nav-btn:hover,
|
|
418
|
-
.cm-toolbar-btn:hover {
|
|
419
|
-
background-color: ${S?"#374151":"#f3f4f6"};
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
.cm-diff-nav-btn:disabled {
|
|
423
|
-
opacity: 0.5;
|
|
424
|
-
cursor: not-allowed;
|
|
425
|
-
}
|
|
426
|
-
`}),r.jsx("div",{className:s?"w-full h-full flex flex-col":`fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${g?"md:p-0":""}`,children:r.jsxs("div",{className:s?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(g?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border flex-shrink-0 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:e.name}),e.diffInfo&&r.jsx("span",{className:"text-xs bg-primary/15 dark:bg-primary/30 text-primary dark:text-primary/80 px-2 py-1 rounded whitespace-nowrap",children:i("header.showingChanges")})]}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate",children:e.path})]})}),r.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:H,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(ga,{className:"w-5 h-5 md:w-4 md:h-4"})}),r.jsx("button",{onClick:de,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 ${I?"bg-green-600 hover:bg-green-700":"bg-primary hover:bg-primary/90"}`,children:I?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(Ff,{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:Le,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:i(g?"actions.exitFullscreen":"actions.fullscreen"),children:g?r.jsx(_f,{className:"w-4 h-4"}):r.jsx(Rc,{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(sr,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Qp,{ref:q,value:c,onChange:d,extensions:[...ge(e.name),...Ce,...e.diffInfo&&w&&e.diffInfo.old_string!==void 0?[tb({original:e.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...re,...Se]:[],...C?[ur.lineWrapping]:[]],theme:S?Zp:void 0,height:"100%",style:{fontSize:`${z}px`,height:"100%"},basicSetup:{lineNumbers:D,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),r.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-border bg-muted flex-shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[r.jsxs("span",{children:[i("footer.lines")," ",c.split(`
|
|
427
|
-
`).length]}),r.jsxs("span",{children:[i("footer.characters")," ",c.length]})]}),r.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:i("footer.shortcuts")})]})]})})]})}var jb=Hm(),Sb=qm(),Nb=Vm(),pa={exports:{}},gc;function Cb(){return gc||(gc=1,function(e,t){(function(n,s){e.exports=s()})(self,()=>(()=>{var n={6:(i,c)=>{function d(p){try{const m=new URL(p),h=m.password&&m.username?`${m.protocol}//${m.username}:${m.password}@${m.host}`:m.username?`${m.protocol}//${m.username}@${m.host}`:`${m.protocol}//${m.host}`;return p.toLocaleLowerCase().startsWith(h.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(p,m,h,g={}){this._terminal=p,this._regex=m,this._handler=h,this._options=g}provideLinks(p,m){const h=u.computeLink(p,this._regex,this._terminal,this._handler);m(this._addCallbacks(h))}_addCallbacks(p){return p.map(m=>(m.leave=this._options.leave,m.hover=(h,g)=>{if(this._options.hover){const{range:x}=m;this._options.hover(h,g,x)}},m))}};class u{static computeLink(m,h,g,x){const S=new RegExp(h.source,(h.flags||"")+"g"),[k,I]=u._getWindowedLineStrings(m-1,g),A=k.join("");let w;const M=[];for(;w=S.exec(A);){const C=w[0];if(!d(C))continue;const[b,R]=u._mapStrIdx(g,I,0,w.index),[B,D]=u._mapStrIdx(g,b,R,C.length);if(b===-1||R===-1||B===-1||D===-1)continue;const Z={start:{x:R+1,y:b+1},end:{x:D,y:B+1}};M.push({range:Z,text:C,activate:x})}return M}static _getWindowedLineStrings(m,h){let g,x=m,S=m,k=0,I="";const A=[];if(g=h.buffer.active.getLine(m)){const w=g.translateToString(!0);if(g.isWrapped&&w[0]!==" "){for(k=0;(g=h.buffer.active.getLine(--x))&&k<2048&&(I=g.translateToString(!0),k+=I.length,A.push(I),g.isWrapped&&I.indexOf(" ")===-1););A.reverse()}for(A.push(w),k=0;(g=h.buffer.active.getLine(++S))&&g.isWrapped&&k<2048&&(I=g.translateToString(!0),k+=I.length,A.push(I),I.indexOf(" ")===-1););}return[A,x]}static _mapStrIdx(m,h,g,x){const S=m.buffer.active,k=S.getNullCell();let I=g;for(;x;){const A=S.getLine(h);if(!A)return[-1,-1];for(let w=I;w<A.length;++w){A.getCell(w,k);const M=k.getChars();if(k.getWidth()&&(x-=M.length||1,w===A.length-1&&M==="")){const C=S.getLine(h+1);C&&C.isWrapped&&(C.getCell(0,k),k.getWidth()===2&&(x+=1))}if(x<0)return[h,w]}h++,I=0}return[h,I]}}c.LinkComputer=u}},s={};function o(i){var c=s[i];if(c!==void 0)return c.exports;var d=s[i]={exports:{}};return n[i](d,d.exports,o),d.exports}var a={};return(()=>{var i=a;Object.defineProperty(i,"__esModule",{value:!0}),i.WebLinksAddon=void 0;const c=o(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(p,m){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=m}else console.warn("Opening link blocked as opener could not be cleared")}i.WebLinksAddon=class{constructor(p=u,m={}){this._handler=p,this._options=m}activate(p){this._terminal=p;const m=this._options,h=m.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,h,this._handler,m))}dispose(){this._linkProvider?.dispose()}}})(),a})())}(pa)),pa.exports}var Eb=Cb();const Ib=`
|
|
428
|
-
.xterm .xterm-screen {
|
|
429
|
-
outline: none !important;
|
|
430
|
-
}
|
|
431
|
-
.xterm:focus .xterm-screen {
|
|
432
|
-
outline: none !important;
|
|
433
|
-
}
|
|
434
|
-
.xterm-screen:focus {
|
|
435
|
-
outline: none !important;
|
|
436
|
-
}
|
|
437
|
-
`;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=Ib,document.head.appendChild(e)}function Ab({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:s=!1,onProcessComplete:o,minimal:a=!1,autoConnect:i=!1}){const{t:c}=Mt("chat"),d=l.useRef(null),u=l.useRef(null),p=l.useRef(null),m=l.useRef(null),[h,g]=l.useState(!1),[x,S]=l.useState(!1),[k,I]=l.useState(!1),[A,w]=l.useState(null),[M,C]=l.useState(!1),b=l.useRef(e),R=l.useRef(t),B=l.useRef(n),D=l.useRef(s),Z=l.useRef(o);l.useEffect(()=>{b.current=e,R.current=t,B.current=n,D.current=s,Z.current=o});const z=l.useCallback(async()=>{if(!(M||h))try{let de;if(!Px){const H=localStorage.getItem("auth-token");if(!H){console.error("No authentication token found for Shell WebSocket connection");return}de=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(H)}`}m.current=new WebSocket(de),m.current.onopen=()=>{g(!0),C(!1),setTimeout(()=>{p.current&&u.current&&(p.current.fit(),m.current.send(JSON.stringify({type:"init",projectPath:b.current.fullPath||b.current.path,sessionId:D.current?null:R.current?.id,hasSession:D.current?!1:!!R.current,provider:D.current?"plain-shell":R.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:B.current,isPlainShell:D.current})))},100)},m.current.onmessage=H=>{try{const Le=JSON.parse(H.data);if(Le.type==="output"){let $=Le.data;if(D.current&&Z.current){const N=$.replace(/\x1b\[[0-9;]*m/g,"");if(N.includes("Process exited with code 0"))Z.current(0);else if(N.match(/Process exited with code (\d+)/)){const O=parseInt(N.match(/Process exited with code (\d+)/)[1]);O!==0&&Z.current(O)}}u.current&&u.current.write($)}else Le.type==="url_open"&&window.open(Le.url,"_blank")}catch(Le){console.error("[Shell] Error handling WebSocket message:",Le,H.data)}},m.current.onclose=H=>{g(!1),C(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},m.current.onerror=H=>{g(!1),C(!1)}}catch{g(!1),C(!1)}},[M,h]),X=l.useCallback(()=>{!x||h||M||(C(!0),z())},[x,h,M,z]),q=l.useCallback(()=>{m.current&&(m.current.close(),m.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),g(!1),C(!1)},[]),re=l.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),Se=l.useMemo(()=>re?re.slice(0,30):null,[re]),Ce=l.useMemo(()=>re?re.slice(0,50):null,[re]),ge=()=>{I(!0),m.current&&(m.current.close(),m.current=null),u.current&&(u.current.dispose(),u.current=null,p.current=null),g(!1),S(!1),setTimeout(()=>{I(!1)},200)};return l.useEffect(()=>{const de=t?.id||null;A!==null&&A!==de&&x&&q(),w(de)},[t?.id,x,q]),l.useEffect(()=>{if(!d.current||!e||k||u.current)return;u.current=new jb.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 Sb.FitAddon;const de=new Nb.WebglAddon,H=new Eb.WebLinksAddon;u.current.loadAddon(p.current),u.current.loadAddon(H);try{u.current.loadAddon(de)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler($=>($.ctrlKey||$.metaKey)&&$.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):($.ctrlKey||$.metaKey)&&$.key==="v"?(navigator.clipboard.readText().then(N=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:N}))}).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),S(!0),u.current.onData($=>{m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"input",data:$}))});const Le=new ResizeObserver(()=>{p.current&&u.current&&setTimeout(()=>{p.current.fit(),m.current&&m.current.readyState===WebSocket.OPEN&&m.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&Le.observe(d.current),()=>{Le.disconnect(),m.current&&(m.current.readyState===WebSocket.OPEN||m.current.readyState===WebSocket.CONNECTING)&&m.current.close(),m.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,k]),l.useEffect(()=>{!i||!x||M||h||X()},[i,x,M,h,X]),e?a?r.jsx("div",{className:"h-full w-full bg-gray-900",children:r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):r.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${h?"bg-green-500":"bg-red-500"}`}),t&&r.jsxs("span",{className:"text-xs text-primary/80",children:["(",Se,"...)"]}),!t&&r.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!x&&r.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),k&&r.jsx("span",{className:"text-xs text-primary",children:c("shell.status.restarting")})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[h&&r.jsxs("button",{onClick:q,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:ge,disabled:k||h,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:c("shell.actions.restartTitle"),children:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),r.jsx("span",{children:c("shell.actions.restart")})]})]})]})}),r.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!x&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:r.jsx("div",{className:"text-white",children:c("shell.loading")})}),x&&!h&&!M&&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:X,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:Ce}):c("shell.startSession")})]})}),M&&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 Vu({project:e,session:t=null,command:n=null,isPlainShell:s=null,autoConnect:o=!0,onComplete:a=null,onClose:i=null,title:c=null,className:d="",showHeader:u=!0,compact:p=!1,minimal:m=!1}){const[h,g]=l.useState(!1),x=s!==null?s:n!==null,S=l.useCallback(k=>{g(!0),a&&a(k)},[a]);return e?r.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!m&&u&&c&&r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-200",children:c}),h&&r.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),i&&r.jsx("button",{onClick:i,className:"text-gray-400 hover:text-white",title:"Close",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),r.jsx("div",{className:"flex-1 w-full min-h-0",children:r.jsx(Ab,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:x,onProcessComplete:S,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 mt.transcribe(n);if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function _b({onTranscript:e,className:t=""}){const[n,s]=l.useState("idle"),[o,a]=l.useState(null),[i,c]=l.useState(!0),d=l.useRef(null),u=l.useRef(null),p=l.useRef([]),m=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),a("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),a("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),a(null)})()},[]);const h=async()=>{try{if(console.log("Starting recording..."),a(null),p.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const w=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=w;const M=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",C=new MediaRecorder(w,{mimeType:M});d.current=C,C.ondataavailable=b=>{b.data.size>0&&p.current.push(b.data)},C.onstop=async()=>{console.log("Recording stopped, creating blob...");const b=new Blob(p.current,{type:M});u.current&&(u.current.getTracks().forEach(Z=>Z.stop()),u.current=null),s("transcribing");const R=window.localStorage.getItem("whisperMode")||"default",B=R==="prompt"||R==="vibe"||R==="instructions"||R==="architect";let D;B&&(D=setTimeout(()=>{s("processing")},2e3));try{const Z=await Tb(b);Z&&e&&e(Z)}catch(Z){console.error("Transcription error:",Z),a(Z.message)}finally{D&&clearTimeout(D),s("idle")}},C.start(),s("recording"),console.log("Recording started successfully")}catch(w){console.error("Failed to start recording:",w);let M="Microphone access failed";w.name==="NotAllowedError"?M="Microphone access denied. Please allow microphone permissions.":w.name==="NotFoundError"?M="No microphone found. Please check your audio devices.":w.name==="NotSupportedError"?M="Microphone not supported by this browser.":w.name==="NotReadableError"?M="Microphone is being used by another application.":w.message.includes("HTTPS")&&(M=w.message),a(M),s("idle")}},g=()=>{console.log("Stopping recording..."),d.current&&d.current.state==="recording"?d.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),u.current&&(u.current.getTracks().forEach(w=>w.stop()),u.current=null),s("idle"))},x=w=>{if(w&&(w.preventDefault(),w.stopPropagation()),!i)return;const M=Date.now();if(M-m.current<300){console.log("Ignoring rapid tap");return}m.current=M,console.log("Button clicked, current state:",n),n==="idle"?h():n==="recording"&&g()};l.useEffect(()=>()=>{u.current&&u.current.getTracks().forEach(w=>w.stop())},[]);const S=()=>{if(!i)return{icon:r.jsx(Ps,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(n){case"recording":return{icon:r.jsx(Ps,{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(Wn,{className:"w-5 h-5 animate-spin"}),className:"bg-primary hover:bg-primary/90",disabled:!0};case"processing":return{icon:r.jsx(Ac,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:r.jsx(Ps,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:k,className:I,disabled:A}=S();return r.jsxs("div",{className:"relative",children:[r.jsx("button",{type:"button",style:{backgroundColor:n==="recording"?"#ef4444":n==="transcribing"?"#3b82f6":n==="processing"?"#a855f7":"#374151"},className:`
|
|
438
|
-
flex items-center justify-center
|
|
439
|
-
w-12 h-12 rounded-full
|
|
440
|
-
text-white transition-all duration-200
|
|
441
|
-
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ring
|
|
442
|
-
dark:ring-offset-gray-800
|
|
443
|
-
touch-action-manipulation
|
|
444
|
-
${A?"cursor-not-allowed opacity-75":"cursor-pointer"}
|
|
445
|
-
${n==="recording"?"animate-pulse":""}
|
|
446
|
-
hover:opacity-90
|
|
447
|
-
${t}
|
|
448
|
-
`,onClick:x,disabled:A,children:k}),o&&r.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
|
|
449
|
-
bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
|
|
450
|
-
animate-fade-in`,children:o}),n==="recording"&&r.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),n==="processing"&&r.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}function xc({diff:e,fileName:t,isMobile:n,wrapText:s}){if(!e)return r.jsx("div",{className:"p-4 text-center text-gray-500 dark:text-gray-400 text-sm",children:"No diff available"});const o=(a,i)=>{const c=a.startsWith("+")&&!a.startsWith("+++"),d=a.startsWith("-")&&!a.startsWith("---"),u=a.startsWith("@@");return r.jsx("div",{className:`font-mono text-xs p-2 ${n&&s?"whitespace-pre-wrap break-all":"whitespace-pre overflow-x-auto"} ${c?"bg-green-50 dark:bg-green-950 text-green-700 dark:text-green-300":d?"bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300":u?"bg-primary/10 dark:bg-primary/20 text-primary":"text-gray-600 dark:text-gray-400"}`,children:a},i)};return r.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-background/95 shadow-sm",children:[t&&r.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e.split(`
|
|
451
|
-
`).map((a,i)=>o(a,i))]})}function Mb({selectedProject:e,isMobile:t,onFileOpen:n}){const[s,o]=l.useState(null),[a,i]=l.useState({}),[c,d]=l.useState(!1),[u,p]=l.useState(""),[m,h]=l.useState(new Set),[g,x]=l.useState(new Set),[S,k]=l.useState(!1),[I,A]=l.useState(""),[w,M]=l.useState([]),[C,b]=l.useState(!0),[R,B]=l.useState(!1),[D,Z]=l.useState(!1),[z,X]=l.useState(!1),[q,re]=l.useState(""),[Se,Ce]=l.useState(!1),[ge,de]=l.useState("changes"),[H,Le]=l.useState([]),[$,N]=l.useState(new Set),[O,ne]=l.useState({}),[ke,xe]=l.useState(!1),[P,ae]=l.useState(null),[ee,Ne]=l.useState(!1),[lt,Ge]=l.useState(!1),[Ke,qe]=l.useState(!1),[ct,Et]=l.useState(!1),[Xe,kt]=l.useState(t),[je,Ve]=l.useState(null),[jt,St]=l.useState(!1),Dt=l.useRef(null),Y=l.useRef(null),[oe,Ee]=l.useState(()=>localStorage.getItem("selected-provider")||"claude");l.useEffect(()=>{const j=()=>{const F=localStorage.getItem("selected-provider")||"claude";Ee(F)};return window.addEventListener("storage",j),()=>window.removeEventListener("storage",j)},[]),l.useEffect(()=>{e&&(Ae(),Oe(),tt(),ge==="history"&&qt())},[e,ge]),l.useEffect(()=>{const j=F=>{Y.current&&!Y.current.contains(F.target)&&Z(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const Ae=async()=>{if(e){d(!0);try{const F=await(await le(`/api/git/status?project=${encodeURIComponent(e.name)}`)).json();if(F.error)console.error("Git status error:",F.error),o({error:F.error,details:F.details});else{o(F),A(F.branch||"main");const ve=new Set([...F.modified||[],...F.added||[],...F.deleted||[],...F.untracked||[]]);x(ve);for(const ye of F.modified||[])rt(ye);for(const ye of F.added||[])rt(ye);for(const ye of F.deleted||[])rt(ye);for(const ye of F.untracked||[])rt(ye)}}catch(j){console.error("Error fetching git status:",j)}finally{d(!1)}}},Oe=async()=>{try{const F=await(await le(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!F.error&&F.branches&&M(F.branches)}catch(j){console.error("Error fetching branches:",j)}},tt=async()=>{if(e)try{const F=await(await le(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();F.error?ae(null):ae(F)}catch(j){console.error("Error fetching remote status:",j),ae(null)}},ue=async j=>{try{const ve=await(await le("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:j})})).json();ve.success?(A(j),Z(!1),Ae()):console.error("Failed to switch branch:",ve.error)}catch(F){console.error("Error switching branch:",F)}},dt=async()=>{if(q.trim()){Ce(!0);try{const F=await(await le("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:q.trim()})})).json();F.success?(A(q.trim()),X(!1),Z(!1),re(""),Oe(),Ae()):console.error("Failed to create branch:",F.error)}catch(j){console.error("Error creating branch:",j)}finally{Ce(!1)}}},Ye=async()=>{Ne(!0);try{const F=await(await le("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),tt()):console.error("Fetch failed:",F.error)}catch(j){console.error("Error fetching from remote:",j)}finally{Ne(!1)}},Qe=async()=>{Ge(!0);try{const F=await(await le("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),tt()):console.error("Pull failed:",F.error)}catch(j){console.error("Error pulling from remote:",j)}finally{Ge(!1)}},Be=async()=>{qe(!0);try{const F=await(await le("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),tt()):console.error("Push failed:",F.error)}catch(j){console.error("Error pushing to remote:",j)}finally{qe(!1)}},Lt=async()=>{Et(!0);try{const F=await(await le("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:I})})).json();F.success?(Ae(),tt()):console.error("Publish failed:",F.error)}catch(j){console.error("Error publishing branch:",j)}finally{Et(!1)}},Nt=async j=>{try{const ve=await(await le("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:j})})).json();ve.success?(x(ye=>{const ut=new Set(ye);return ut.delete(j),ut}),Ae()):console.error("Discard failed:",ve.error)}catch(F){console.error("Error discarding changes:",F)}},vt=async j=>{try{const ve=await(await le("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:j})})).json();ve.success?(x(ye=>{const ut=new Set(ye);return ut.delete(j),ut}),Ae()):console.error("Delete failed:",ve.error)}catch(F){console.error("Error deleting untracked file:",F)}},$t=async()=>{if(!je)return;const{type:j,file:F,message:ve}=je;Ve(null);try{switch(j){case"discard":await Nt(F);break;case"delete":await vt(F);break;case"commit":await Rt();break;case"pull":await Qe();break;case"push":await Be();break;case"publish":await Lt();break}}catch(ye){console.error(`Error executing ${j}:`,ye)}},rt=async j=>{try{const ve=await(await le(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(j)}`)).json();!ve.error&&ve.diff&&i(ye=>({...ye,[j]:ve.diff}))}catch(F){console.error("Error fetching file diff:",F)}},ft=async j=>{if(n)try{const ve=await(await le(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(j)}`)).json();if(ve.error){console.error("Error fetching file with diff:",ve.error),n(j);return}const ye={old_string:ve.oldContent||"",new_string:ve.currentContent||""};n(j,ye)}catch(F){console.error("Error opening file:",F),n(j)}},qt=async()=>{try{const F=await(await le(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!F.error&&F.commits&&Le(F.commits)}catch(j){console.error("Error fetching commits:",j)}},It=async j=>{try{const ve=await(await le(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${j}`)).json();!ve.error&&ve.diff&&ne(ye=>({...ye,[j]:ve.diff}))}catch(F){console.error("Error fetching commit diff:",F)}},ht=async()=>{xe(!0);try{const F=await(await le("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(g),provider:oe})})).json();F.message?p(F.message):console.error("Failed to generate commit message:",F.error)}catch(j){console.error("Error generating commit message:",j)}finally{xe(!1)}},Qt=j=>{h(F=>{const ve=new Set(F);return ve.has(j)?ve.delete(j):ve.add(j),ve})},Vt=j=>{N(F=>{const ve=new Set(F);return ve.has(j)?ve.delete(j):(ve.add(j),O[j]||It(j)),ve})},Zt=j=>{x(F=>{const ve=new Set(F);return ve.has(j)?ve.delete(j):ve.add(j),ve})},Rt=async()=>{if(!(!u.trim()||g.size===0)){k(!0);try{const F=await(await le("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,message:u,files:Array.from(g)})})).json();F.success?(p(""),x(new Set),Ae(),tt()):console.error("Commit failed:",F.error)}catch(j){console.error("Error committing changes:",j)}finally{k(!1)}}},T=async()=>{St(!0);try{const F=await(await le("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();F.success?(Ae(),tt()):(console.error("Initial commit failed:",F.error),alert(F.error||"Failed to create initial commit"))}catch(j){console.error("Error creating initial commit:",j),alert("Failed to create initial commit")}finally{St(!1)}},G=j=>{switch(j){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return j}},Me=j=>{const F=$.has(j.hash),ve=O[j.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:()=>Vt(j.hash),children:[r.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:F?r.jsx(Ar,{className:"w-3 h-3"}):r.jsx(yn,{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:j.message}),r.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[j.author," • ",j.date]})]}),r.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:j.hash.substring(0,7)})]})})]}),F&&ve&&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:j.stats}),r.jsx(xc,{diff:ve,fileName:"commit",isMobile:t,wrapText:C})]})})]},j.hash)},fe=(j,F)=>{const ve=m.has(j),ye=g.has(j),ut=a[j];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:ye,onChange:()=>Zt(j),onClick:U=>U.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:U=>{U.stopPropagation(),Qt(j)},children:r.jsx(yn,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${ve?"rotate-90":"rotate-0"}`})}),r.jsx("span",{className:`flex-1 truncate ${t?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:U=>{U.stopPropagation(),ft(j)},title:"Click to open file",children:j}),r.jsxs("div",{className:"flex items-center gap-1",children:[(F==="M"||F==="D")&&r.jsxs("button",{onClick:U=>{U.stopPropagation(),Ve({type:"discard",file:j,message:`Discard all changes to "${j}"? 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(dr,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Discard"})]}),F==="U"&&r.jsxs("button",{onClick:U=>{U.stopPropagation(),Ve({type:"delete",file:j,message:`Delete untracked file "${j}"? 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(dr,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Delete"})]}),r.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,title:G(F),children:F})]})]})]}),r.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${ve&&ut?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[r.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-xs font-bold border ${F==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":F==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":F==="D"?"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 border-red-200 dark:border-red-800":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 border-gray-300 dark:border-gray-600"}`,children:F}),r.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:G(F)})]}),t&&r.jsx("button",{onClick:U=>{U.stopPropagation(),b(!C)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:C?"Switch to horizontal scroll":"Switch to text wrap",children:C?"↔️ Scroll":"↩️ Wrap"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto",children:ut&&r.jsx(xc,{diff:ut,fileName:j,isMobile:t,wrapText:C})})]})]},j)};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:Y,children:[r.jsxs("button",{onClick:()=>Z(!D),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(Jo,{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:I}),P?.hasRemote&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[P.ahead>0&&r.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${P.ahead} commit${P.ahead!==1?"s":""} ahead`,children:["↑",P.ahead]}),P.behind>0&&r.jsxs("span",{className:"text-primary",title:`${P.behind} commit${P.behind!==1?"s":""} behind`,children:["↓",P.behind]}),P.isUpToDate&&r.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),r.jsx(Ar,{className:`w-3 h-3 text-gray-500 transition-transform ${D?"rotate-180":""}`})]}),D&&r.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 z-50",children:[r.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:w.map(j=>r.jsx("button",{onClick:()=>ue(j),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${j===I?"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:[j===I&&r.jsx(vr,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),r.jsx("span",{className:j===I?"font-medium":"",children:j})]})},j))}),r.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:r.jsxs("button",{onClick:()=>{X(!0),Z(!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(jn,{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:[P?.hasRemote&&r.jsxs(r.Fragment,{children:[!P?.hasUpstream&&r.jsxs("button",{onClick:()=>Ve({type:"publish",message:`Publish branch "${I}" to ${P.remoteName}?`}),disabled:ct,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 "${I}" to ${P.remoteName}`,children:[r.jsx(vs,{className:`w-3 h-3 ${ct?"animate-pulse":""}`}),r.jsx("span",{children:ct?"Publishing...":"Publish"})]}),P?.hasUpstream&&!P?.isUpToDate&&r.jsxs(r.Fragment,{children:[P.behind>0&&r.jsxs("button",{onClick:()=>Ve({type:"pull",message:`Pull ${P.behind} commit${P.behind!==1?"s":""} from ${P.remoteName}?`}),disabled:lt,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 ${P.behind} commit${P.behind!==1?"s":""} from ${P.remoteName}`,children:[r.jsx(ga,{className:`w-3 h-3 ${lt?"animate-pulse":""}`}),r.jsx("span",{children:lt?"Pulling...":`Pull ${P.behind}`})]}),P.ahead>0&&r.jsxs("button",{onClick:()=>Ve({type:"push",message:`Push ${P.ahead} commit${P.ahead!==1?"s":""} to ${P.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 ${P.ahead} commit${P.ahead!==1?"s":""} to ${P.remoteName}`,children:[r.jsx(vs,{className:`w-3 h-3 ${Ke?"animate-pulse":""}`}),r.jsx("span",{children:Ke?"Pushing...":`Push ${P.ahead}`})]}),(P.ahead>0||P.behind>0&&P.ahead>0)&&r.jsxs("button",{onClick:Ye,disabled:ee,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 ${P.remoteName}`,children:[r.jsx(Ir,{className:`w-3 h-3 ${ee?"animate-spin":""}`}),r.jsx("span",{children:ee?"Fetching...":"Fetch"})]})]})]}),r.jsx("button",{onClick:()=>{Ae(),Oe(),tt()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${t?"p-1":"p-1.5"}`,children:r.jsx(Ir,{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(Jo,{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:()=>de("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${ge==="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(Xa,{className:"w-4 h-4"}),r.jsx("span",{children:"Changes"})]})}),r.jsx("button",{onClick:()=>de("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${ge==="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(al,{className:"w-4 h-4"}),r.jsx("span",{children:"History"})]})})]}),ge==="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&&Xe?r.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:r.jsxs("button",{onClick:()=>kt(!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(Yo,{className:"w-4 h-4"}),r.jsxs("span",{children:["Commit ",g.size," file",g.size!==1?"s":""]}),r.jsx(Ar,{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:()=>kt(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:r.jsx(Ar,{className:"w-4 h-4 rotate-180"})})]}),r.jsxs("div",{className:"relative",children:[r.jsx("textarea",{ref:Dt,value:u,onChange:j=>p(j.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:j=>{j.key==="Enter"&&(j.ctrlKey||j.metaKey)&&Rt()}}),r.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[r.jsx("button",{onClick:ht,disabled:g.size===0||ke,className:"p-1.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",title:"Generate commit message",children:ke?r.jsx(Ir,{className:"w-4 h-4 animate-spin"}):r.jsx(Ya,{className:"w-4 h-4"})}),r.jsx("div",{style:{display:"none"},children:r.jsx(_b,{onTranscript:j=>p(j),mode:"default",className:"p-1.5"})})]})]}),r.jsxs("div",{className:"flex items-center justify-between mt-2",children:[r.jsxs("span",{className:"text-xs text-gray-500",children:[g.size," file",g.size!==1?"s":""," selected"]}),r.jsxs("button",{onClick:()=>Ve({type:"commit",message:`Commit ${g.size} file${g.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||g.size===0||S,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(vr,{className:"w-3 h-3"}),r.jsx("span",{children:S?"Committing...":"Commit"})]})]})]})})})}),ge==="changes"&&s&&!s.error&&r.jsxs("div",{className:`border-b border-gray-200 dark:border-gray-700 flex items-center justify-between transition-all duration-300 ease-in-out ${t?"px-3 py-1.5":"px-4 py-2"} ${m.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[r.jsxs("span",{className:"text-gray-600 dark:text-gray-400 text-xs",children:[g.size," of ",(s?.modified?.length||0)+(s?.added?.length||0)+(s?.deleted?.length||0)+(s?.untracked?.length||0)," ",t?"":"files"," selected"]}),r.jsxs("div",{className:`flex ${t?"gap-1":"gap-2"}`,children:[r.jsx("button",{onClick:()=>{const j=new Set([...s?.modified||[],...s?.added||[],...s?.deleted||[],...s?.untracked||[]]);x(j)},className:"text-primary hover:text-primary text-xs",children:t?"All":"Select All"}),r.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),r.jsx("button",{onClick:()=>x(new Set),className:"text-primary hover:text-primary text-xs",children:t?"None":"Deselect All"})]})]}),!s?.error&&!t&&r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("button",{onClick:()=>B(!R),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(wf,{className:"w-3 h-3"}),r.jsx("span",{children:"File Status Guide"}),R?r.jsx(Ar,{className:"w-3 h-3"}):r.jsx(yn,{className:"w-3 h-3"})]}),R&&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"})]})]})})]})]}),ge==="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(Ir,{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(Jo,{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:T,disabled:jt,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:jt?r.jsxs(r.Fragment,{children:[r.jsx(Ir,{className:"w-4 h-4 animate-spin"}),r.jsx("span",{children:"Creating Initial Commit..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(Yo,{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(Yo,{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(j=>fe(j,"M")),s.added?.map(j=>fe(j,"A")),s.deleted?.map(j=>fe(j,"D")),s.untracked?.map(j=>fe(j,"U"))]})}),ge==="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(Ir,{className:"w-6 h-6 animate-spin text-gray-400"})}):H.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(al,{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:H.map(j=>Me(j))})}),z&&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:()=>X(!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:q,onChange:j=>re(j.target.value),onKeyDown:j=>{j.key==="Enter"&&!Se&&dt()},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 (",I,")"]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>{X(!1),re("")},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:dt,disabled:!q.trim()||Se,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:Se?r.jsxs(r.Fragment,{children:[r.jsx(Ir,{className:"w-3 h-3 animate-spin"}),r.jsx("span",{children:"Creating..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(jn,{className:"w-3 h-3"}),r.jsx("span",{children:"Create Branch"})]})})]})]})})]}),je&&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:()=>Ve(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 ${je.type==="discard"||je.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:r.jsx(wa,{className:`w-5 h-5 ${je.type==="discard"||je.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:je.type==="discard"?"Discard Changes":je.type==="delete"?"Delete File":je.type==="commit"?"Confirm Commit":je.type==="pull"?"Confirm Pull":je.type==="publish"?"Publish Branch":"Confirm Push"})]}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:je.message}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>Ve(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:$t,className:`px-4 py-2 text-sm text-white rounded-md ${je.type==="discard"||je.type==="delete"?"bg-red-600 hover:bg-red-700":je.type==="commit"?"bg-primary hover:bg-primary/90":je.type==="pull"?"bg-green-600 hover:bg-green-700":je.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:je.type==="discard"?r.jsxs(r.Fragment,{children:[r.jsx(dr,{className:"w-4 h-4"}),r.jsx("span",{children:"Discard"})]}):je.type==="delete"?r.jsxs(r.Fragment,{children:[r.jsx(dr,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete"})]}):je.type==="commit"?r.jsxs(r.Fragment,{children:[r.jsx(vr,{className:"w-4 h-4"}),r.jsx("span",{children:"Commit"})]}):je.type==="pull"?r.jsxs(r.Fragment,{children:[r.jsx(ga,{className:"w-4 h-4"}),r.jsx("span",{children:"Pull"})]}):je.type==="publish"?r.jsxs(r.Fragment,{children:[r.jsx(vs,{className:"w-4 h-4"}),r.jsx("span",{children:"Publish"})]}):r.jsxs(r.Fragment,{children:[r.jsx(vs,{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 Db extends Tn.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 Rb=Rx,Gu=l.forwardRef(({className:e,...t},n)=>r.jsx(Kd,{ref:n,className:it("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...t}));Gu.displayName=Kd.displayName;const Ku=l.forwardRef(({className:e,...t},n)=>r.jsx(Jd,{ref:n,className:it("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}));Ku.displayName=Jd.displayName;const Pb=l.forwardRef(({className:e,...t},n)=>r.jsx(Yd,{ref:n,className:it("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...t}));Pb.displayName=Yd.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:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:S,processingSessions:k,onReplaceTemporarySession:I,onNavigateToSession:A,onShowSettings:w,autoExpandTools:M,showRawParameters:C,showThinking:b,autoScrollToBottom:R,sendByCtrlEnter:B,externalMessageUpdate:D,urlContext:Z,urlPrompt:z,integrationClientId:X,latestIntegrationMessage:q,sendIntegrationMessage:re,onShowNewProject:Se,onNewSession:Ce,newSessionResetNonce:ge}){const{t:de}=Mt(),[H,Le]=l.useState(null),[$,N]=l.useState(600),[O,ne]=l.useState(!1),[ke,xe]=l.useState(!1),P=l.useRef(null),ae=(Xe,kt=null)=>{const je={name:Xe.split("/").pop(),path:Xe,projectName:e?.name,diffInfo:kt};Le(je)},ee=()=>{Le(null),xe(!1)},Ne=()=>{xe(!ke)},lt=Xe=>{c||(ne(!0),Xe.preventDefault())};if(l.useEffect(()=>{n==="files"&&s("chat")},[n,s]),l.useEffect(()=>{const Xe=je=>{if(!O)return;const Ve=P.current?.parentElement;if(!Ve)return;const jt=Ve.getBoundingClientRect(),St=jt.right-je.clientX,Dt=300,Y=jt.width*.8;St>=Dt&&St<=Y&&N(St)},kt=()=>{ne(!1)};return O&&(document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",kt),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",Xe),document.removeEventListener("mouseup",kt),document.body.style.cursor="",document.body.style.userSelect=""}},[O]),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:de("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:de("mainContent.chooseProject")}),r.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:de("mainContent.selectProjectDescription")}),r.jsx("div",{className:"mx-auto flex w-fit items-center",children:r.jsxs("button",{onClick:Se,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:de("tooltips.createProject")||"New Chat",children:[r.jsx(tn,{className:"w-5 h-5"}),r.jsx("span",{children:de("tooltips.createProject")||"New Chat"})]})})]})})]});const Ge=t?.__provider||t?.provider||"claude",Ke=Ge==="openai"?"codex":Ge,qe=Ke==="codex"&&typeof t?.id=="string"?t.id.trim():"",ct=qe?`codex://threads/${encodeURIComponent(qe)}`:"",Et=()=>{ct&&(window.location.href=ct)};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:Xe=>{Xe.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(ao,{className:"w-4 h-4"}):Ke==="gemini"?r.jsx(io,{className:"w-4 h-4"}):Ke==="opencode"?r.jsx(lo,{className:"h-4 w-auto max-w-full"}):r.jsx(es,{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:de("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"?de("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"&&ct&&r.jsx("button",{onClick:Et,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:de("mainContent.openInCodexClient"),"aria-label":de("mainContent.openInCodexClient"),children:r.jsx(xa,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>Ce&&Ce(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:de("tooltips.newChat","New Chat"),children:r.jsx(Ef,{className:"w-5 h-5"})}),r.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:r.jsx(Rb,{value:n,onValueChange:s,children:r.jsx(Gu,{children:r.jsx($n,{content:de("tabs.chat"),position:"bottom",children:r.jsx(Ku,{value:"chat",children:r.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[r.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),r.jsx("span",{className:"hidden lg:inline",children:de("tabs.chat")})]})})})})})})]})]})}),r.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[r.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${H?"mr-0":""} ${ke?"hidden":""}`,children:[r.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:r.jsx(Db,{showDetails:!0,children:r.jsx(Ry,{selectedProject:e,selectedSession:t,ws:o,sendMessage:a,latestMessage:i,onFileOpen:ae,onInputFocusChange:m,onSessionActive:h,onSessionInactive:g,onSessionProcessing:x,onSessionNotProcessing:S,processingSessions:k,onReplaceTemporarySession:I,onNavigateToSession:A,onShowSettings:w,autoExpandTools:M,showRawParameters:C,showThinking:b,autoScrollToBottom:R,sendByCtrlEnter:B,externalMessageUpdate:D,urlContext:Z,urlPrompt:z,integrationClientId:X,latestIntegrationMessage:q,sendIntegrationMessage:re,newSessionResetNonce:ge},`${e?.name||"no-project"}:${t?.id||`new-${ge}`}`)})}),n==="shell"&&r.jsx("div",{className:"h-full w-full overflow-hidden",children:r.jsx(Vu,{project:e,session:t,showHeader:!1})}),n==="git"&&r.jsx("div",{className:"chat-surface h-full overflow-hidden",children:r.jsx(Mb,{selectedProject:e,isMobile:c,onFileOpen:ae})}),r.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),H&&!c&&r.jsxs(r.Fragment,{children:[!ke&&r.jsx("div",{ref:P,onMouseDown:lt,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 ${ke?"flex-1":""}`,style:ke?{}:{width:`${$}px`},children:r.jsx(hc,{file:H,onClose:ee,projectPath:e?.path,isSidebar:!0,isExpanded:ke,onToggleExpand:Ne})})]})]}),H&&c&&r.jsx(hc,{file:H,onClose:ee,projectPath:e?.path,isSidebar:!1})]})}const Ob=Tn.memo(Lb),Ju="0.2.4",Yu=()=>{const[e,t]=l.useState(!1),[n,s]=l.useState(null),[o,a]=l.useState(null);return l.useEffect(()=>{(async()=>{try{const c=await le("/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:Ju,releaseInfo:o}};function Fb(){const{t:e}=Mt("settings"),[t,n]=l.useState([]),[s,o]=l.useState(!0),[a,i]=l.useState(!1),[c,d]=l.useState(""),[u,p]=l.useState(null),[m,h]=l.useState(null),{updateAvailable:g,latestVersion:x,releaseInfo:S}=Yu();l.useEffect(()=>{k()},[]);const k=async()=>{try{o(!0);const b=await(await le("/api/settings/api-keys")).json();n(b.apiKeys||[])}catch(C){console.error("Error fetching settings:",C)}finally{o(!1)}},I=async()=>{if(c.trim())try{const b=await(await le("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:c})})).json();b.success&&(h(b.apiKey),d(""),i(!1),k())}catch(C){console.error("Error creating API key:",C)}},A=async C=>{if(confirm(e("apiKeys.confirmDelete")))try{await le(`/api/settings/api-keys/${C}`,{method:"DELETE"}),k()}catch(b){console.error("Error deleting API key:",b)}},w=async(C,b)=>{try{await le(`/api/settings/api-keys/${C}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!b})}),k()}catch(R){console.error("Error toggling API key:",R)}},M=(C,b)=>{navigator.clipboard.writeText(C),p(b),setTimeout(()=>p(null),2e3)};return s?r.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):r.jsxs("div",{className:"space-y-8",children:[m&&r.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[r.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:m.apiKey}),r.jsx(Re,{size:"sm",variant:"outline",onClick:()=>M(m.apiKey,"new"),children:u==="new"?r.jsx(vr,{className:"h-4 w-4"}):r.jsx($m,{className:"h-4 w-4"})})]}),r.jsx(Re,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>h(null),children:e("apiKeys.newKey.iveSavedIt")})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Mc,{className:"h-5 w-5"}),r.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),r.jsxs(Re,{size:"sm",onClick:()=>i(!a),children:[r.jsx(jn,{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(xa,{className:"h-3 w-3"})]})]}),a&&r.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[r.jsx(Pt,{placeholder:e("apiKeys.form.placeholder"),value:c,onChange:C=>d(C.target.value),className:"mb-2"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Re,{onClick:I,children:e("apiKeys.form.createButton")}),r.jsx(Re,{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(C=>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:C.key_name}),r.jsx("code",{className:"text-xs text-muted-foreground",children:C.api_key}),r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(C.created_at).toLocaleDateString(),C.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(C.last_used).toLocaleDateString()}`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Re,{size:"sm",variant:C.is_active?"outline":"secondary",onClick:()=>w(C.id,C.is_active),children:C.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),r.jsx(Re,{size:"sm",variant:"ghost",onClick:()=>A(C.id),children:r.jsx(dr,{className:"h-4 w-4"})})]})]},C.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:S?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Ju]}),g&&x&&r.jsxs("a",{href:S?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[r.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:x})}),r.jsx(xa,{className:"h-2.5 w-2.5"})]})]})})]})}const $b=["claude","cursor","codex","gemini","opencode"],vc=["lark","dingtalk"],yc={lark:{appId:"",appSecret:"",hasAppSecret:!1,encryptKey:"",verificationToken:"",hasEncryptKey:!1,hasVerificationToken:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""},dingtalk:{clientId:"",clientSecret:"",hasClientSecret:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""}},ma={running:!1,status:"stopped",error:null};function Bb({projects:e=[]}){const{t}=Mt("settings"),[n,s]=l.useState("lark"),[o,a]=l.useState(yc),[i,c]=l.useState({lark:{...ma},dingtalk:{...ma}}),[d,u]=l.useState({lark:[],dingtalk:[]}),[p,m]=l.useState(!1),[h,g]=l.useState(!1),[x,S]=l.useState(!1),[k,I]=l.useState(!1),[A,w]=l.useState(null),[M,C]=l.useState(null),[b,R]=l.useState({userId:"",displayName:"",note:""}),B=l.useMemo(()=>e.map(N=>({label:N.displayName||N.name||N.path||N.fullPath,value:N.path||N.fullPath||""})).filter(N=>N.value),[e]),D=o[n]||yc[n],Z=i[n]||ma,z=d[n]||[],X=async(N,O=!1)=>{O||C(null);const[ne,ke,xe]=await Promise.all([le(`/api/channels/${N}/config`),le(`/api/channels/${N}/status`),le(`/api/channels/${N}/allowed-users`)]),P=await ne.json(),ae=await ke.json(),ee=await xe.json();P?.success&&P?.config&&a(Ne=>({...Ne,[N]:{...Ne[N],...P.config}})),ae?.success&&ae?.status&&c(Ne=>({...Ne,[N]:ae.status})),ee?.success&&u(Ne=>({...Ne,[N]:ee.users||[]}))},q=async(N=!1)=>{m(!0);try{await Promise.all(vc.map(O=>X(O,N)))}catch(O){C(O.message||t("channels.errors.loadFailed","加载渠道设置失败"))}finally{m(!1)}};l.useEffect(()=>{q()},[]);const re=N=>{a(O=>({...O,[n]:{...O[n],...N}}))},Se=async()=>{m(!0),w(null),C(null);try{const N=n==="dingtalk"?{clientId:D.clientId,clientSecret:D.clientSecret,defaultBackend:D.defaultBackend,defaultModel:D.defaultModel,defaultProjectPath:D.defaultProjectPath}:{appId:D.appId,appSecret:D.appSecret,encryptKey:D.encryptKey,verificationToken:D.verificationToken,defaultBackend:D.defaultBackend,defaultModel:D.defaultModel,defaultProjectPath:D.defaultProjectPath},O=await le(`/api/channels/${n}/config`,{method:"PUT",body:JSON.stringify(N)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||t("channels.errors.saveFailed","保存失败"));re(n==="dingtalk"?{...ne.config,clientSecret:""}:{...ne.config,appSecret:"",encryptKey:"",verificationToken:""}),w(t(`channels.messages.${n}.configSaved`,n==="dingtalk"?"DingTalk 配置已保存":"Lark 配置已保存")),await X(n,!0)}catch(N){C(N.message||t("channels.errors.saveFailed","保存失败"))}finally{m(!1)}},Ce=async()=>{if(n==="dingtalk"){const N=String(D.clientId||"").trim(),O=String(D.clientSecret||"").trim();if(!N||!O&&!D.hasClientSecret){C(t("channels.errors.testNeedCredentialsDingTalk","测试连接需要填写 Client ID 和 Client Secret"));return}}else{const N=String(D.appId||"").trim(),O=String(D.appSecret||"").trim();if(!N||!O&&!D.hasAppSecret){C(t("channels.errors.testNeedCredentials","测试连接需要填写 App ID 和 App Secret"));return}}g(!0),C(null),w(null);try{const N=await le(`/api/channels/${n}/test`,{method:"POST",body:JSON.stringify(n==="dingtalk"?{clientId:D.clientId,clientSecret:D.clientSecret}:{appId:D.appId,appSecret:D.appSecret})}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||t("channels.errors.testFailed","连接测试失败"));w(t(`channels.messages.${n}.testSuccess`,n==="dingtalk"?"DingTalk 连接测试成功":"Lark 连接测试成功"))}catch(N){C(N.message||t("channels.errors.testFailed","连接测试失败"))}finally{g(!1)}},ge=async()=>{S(!0),C(null),w(null);try{const N=await le(`/api/channels/${n}/start`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||t("channels.errors.startFailed","启动失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),w(t(`channels.messages.${n}.started`,n==="dingtalk"?"DingTalk 已启动":"Lark 已启动")),await X(n,!0)}catch(N){C(N.message||t("channels.errors.startFailed","启动失败"))}finally{S(!1)}},de=async()=>{I(!0),C(null),w(null);try{const N=await le(`/api/channels/${n}/stop`,{method:"POST"}),O=await N.json();if(!N.ok||!O.success)throw new Error(O.error||t("channels.errors.stopFailed","停止失败"));c(ne=>({...ne,[n]:O.status||ne[n]})),w(t(`channels.messages.${n}.stopped`,n==="dingtalk"?"DingTalk 已停止":"Lark 已停止")),await X(n,!0)}catch(N){C(N.message||t("channels.errors.stopFailed","停止失败"))}finally{I(!1)}},H=async()=>{if(!b.userId.trim()){C(t("channels.errors.userIdRequired","请输入用户ID"));return}m(!0),C(null),w(null);try{const O=await le(`/api/channels/${n}/allowed-users`,{method:"POST",body:JSON.stringify(b)}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||t("channels.errors.addUserFailed","新增用户失败"));R({userId:"",displayName:"",note:""}),w(t("channels.messages.userAdded","用户已添加")),await X(n,!0)}catch(O){C(O.message||t("channels.errors.addUserFailed","新增用户失败"))}finally{m(!1)}},Le=async N=>{m(!0),C(null);try{const O=await le(`/api/channels/${n}/allowed-users/${N.id}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!N.isActive})}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||t("channels.errors.toggleUserFailed","更新用户状态失败"));await X(n,!0)}catch(O){C(O.message||t("channels.errors.toggleUserFailed","更新用户状态失败"))}finally{m(!1)}},$=async N=>{if(window.confirm(t("channels.confirmDeleteUser","确定要删除这个用户ID吗?"))){m(!0),C(null);try{const O=await le(`/api/channels/${n}/allowed-users/${N}`,{method:"DELETE"}),ne=await O.json();if(!O.ok||!ne.success)throw new Error(ne.error||t("channels.errors.deleteUserFailed","删除用户失败"));await X(n,!0)}catch(O){C(O.message||t("channels.errors.deleteUserFailed","删除用户失败"))}finally{m(!1)}}};return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:t("channels.title","第三方 IM")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:t(`channels.platformDescriptions.${n}`,n==="dingtalk"?"配置 DingTalk 机器人连接、默认执行环境,并通过用户ID白名单控制访问。":"配置飞书机器人连接、默认执行环境,并通过用户ID白名单控制访问。")})]}),r.jsx("div",{className:"border-b border-border",children:r.jsx("div",{className:"flex items-end gap-1 -mb-px",role:"tablist","aria-label":t("channels.title","第三方 IM"),children:vc.map(N=>{const O=N===n;return r.jsx("button",{type:"button",role:"tab","aria-selected":O,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors rounded-t-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 ${O?"border-primary text-primary bg-primary/5":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>{s(N),w(null),C(null)},children:t(`channels.platforms.${N}`,N==="dingtalk"?"DingTalk / 钉钉":"Lark / 飞书")},N)})})}),(A||M)&&r.jsx("div",{className:`rounded-lg border p-3 text-sm ${M?"border-red-300 bg-red-50 text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300":"border-green-300 bg-green-50 text-green-700 dark:border-green-800 dark:bg-green-900/20 dark:text-green-300"}`,children:M||A}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.connection.title","连接配置")}),n==="dingtalk"?r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client ID"}),r.jsx(Pt,{value:D.clientId,onChange:N=>re({clientId:N.target.value}),placeholder:"dingxxxxxxxx"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client Secret"}),r.jsx(Pt,{type:"password",value:D.clientSecret,onChange:N=>re({clientSecret:N.target.value}),placeholder:D.hasClientSecret?"••••••••(已保存)":"输入 Client Secret"})]})]}):r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App ID"}),r.jsx(Pt,{value:D.appId,onChange:N=>re({appId:N.target.value}),placeholder:"cli_xxx"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"App Secret"}),r.jsx(Pt,{type:"password",value:D.appSecret,onChange:N=>re({appSecret:N.target.value}),placeholder:D.hasAppSecret?"••••••••(已保存)":"输入 App Secret"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:t("channels.defaults.backend","默认后端")}),r.jsx("select",{value:D.defaultBackend,onChange:N=>re({defaultBackend:N.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg",children:$b.map(N=>r.jsx("option",{value:N,children:N},N))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:t("channels.defaults.project","默认项目")}),r.jsxs("select",{value:D.defaultProjectPath,onChange:N=>re({defaultProjectPath:N.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg",children:[r.jsx("option",{value:"",children:t("channels.defaults.projectPlaceholder","请选择项目")}),B.map(N=>r.jsx("option",{value:N.value,children:N.label},N.value))]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Re,{onClick:Se,disabled:p,children:t("channels.actions.saveConfig","保存配置")}),r.jsx(Re,{variant:"outline",onClick:Ce,disabled:h,children:h?t("channels.actions.testing","测试中..."):t("channels.actions.test","测试连接")})]})]}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.runtime.title","运行状态")}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[t("channels.runtime.currentStatus","当前状态"),": ",r.jsx("span",{className:"font-medium text-foreground",children:Z.status||"stopped"}),Z.error?r.jsx("span",{className:"text-red-500 ml-2",children:Z.error}):null]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Re,{onClick:ge,disabled:x||Z.running,children:x?t("channels.actions.starting","启动中..."):t("channels.actions.start","启动")}),r.jsx(Re,{variant:"outline",onClick:de,disabled:k||!Z.running,children:k?t("channels.actions.stopping","停止中..."):t("channels.actions.stop","停止")}),r.jsx(Re,{variant:"ghost",onClick:()=>void X(n),disabled:p,children:t("channels.actions.refresh","刷新")})]})]}),r.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[r.jsx("h4",{className:"font-medium text-foreground",children:t("channels.allowedUsers.title","允许用户ID(白名单)")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-2",children:[r.jsx(Pt,{placeholder:t("channels.allowedUsers.userId","用户ID"),value:b.userId,onChange:N=>R(O=>({...O,userId:N.target.value}))}),r.jsx(Pt,{placeholder:t("channels.allowedUsers.displayName","显示名(可选)"),value:b.displayName,onChange:N=>R(O=>({...O,displayName:N.target.value}))}),r.jsx(Pt,{placeholder:t("channels.allowedUsers.note","备注(可选)"),value:b.note,onChange:N=>R(O=>({...O,note:N.target.value}))}),r.jsx(Re,{onClick:H,disabled:p,children:t("channels.allowedUsers.add","新增")})]}),r.jsx("div",{className:"space-y-2",children:z.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:t("channels.allowedUsers.empty","暂无白名单用户")}):z.map(N=>r.jsxs("div",{className:"border border-border rounded-lg p-3 flex flex-col md:flex-row md:items-center md:justify-between gap-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:N.userId}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[N.displayName||"-",N.note?` · ${N.note}`:""]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`text-xs px-2 py-1 rounded ${N.isActive?"bg-green-100 text-green-700 dark:bg-green-900/20 dark:text-green-300":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}`,children:N.isActive?t("channels.allowedUsers.active","启用"):t("channels.allowedUsers.inactive","停用")}),r.jsx(Re,{size:"sm",variant:"outline",onClick:()=>void Le(N),children:N.isActive?t("channels.allowedUsers.disable","停用"):t("channels.allowedUsers.enable","启用")}),r.jsx(Re,{size:"sm",variant:"ghost",onClick:()=>void $(N.id),children:t("channels.allowedUsers.delete","删除")})]})]},N.id))})]}),r.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/10 dark:border-primary/40 dark:bg-primary/15 p-4",children:[r.jsx("h5",{className:"font-medium text-foreground mb-2",children:t("channels.help.title","使用说明")}),r.jsxs("ul",{className:"text-sm text-muted-foreground list-disc pl-5 space-y-1",children:[r.jsx("li",{children:t(`channels.help.${n}.step1`,n==="dingtalk"?"未绑定用户给机器人发消息时,机器人会返回该用户的钉钉用户ID。":"未绑定用户给机器人发消息时,机器人会返回该用户的飞书用户ID。")}),r.jsx("li",{children:t(`channels.help.${n}.step2`,"管理员将该ID加入白名单后,用户即可正常对话。")}),r.jsx("li",{children:t(`channels.help.${n}.step3`,"请先配置默认项目,否则机器人不会执行任务。")})]})]})]})}function zb({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(sr,{className:"w-6 h-6"})})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(Vu,{project:s,command:c(),onComplete:u,minimal:!0})})]})})}function Xu({compact:e=!1}){const{i18n:t,t:n}=Mt("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(Dc,{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:sl.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:sl.map(o=>r.jsx("option",{value:o.value,children:o.nativeName},o.value))})]})})}function Ub({isOpen:e,onClose:t,projects:n=[],initialTab:s="appearance"}){const{isDarkMode:o,toggleDarkMode:a}=Ka(),{t:i}=Mt("settings"),[c,d]=l.useState([]),[u,p]=l.useState([]),[m,h]=l.useState(""),[g,x]=l.useState(""),[S,k]=l.useState(!1),[I,A]=l.useState(!1),[w,M]=l.useState(null),[C,b]=l.useState("name"),[R,B]=l.useState([]),[D,Z]=l.useState(!1),[z,X]=l.useState(null),[q,re]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[Se,Ce]=l.useState(!1),[ge,de]=l.useState({}),[H,Le]=l.useState({}),[$,N]=l.useState({}),[O,ne]=l.useState(s),[ke,xe]=l.useState(""),P=["appearance","api","channels"],[ae,ee]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[Ne,lt]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ge,Ke]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[qe,ct]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Et,Xe]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[kt,je]=l.useState([]),[Ve,jt]=l.useState("default"),[St,Dt]=l.useState(!1),[Y,oe]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[Ee,Ae]=l.useState(null),[Oe,tt]=l.useState(!1),[ue,dt]=l.useState(!1),[Ye,Qe]=l.useState(""),[Be,Lt]=l.useState(null),[Nt,vt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[$t,rt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[ft,qt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),It=async()=>{try{const L=await le("/api/codex/mcp/config/read");if(L.ok){const se=await L.json();if(se.success&&se.servers){je(se.servers);return}}const W=await le("/api/codex/mcp/cli/list");if(W.ok){const se=await W.json();if(se.success&&se.servers){const E=se.servers.map(J=>({id:J.name,name:J.name,type:J.type||"stdio",scope:"user",config:{command:J.command||"",args:J.args||[],env:J.env||{}}}));je(E)}}}catch(L){console.error("Error fetching Codex MCP servers:",L)}},ht=async()=>{try{const L=await le("/api/mcp/config/read");if(L.ok){const E=await L.json();if(E.success&&E.servers){B(E.servers);return}}const W=await le("/api/mcp/cli/list");if(W.ok){const E=await W.json();if(E.success&&E.servers){const J=E.servers.map(Q=>({id:Q.name,name:Q.name,type:Q.type,scope:"user",config:{command:Q.command||"",args:Q.args||[],env:Q.env||{},url:Q.url||"",headers:Q.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));B(J);return}}const se=await le("/api/mcp/servers?scope=user");if(se.ok){const E=await se.json();B(E.servers||[])}else console.error("Failed to fetch MCP servers")}catch(L){console.error("Error fetching MCP servers:",L)}},Qt=async L=>{try{z&&await Vt(z.id,"user");const W=await le("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:L.name,type:L.type,scope:L.scope,projectPath:L.projectPath,command:L.config?.command,args:L.config?.args||[],url:L.config?.url,headers:L.config?.headers||{},env:L.config?.env||{}})});if(W.ok){const se=await W.json();if(se.success)return await ht(),!0;throw new Error(se.error||"Failed to save server via Claude CLI")}else{const se=await W.json();throw new Error(se.error||"Failed to save server")}}catch(W){throw console.error("Error saving MCP server:",W),W}},Vt=async(L,W="user")=>{try{const se=await le(`/api/mcp/cli/remove/${L}?scope=${W}`,{method:"DELETE"});if(se.ok){const E=await se.json();if(E.success)return await ht(),!0;throw new Error(E.error||"Failed to delete server via Claude CLI")}else{const E=await se.json();throw new Error(E.error||"Failed to delete server")}}catch(se){throw console.error("Error deleting MCP server:",se),se}},Zt=async L=>{try{Ee&&await Rt(Ee.id);const W=await le("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:L.name,command:L.config?.command,args:L.config?.args||[],env:L.config?.env||{}})});if(W.ok){const se=await W.json();if(se.success)return await It(),!0;throw new Error(se.error||"Failed to save Codex MCP server")}else{const se=await W.json();throw new Error(se.error||"Failed to save server")}}catch(W){throw console.error("Error saving Codex MCP server:",W),W}},Rt=async L=>{try{const W=await le(`/api/codex/mcp/cli/remove/${L}`,{method:"DELETE"});if(W.ok){const se=await W.json();if(se.success)return await It(),!0;throw new Error(se.error||"Failed to delete Codex MCP server")}else{const se=await W.json();throw new Error(se.error||"Failed to delete server")}}catch(W){throw console.error("Error deleting Codex MCP server:",W),W}},T=()=>{oe({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Ae(null),Dt(!1)},G=async L=>{L.preventDefault(),tt(!0);try{Ee&&await Rt(Ee.name),await Zt(Y),T(),M("success")}catch(W){alert(`Error: ${W.message}`),M("error")}finally{tt(!1)}};l.useEffect(()=>{e&&(Me(),fe(),j(),F(),ne(P.includes(s)?s:"appearance"))},[e,s]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",ae),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ae]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",Ne.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ne]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ge.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ge]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",qe.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[qe]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Et),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Et]);const Me=async()=>{try{const L=localStorage.getItem("claude-settings");if(L){const se=JSON.parse(L);d(se.allowedTools||[]),p(se.disallowedTools||[]),k(se.skipPermissions||!1),b(se.projectSortOrder||"name")}else d([]),p([]),k(!1),b("name");const W=localStorage.getItem("codex-settings");if(W){const se=JSON.parse(W);jt(se.permissionMode||"default")}else jt("default");await ht(),await It()}catch(L){console.error("Error loading tool settings:",L),d([]),p([]),k(!1),b("name")}},fe=async()=>{try{const L=await le("/api/cli/claude/status");if(L.ok){const W=await L.json();vt({authenticated:W.authenticated,email:W.email,loading:!1,error:W.error||null})}else vt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Claude auth status:",L),vt({authenticated:!1,email:null,loading:!1,error:L.message})}},j=async()=>{try{const L=await le("/api/cli/codex/status");if(L.ok){const W=await L.json();rt({authenticated:W.authenticated,email:W.email,loading:!1,error:W.error||null})}else rt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Codex auth status:",L),rt({authenticated:!1,email:null,loading:!1,error:L.message})}},F=async()=>{try{const L=await le("/api/cli/gemini/status");if(L.ok){const W=await L.json();qt({authenticated:W.authenticated,email:W.email,loading:!1,error:W.error||null})}else qt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Gemini auth status:",L),qt({authenticated:!1,email:null,loading:!1,error:L.message})}},ve=L=>{L===0&&(M("success"),Ye==="claude"?fe():Ye==="codex"?j():Ye==="gemini"&&F())},ye=()=>{A(!0),M(null);try{const L={allowedTools:c,disallowedTools:u,skipPermissions:S,projectSortOrder:C,lastUpdated:new Date().toISOString()},W={permissionMode:Ve,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(L)),localStorage.setItem("codex-settings",JSON.stringify(W)),M("success"),setTimeout(()=>{t()},1e3)}catch(L){console.error("Error saving tool settings:",L),M("error")}finally{A(!1)}},ut=()=>{re({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),X(null),Z(!1),xe("")},U=async L=>{L.preventDefault(),Ce(!0);try{if(q.importMode==="json"){const W=await le("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:q.name,jsonConfig:q.jsonInput,scope:q.scope,projectPath:q.projectPath})});if(W.ok){const se=await W.json();if(se.success)await ht(),ut(),M("success");else throw new Error(se.error||"Failed to add server via JSON")}else{const se=await W.json();throw new Error(se.error||"Failed to add server")}}else await Qt(q),ut(),M("success")}catch(W){alert(`Error: ${W.message}`),M("error")}finally{Ce(!1)}},ot=(L,W)=>{re(se=>({...se,config:{...se.config,[L]:W}}))};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(Pc,{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(Re,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:r.jsx(sr,{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:()=>ne("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="appearance"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),r.jsxs("button",{onClick:()=>ne("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(Mc,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),r.jsxs("button",{onClick:()=>ne("channels"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${O==="channels"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(zf,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.channels","Channels")]})]})}),r.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[O==="appearance"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:O==="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(va,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(ba,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),r.jsx("div",{className:"space-y-4",children:r.jsx(Xu,{})}),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:C,onChange:L=>b(L.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:()=>ee(ae==="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":ae==="dark","aria-label":"Toggle editor theme",children:[r.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),r.jsx("span",{className:`${ae==="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:ae==="dark"?r.jsx(va,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(ba,{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:()=>lt(!Ne),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":Ne,"aria-label":"Toggle word wrap",children:[r.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),r.jsx("span",{className:`${Ne?"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(!Ge),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ge,"aria-label":"Toggle minimap",children:[r.jsx("span",{className:"sr-only",children:"Toggle minimap"}),r.jsx("span",{className:`${Ge?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),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:()=>ct(!qe),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":qe,"aria-label":"Toggle line numbers",children:[r.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),r.jsx("span",{className:`${qe?"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:Et,onChange:L=>Xe(L.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"})]})]})})]})]})}),D&&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(z?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Re,{variant:"ghost",size:"sm",onClick:ut,children:r.jsx(sr,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:U,className:"p-4 space-y-4",children:[!z&&r.jsxs("div",{className:"flex gap-2 mb-4",children:[r.jsx("button",{type:"button",onClick:()=>re(L=>({...L,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${q.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:()=>re(L=>({...L,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${q.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")})]}),q.importMode==="form"&&z&&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:[q.scope==="user"?r.jsx(ol,{className:"w-4 h-4"}):r.jsx(rn,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm",children:q.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),q.scope==="local"&&q.projectPath&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",q.projectPath]})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),q.importMode==="form"&&!z&&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:()=>re(L=>({...L,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${q.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(ol,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),r.jsx("button",{type:"button",onClick:()=>re(L=>({...L,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${q.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(rn,{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:q.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),q.scope==="local"&&!z&&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:q.projectPath,onChange:L=>re(W=>({...W,projectPath:L.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:q.scope==="local",children:[r.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),n.map(L=>r.jsx("option",{value:L.path||L.fullPath,children:L.displayName||L.name},L.name))]}),q.projectPath&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:q.projectPath})})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:q.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(Pt,{value:q.name,onChange:L=>{re(W=>({...W,name:L.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),q.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:q.type,onChange:L=>{re(W=>({...W,type:L.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"})]})]})]}),z&&q.raw&&q.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:z.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(q.raw,null,2)})]}),q.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:q.jsonInput,onChange:L=>{re(W=>({...W,jsonInput:L.target.value}));try{if(L.target.value.trim()){const W=JSON.parse(L.target.value);W.type?W.type==="stdio"&&!W.command?xe(i("mcpForm.validation.stdioRequiresCommand")):(W.type==="http"||W.type==="sse")&&!W.url?xe(i("mcpForm.validation.httpRequiresUrl",{type:W.type})):xe(""):xe(i("mcpForm.validation.missingType"))}}catch{L.target.value.trim()?xe(i("mcpForm.validation.invalidJson")):xe("")}},className:`w-full px-3 py-2 border ${ke?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary font-mono text-sm`,rows:"8",placeholder:`{
|
|
452
|
-
"type": "stdio",
|
|
453
|
-
"command": "/path/to/server",
|
|
454
|
-
"args": ["--api-key", "abc123"],
|
|
455
|
-
"env": {
|
|
456
|
-
"CACHE_DIR": "/tmp"
|
|
457
|
-
}
|
|
458
|
-
}`,required:!0}),ke&&r.jsx("p",{className:"text-xs text-red-500 mt-1",children:ke}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i("mcpForm.validation.jsonHelp"),r.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',r.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),q.importMode==="form"&&q.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(Pt,{value:q.config.command,onChange:L=>ot("command",L.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(q.config.args)?q.config.args.join(`
|
|
459
|
-
`):"",onChange:L=>ot("args",L.target.value.split(`
|
|
460
|
-
`).filter(W=>W.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`--api-key
|
|
461
|
-
abc123`})]})]}),q.importMode==="form"&&(q.type==="sse"||q.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(Pt,{value:q.config.url,onChange:L=>ot("url",L.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),q.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(q.config.env||{}).map(([L,W])=>`${L}=${W}`).join(`
|
|
462
|
-
`),onChange:L=>{const W={};L.target.value.split(`
|
|
463
|
-
`).forEach(se=>{const[E,...J]=se.split("=");E&&E.trim()&&(W[E.trim()]=J.join("=").trim())}),ot("env",W)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`API_KEY=your-key
|
|
464
|
-
DEBUG=true`})]}),q.importMode==="form"&&(q.type==="sse"||q.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(q.config.headers||{}).map(([L,W])=>`${L}=${W}`).join(`
|
|
465
|
-
`),onChange:L=>{const W={};L.target.value.split(`
|
|
466
|
-
`).forEach(se=>{const[E,...J]=se.split("=");E&&E.trim()&&(W[E.trim()]=J.join("=").trim())}),ot("headers",W)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary",rows:"3",placeholder:`Authorization=Bearer token
|
|
467
|
-
X-API-Key=your-key`})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(Re,{type:"button",variant:"outline",onClick:ut,children:i("mcpForm.actions.cancel")}),r.jsx(Re,{type:"submit",disabled:Se,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(Se?"mcpForm.actions.saving":z?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),St&&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(Ee?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Re,{variant:"ghost",size:"sm",onClick:T,children:r.jsx(sr,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:G,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(Pt,{value:Y.name,onChange:L=>oe(W=>({...W,name:L.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(Pt,{value:Y.config?.command||"",onChange:L=>oe(W=>({...W,config:{...W.config,command:L.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:(Y.config?.args||[]).join(`
|
|
468
|
-
`),onChange:L=>oe(W=>({...W,config:{...W.config,args:L.target.value.split(`
|
|
469
|
-
`).filter(se=>se.trim())}})),placeholder:`--port
|
|
470
|
-
3000`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),r.jsx("textarea",{value:Object.entries(Y.config?.env||{}).map(([L,W])=>`${L}=${W}`).join(`
|
|
471
|
-
`),onChange:L=>{const W={};L.target.value.split(`
|
|
472
|
-
`).forEach(se=>{const[E,...J]=se.split("=");E&&J.length>0&&(W[E.trim()]=J.join("=").trim())}),oe(se=>({...se,config:{...se.config,env:W}}))},placeholder:`API_KEY=xxx
|
|
473
|
-
DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[r.jsx(Re,{type:"button",variant:"outline",onClick:T,children:i("mcpForm.actions.cancel")}),r.jsx(Re,{type:"submit",disabled:Oe||!Y.name||!Y.config?.command,className:"bg-green-600 hover:bg-green-700 text-white",children:i(Oe?"mcpForm.actions.saving":Ee?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),O==="api"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(Fb,{})}),O==="channels"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(Bb,{projects:n})})]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[r.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[w==="success"&&r.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),i("saveStatus.success")]}),w==="error"&&r.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),r.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[r.jsx(Re,{variant:"outline",onClick:t,disabled:I,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),O!=="channels"&&r.jsx(Re,{onClick:ye,disabled:I,className:"flex-1 sm:flex-none h-10 bg-primary hover:bg-primary/90 disabled:opacity-50 touch-manipulation",children:I?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(zb,{isOpen:ue,onClose:()=>dt(!1),provider:Ye,project:Be,onComplete:ve,isAuthenticated:Ye==="claude"?Nt.authenticated:Ye==="codex"?$t.authenticated:!1},Ye)]}):null}const Wb=({isOpen:e,onToggle:t,autoExpandTools:n,onAutoExpandChange:s,showRawParameters:o,onShowRawParametersChange:a,showThinking:i,onShowThinkingChange:c,autoScrollToBottom:d,onAutoScrollChange:u,sendByCtrlEnter:p,onSendByCtrlEnterChange:m,isMobile:h})=>{const{t:g}=Mt("settings"),[x,S]=l.useState(e),[k,I]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:A}=Ka(),[w,M]=l.useState(()=>{const $=localStorage.getItem("quickSettingsHandlePosition");if($)try{return JSON.parse($).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[C,b]=l.useState(!1),[R,B]=l.useState(0),[D,Z]=l.useState(0),[z,X]=l.useState(!1),q=l.useRef(null),re=l.useRef({min:10,max:90}),Se=5;l.useEffect(()=>{S(e)},[e]),l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:w}))},[w]);const Ce=l.useCallback(()=>h?{bottom:`${window.innerHeight*w/100}px`}:{top:`${w}%`,transform:"translateY(-50%)"},[w,h]),ge=l.useCallback($=>{$.stopPropagation();const N=$.type.includes("touch")?$.touches[0].clientY:$.clientY;B(N),Z(w),X(!1),b(!1)},[w]),de=l.useCallback($=>{if(R===0)return;const N=$.type.includes("touch")?$.touches[0].clientY:$.clientY,O=Math.abs(N-R);if(!C&&O>Se&&(b(!0),X(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",$.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!C)return;$.type.includes("touch")&&$.preventDefault();const ne=N-R;let ke;h?ke=-(ne/window.innerHeight)*100:ke=ne/window.innerHeight*100;let xe=D+ke;xe=Math.max(re.current.min,Math.min(re.current.max,xe)),M(xe)},[C,R,D,h,Se]),H=l.useCallback(()=>{b(!1),B(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(R!==0){const $=ke=>de(ke),N=()=>H(),O=ke=>de(ke),ne=()=>H();return document.addEventListener("mousemove",$),document.addEventListener("mouseup",N),document.addEventListener("touchmove",O,{passive:!1}),document.addEventListener("touchend",ne),()=>{document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",O),document.removeEventListener("touchend",ne)}}},[R,de,H]);const Le=$=>{if(z){$.preventDefault(),X(!1);return}const N=!x;S(N),t(N)};return r.jsxs(r.Fragment,{children:[r.jsx("button",{ref:q,onClick:Le,onMouseDown:$=>{ge($)},onTouchStart:$=>{ge($)},className:`fixed ${x?"right-64":"right-0"} z-50 ${C?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${C?"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 ${C?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...Ce(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":g(C?"quickSettings.dragHandle.dragging":x?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:g(C?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:C?r.jsx(vf,{className:"h-5 w-5 text-primary"}):x?r.jsx(yn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):r.jsx(Tc,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),r.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${x?"translate-x-0":"translate-x-full"} ${h?"h-screen":""}`,children:r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:r.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[r.jsx(Hf,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),g("quickSettings.title")]})}),r.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${h?"pb-mobile-nav":""}`,children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.appearance")}),r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[A?r.jsx(va,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):r.jsx(ba,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.darkMode")]}),r.jsx(Bm,{})]}),r.jsx("div",{children:r.jsx(Xu,{compact:!0})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.toolDisplay")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Rc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoExpandTools")]}),r.jsx("input",{type:"checkbox",checked:n,onChange:$=>s($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(_c,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showRawParameters")]}),r.jsx("input",{type:"checkbox",checked:o,onChange:$=>a($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),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(Ac,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showThinking")]}),r.jsx("input",{type:"checkbox",checked:i,onChange:$=>c($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.viewOptions")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Jm,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoScrollToBottom")]}),r.jsx("input",{type:"checkbox",checked:d,onChange:$=>u($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.inputSettings")}),r.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(Dc,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.sendByCtrlEnter")]}),r.jsx("input",{type:"checkbox",checked:p,onChange:$=>m($.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:g("quickSettings.sendByCtrlEnterDescription")})]}),r.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:g("quickSettings.sections.whisperDictation")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:k==="default",onChange:()=>{I("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(Ps,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.default")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.defaultDescription")})]})]}),r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:k==="prompt",onChange:()=>{I("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(Ya,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.prompt")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.promptDescription")})]})]}),r.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:k==="vibe"||k==="instructions"||k==="architect",onChange:()=>{I("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(Xa,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.whisper.modes.vibe")]}),r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:g("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),x&&r.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:Le})]})},Qu=l.createContext({user:null,token:null,login:()=>{},register:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,error:null}),mo=()=>{const e=l.useContext(Qu);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Hb=({children:e})=>{const[t,n]=l.useState(null),[s,o]=l.useState(localStorage.getItem("auth-token")),[a,i]=l.useState(!0),[c,d]=l.useState(!1),[u,p]=l.useState(null);l.useEffect(()=>{m()},[]);const m=async()=>{try{if(i(!0),p(null),(await(await mt.auth.status()).json()).needsSetup){d(!0),i(!1);return}if(s)try{const A=await mt.auth.user();if(A.ok){const w=await A.json();n(w.user),d(!1)}else localStorage.removeItem("auth-token"),o(null),n(null)}catch(A){console.error("Token verification failed:",A),localStorage.removeItem("auth-token"),o(null),n(null)}}catch(k){console.error("[AuthContext] Auth status check failed:",k),p("Failed to check authentication status")}finally{i(!1)}},S={user:t,token:s,login:async(k,I)=>{try{p(null);const A=await mt.auth.login(k,I),w=await A.json();return A.ok?(o(w.token),n(w.user),localStorage.setItem("auth-token",w.token),{success:!0}):(p(w.error||"Login failed"),{success:!1,error:w.error||"Login failed"})}catch(A){console.error("Login error:",A);const w="Network error. Please try again.";return p(w),{success:!1,error:w}}},register:async(k,I)=>{try{p(null);const A=await mt.auth.register(k,I),w=await A.json();return A.ok?(o(w.token),n(w.user),d(!1),localStorage.setItem("auth-token",w.token),{success:!0}):(p(w.error||"Registration failed"),{success:!1,error:w.error||"Registration failed"})}catch(A){console.error("Registration error:",A);const w="Network error. Please try again.";return p(w),{success:!1,error:w}}},logout:()=>{o(null),n(null),localStorage.removeItem("auth-token"),s&&mt.auth.logout().catch(k=>{console.error("Logout endpoint error:",k)})},isLoading:a,needsSetup:c,error:u};return r.jsx(Qu.Provider,{value:S,children:e})},Zu=l.createContext(null),qb=()=>{const e=l.useContext(Zu);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},Vb=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},Gb=()=>{const e=l.useRef(null),t=l.useRef(!1),[n,s]=l.useState(null),[o,a]=l.useState(!1),i=l.useRef(null),c=l.useRef(!1),d=l.useRef([]),u=l.useRef([]),p=l.useRef(null),m=l.useRef(0),{token:h}=mo(),g=l.useCallback(()=>{if(p.current||t.current)return;const b=()=>{if(p.current=null,t.current){u.current=[];return}const R=u.current.shift();R&&(m.current+=1,s({...R,__messageSeq:m.current}),u.current.length>0&&(p.current=setTimeout(b,0)))};p.current=setTimeout(b,0)},[]),x=l.useCallback(b=>{u.current.push(b),g()},[g]),S=l.useCallback((b,R)=>{x({type:"connection-error",error:R,provider:b?.provider||(typeof b?.type=="string"?b.type.replace(/-command$/,""):"claude"),sessionId:b?.sessionId||b?.options?.sessionId||null,clientRequestId:b?.clientRequestId||null})},[x]),k=l.useCallback(b=>{b.timeoutId&&(clearTimeout(b.timeoutId),b.timeoutId=null)},[]),I=l.useCallback(b=>{if(b.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach(B=>{k(B),b.send(JSON.stringify(B.payload))})},[k]),A=l.useCallback(b=>{if(!b||typeof b!="object"||b.clientRequestId)return b;const R=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...b,clientRequestId:R}},[]),w=l.useCallback(()=>{if(t.current||c.current)return;const b=e.current;if(!(b&&(b.readyState===WebSocket.OPEN||b.readyState===WebSocket.CONNECTING)))try{const R=Vb(h);if(!R){d.current.splice(0,d.current.length).forEach(Z=>{k(Z),S(Z.payload,"No authentication token found for WebSocket connection")});return}c.current=!0;const B=new WebSocket(R);e.current=B,B.onopen=()=>{c.current=!1,a(!0),e.current=B,x({type:"ws-connection-state",state:"connected"}),I(B)},B.onmessage=D=>{try{const Z=JSON.parse(D.data);x(Z)}catch(Z){console.error("Error parsing WebSocket message:",Z)}},B.onclose=()=>{c.current=!1,a(!1),e.current===B&&(e.current=null),x({type:"ws-connection-state",state:"disconnected"}),i.current=setTimeout(()=>{t.current||w()},3e3)},B.onerror=D=>{console.error("WebSocket error:",D)}}catch(R){c.current=!1,console.error("Error creating WebSocket connection:",R)}},[k,S,I,h]);l.useEffect(()=>(t.current=!1,w(),()=>{c.current=!1,i.current&&clearTimeout(i.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[w,h]),l.useEffect(()=>()=>{t.current=!0,c.current=!1,i.current&&clearTimeout(i.current),p.current&&(clearTimeout(p.current),p.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(R=>k(R)),e.current&&(e.current.close(),e.current=null)},[k]);const M=l.useCallback(b=>{const R=A(b),B=e.current;if(B&&B.readyState===WebSocket.OPEN){try{B.send(JSON.stringify(R))}catch(Z){throw Z}return}x({type:"ws-connection-state",state:"connecting",sessionId:R?.sessionId||R?.options?.sessionId||null,clientRequestId:R?.clientRequestId||null});const D={payload:R,timeoutId:setTimeout(()=>{d.current=d.current.filter(Z=>Z!==D),S(R,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(D),w()},[w,S,x,A]);return l.useMemo(()=>({ws:e.current,sendMessage:M,latestMessage:n,isConnected:o}),[M,n,o])},Kb=({children:e})=>{const t=Gb();return r.jsx(Zu.Provider,{value:t,children:e})},Jb=()=>{const{t:e}=Mt("auth"),[t,n]=l.useState(""),[s,o]=l.useState(""),[a,i]=l.useState(""),[c,d]=l.useState(!1),[u,p]=l.useState(""),{register:m}=mo(),h=async g=>{if(g.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 x=await m(t,s);x.success||p(x.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(es,{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:h,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:g=>n(g.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:g=>o(g.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:g=>i(g.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")})})]})})})},Yb=()=>{const{t:e}=Mt("auth"),[t,n]=l.useState(""),[s,o]=l.useState(""),[a,i]=l.useState(!1),[c,d]=l.useState(""),{login:u}=mo(),p=async m=>{if(m.preventDefault(),d(""),!t||!s){d(e("login.errors.requiredFields"));return}i(!0);const h=await u(t,s);h.success||d(h.error),i(!1)};return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx("div",{className:"w-full max-w-md",children:r.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:r.jsx(Hn,{className:"w-8 h-8 text-primary-foreground"})})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e("login.title")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:e("login.description")})]}),r.jsxs("form",{onSubmit:p,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:e("login.username")}),r.jsx("input",{type:"text",id:"username",value:t,onChange:m=>n(m.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.username"),required:!0,disabled:a})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:e("login.password")}),r.jsx("input",{type:"password",id:"password",value:s,onChange:m=>o(m.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.password"),required:!0,disabled:a})]}),c&&r.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:r.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),r.jsx("button",{type:"submit",disabled:a,className:"w-full bg-primary hover:bg-primary/90 disabled:bg-primary/60 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:e(a?"login.loading":"login.submit")})]}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:e("login.footer")})})]})})})},Xb=()=>r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:r.jsx(Hn,{className:"w-8 h-8 text-primary-foreground"})})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Axhub Genie"}),r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),r.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),Qb=({children:e})=>{const{user:t,isLoading:n,needsSetup:s}=mo();return n?r.jsx(Xb,{}):s?r.jsx(Jb,{}):t?e:r.jsx(Yb,{})};function xn(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 Zb=3e3;function On(e){return typeof e=="string"&&e.trim().length>0}function ew(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function tw(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function rw({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(On(s)?s.trim():null),[p,m]=l.useState(null),[h,g]=l.useState(!1),x=l.useMemo(()=>e===!0&&On(t)&&On(n),[e,t,n]);l.useEffect(()=>{u.current=On(s)?s.trim():null},[s]);const S=l.useCallback(C=>{d.current+=1,m({...C,__messageSeq:d.current})},[]),k=l.useCallback(()=>{const C=o.current;C&&(C.close(),o.current=null),g(!1),i.current=!1},[]),I=l.useCallback((C,b=o.current)=>!C||!b||b.readyState!==WebSocket.OPEN?!1:(b.send(JSON.stringify({type:"integration.ack",requestId:C,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),A=l.useCallback((C=o.current)=>{!x||!C||C.readyState!==WebSocket.OPEN||C.send(JSON.stringify({type:"integration.connect",requestId:ew("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:n.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:On(s)?s.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[t,n,x,s]),w=l.useCallback(()=>{if(!x||c.current||i.current)return;const C=o.current;if(C&&(C.readyState===WebSocket.OPEN||C.readyState===WebSocket.CONNECTING))return;const b=tw();if(!b)return;i.current=!0;const R=new WebSocket(b);o.current=R,R.onopen=()=>{i.current=!1,o.current=R,g(!0),A(R)},R.onmessage=B=>{try{const D=JSON.parse(B.data);D&&typeof D.type=="string"&&D.type.startsWith("integration.")&&(D.type==="integration.ping"&&I(D.requestId||null,R),S(D))}catch(D){console.error("Error parsing integration WebSocket message:",D)}},R.onclose=()=>{o.current===R&&(o.current=null),i.current=!1,g(!1),!c.current&&x&&(a.current=setTimeout(()=>{a.current=null,w()},Zb))},R.onerror=B=>{console.error("Integration WebSocket error:",B)}},[A,S,x,I]);l.useEffect(()=>{if(c.current=!1,!x){a.current&&(clearTimeout(a.current),a.current=null),k();return}return w(),()=>{a.current&&(clearTimeout(a.current),a.current=null),k()}},[k,w,x]),l.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),k()},[k]),l.useEffect(()=>{x&&A()},[A,x,s]);const M=l.useCallback(C=>{const b=o.current;return!b||b.readyState!==WebSocket.OPEN?!1:(b.send(JSON.stringify(C)),!0)},[]);return{integrationWs:o.current,latestIntegrationMessage:p,sendIntegrationMessage:M,isIntegrationConnected:h,isIntegrationEnabled:x}}function bc(){const e=cm(),{sessionId:t}=dm(),[n]=um(),{t:s}=Mt("common");l.useRef(0);const{updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c}=Yu(),[d,u]=l.useState(!1),[p,m]=l.useState([]),[h,g]=l.useState(null),[x,S]=l.useState(null),[k,I]=l.useState(0),[A,w]=l.useState("chat"),[M,C]=l.useState(!1),b=M&&!1,[R,B]=l.useState(!1),[D,Z]=l.useState(!0),[z,X]=l.useState(null),[q,re]=l.useState(!1),[Se,Ce]=l.useState(!1),[ge,de]=l.useState("appearance"),[H,Le]=l.useState(!1),[$,N]=xn("autoExpandTools",!1),[O,ne]=xn("showRawParameters",!1),[ke,xe]=xn("showThinking",!0),[P,ae]=xn("autoScrollToBottom",!0),[ee,Ne]=xn("sendByCtrlEnter",!1),[lt,Ge]=xn("sidebarVisible",!0),[Ke,qe]=l.useState(!1),[ct,Et]=l.useState(new Set),[Xe,kt]=l.useState(new Set),je=l.useRef({sessionId:null,status:"idle"}),Ve=l.useCallback((E,J="claude")=>{if(!E)return J;try{const Q=localStorage.getItem("session-provider-map");if(!Q)return J;const be=JSON.parse(Q)?.[E];return typeof be=="string"&&be?be:J}catch{return J}},[]),[jt,St]=l.useState(0),Dt=l.useRef({selectionKey:null}),Y=l.useRef({attemptedKeys:new Set}),oe=n.get("cwd")||n.get("workdir"),Ee=n.get("project")||n.get("projectName"),Ae=n.get("provider")||n.get("tool")||n.get("cli");n.get("model");const Oe=n.get("context"),tt=n.get("prompt"),ue=n.get("integrationWs"),dt=n.get("integrationClientId"),Ye=n.get("integrationChannel"),Qe=n.toString(),Lt=p.find(E=>!!(oe&&(E.fullPath===oe||E.path===oe)||Ee&&(E.fullPath===Ee||E.path===Ee)))?.name||null,Nt=l.useCallback((E,J)=>{const Q=n.toString(),he=Q?`${E}?${Q}`:E;e(he,J)},[e,n]),{ws:vt,sendMessage:$t,latestMessage:rt}=qb(),{latestIntegrationMessage:ft,sendIntegrationMessage:qt}=rw({enabled:ue==="1",clientId:dt,channel:Ye,sessionId:x?.id||t||null}),It=l.useCallback(E=>typeof E!="string"?!1:/^new-session-\d+$/i.test(E)||/^codex-\d+$/i.test(E),[]),ht=l.useRef(null),[Qt,Vt]=l.useState(!1);l.useEffect(()=>{A==="files"&&w("chat")},[A]),l.useEffect(()=>{const E=()=>{const J=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");Vt(J),document.addEventListener("touchstart",{}),J?(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 E(),window.matchMedia("(display-mode: standalone)").addEventListener("change",E),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",E)}},[]),l.useEffect(()=>{const E=()=>{C(window.innerWidth<768)};return E(),window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[]),l.useEffect(()=>{G()},[]),l.useEffect(()=>{if(!oe&&!Ee||p.length===0)return;const E=`${oe||""}::${Ee||""}`;if(Dt.current.selectionKey===E)return;if(x){Dt.current.selectionKey=E;return}let J=null;if(oe&&(J=p.find(Q=>Q.fullPath===oe||Q.path===oe)),!J&&Ee){const Q=Ee.trim().toLowerCase();J=p.find(he=>[he.name,he.displayName,he.path,he.fullPath].some(te=>typeof te=="string"&&te.toLowerCase()===Q))}J&&g(J),Dt.current.selectionKey=E},[oe,Ee,p,x]),l.useEffect(()=>{if(!oe||!oe.trim()||D||x)return;const E=oe.trim();if(p.some(te=>te.fullPath===E||te.path===E))return;const Q=`cwd:${E}`;if(Y.current.attemptedKeys.has(Q))return;Y.current.attemptedKeys.add(Q);let he=!1;return(async()=>{try{const te=await mt.createProject(E),Je=await te.json().catch(()=>({}));if(!te.ok){const gt=Je?.error||"Unknown error";if(gt.includes("Project already configured")){await G();return}console.warn(`[URL] Failed to auto-create project for cwd "${E}": ${gt}`);return}if(he)return;Je?.project&&g(Je.project),await G()}catch(te){console.error(`[URL] Error auto-creating project for cwd "${E}":`,te)}})(),()=>{he=!0}},[oe,p,D,x]);const Zt=(E,J,Q,he)=>{if(!Q||!he)return!0;const be=E?.find(We=>We.name===Q.name),te=J?.find(We=>We.name===Q.name);if(!be||!te)return!1;const Je=We=>[...We.sessions||[],...We.codexSessions||[],...We.geminiSessions||[],...We.opencodeSessions||[]].find(Ct=>Ct.id===he.id),gt=Je(be),yt=Je(te);return!gt||!yt?!1:gt.id===yt.id&>.title===yt.title&>.created_at===yt.created_at&>.updated_at===yt.updated_at},Rt=(E,J)=>!E||!J?E!==J:E.name!==J.name||E.displayName!==J.displayName||E.fullPath!==J.fullPath||E.path!==J.path,T=E=>{if(!E)return!1;if(t===E)return!0;const J=je.current;return J?.sessionId===E&&J?.status!=="missing"&&J?.status!=="error"?!0:ct.has(E)||Xe.has(E)};l.useEffect(()=>{if(rt){if(rt.type==="loading_progress"){ht.current&&(clearTimeout(ht.current),ht.current=null),X(rt),rt.phase==="complete"&&(ht.current=setTimeout(()=>{X(null),ht.current=null},500));return}if(rt.type==="projects_updated"){if(rt.changedFile&&x&&h){const he=rt.changedFile.replace(/\\/g,"/").split("/"),be=he[he.length-1]||"",te=be.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]||be.replace(".jsonl","");if((rt.changedSessionId||te)===x.id){const gt=ct.has(x.id),yt=x.__provider==="codex";(!gt||yt)&&St(nt=>nt+1)}}if(x&&ct.has(x.id)||ct.size>0&&Array.from(ct).some(Q=>Q.startsWith("new-session-"))){const Q=rt.projects;if(!Zt(p,Q,h,x))return}const J=rt.projects;if(m(J),h){const Q=J.find(he=>he.name===h.name);if(Q&&(Rt(h,Q)&&g(Q),x)){const be=[...Q.sessions||[],...Q.codexSessions||[],...Q.geminiSessions||[],...Q.opencodeSessions||[]].find(te=>te.id===x.id);if(!be)T(x.id)||S(null);else{const te={...be,__provider:x.__provider||Ve(be.id,"claude"),__projectName:x.__projectName||Q.name};(te.title!==x.title||te.updated_at!==x.updated_at||te.__provider!==x.__provider||te.__projectName!==x.__projectName)&&S(te)}}}}}return()=>{ht.current&&(clearTimeout(ht.current),ht.current=null)}},[ct,rt,Xe,Ve,h,x,t]);const G=async(E={})=>{const{background:J=!1}=E;try{J||Z(!0);const he=await(await mt.projects()).json();m(be=>be.length===0||he.some((Je,gt)=>{const yt=be[gt];return yt?Je.name!==yt.name||Je.displayName!==yt.displayName||Je.fullPath!==yt.fullPath||JSON.stringify(Je.sessionMeta)!==JSON.stringify(yt.sessionMeta)||JSON.stringify(Je.sessions)!==JSON.stringify(yt.sessions)||JSON.stringify(Je.codexSessions)!==JSON.stringify(yt.codexSessions)||JSON.stringify(Je.geminiSessions)!==JSON.stringify(yt.geminiSessions)||JSON.stringify(Je.opencodeSessions)!==JSON.stringify(yt.opencodeSessions):!0})||he.length!==be.length?he:be)}catch(Q){console.error("Error fetching projects:",Q)}finally{J||Z(!1)}};window.refreshProjects=(E={})=>G({background:!0,...E}),window.openSettings=l.useCallback((E="appearance")=>{de(E),Ce(!0)},[]),l.useEffect(()=>{if(!t||p.length===0)return;const E=x?.id||null;h?.name;const J=E!==t,Q=Ae||x?.__provider||localStorage.getItem("selected-provider")||"claude",he=Ve(t,Q),be=`${t}::${Qe}`,te=It(t),Je=(nt,We,Ot)=>{if(!nt||!We)return!1;const Ct=p.find(Ft=>Ft.name===nt.name)||nt,pr={...We,__provider:Ot||he,__projectName:Ct.name};return g(Ft=>Ft?.name===Ct.name?Ft:Ct),S(Ft=>Ft?.id===pr.id&&Ft?.__provider===pr.__provider&&Ft?.__projectName===pr.__projectName?Ft:pr),J&&w("chat"),je.current={sessionId:t,status:"resolved",resolutionKey:be},!0};for(const nt of p){const We=[{items:nt.sessions,provider:Ve(t,Q)},{items:nt.codexSessions,provider:"codex"},{items:nt.geminiSessions,provider:"gemini"},{items:nt.opencodeSessions,provider:"opencode"}];for(const Ot of We){const Ct=Ot.items?.find(qr=>qr.id===t);if(Ct){Je(nt,Ct,Ot.provider);return}}}if(h&&(S({id:t,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:he,__projectName:h.name}),J&&w("chat"),je.current={sessionId:t,status:"placeholder",resolutionKey:be}),te||je.current.sessionId===t&&je.current.status==="resolving"&&je.current.resolutionKey===be)return;je.current={sessionId:t,status:"resolving",resolutionKey:be};let gt=!1;return(async()=>{try{const nt=await mt.resolveSession(t,he),We=await nt.json().catch(()=>({}));if(gt)return;if(!nt.ok||!We?.found||!We?.project||!We?.session){je.current={sessionId:t,status:"missing",resolutionKey:be};return}if(We?.provider)try{const Ft=localStorage.getItem("session-provider-map"),Mn=Ft?JSON.parse(Ft):{};Mn[t]=We.provider,localStorage.setItem("session-provider-map",JSON.stringify(Mn))}catch{}if(!Je(We.project,We.session,We.provider||he))return;const Ct=new URLSearchParams(Qe);(We.project.fullPath||We.project.path)&&Ct.set("project",We.project.fullPath||We.project.path),We.provider&&Ct.set("provider",We.provider);const qr=`/session/${t}${Ct.toString()?`?${Ct.toString()}`:""}`,pr=`${window.location.pathname}${window.location.search}`;qr!==pr&&e(qr,{replace:!0})}catch(nt){gt||(console.error("Error resolving session route:",nt),je.current={sessionId:t,status:"error",resolutionKey:be})}})(),()=>{gt=!0}},[It,e,p,Ve,Qe,h?.name,x?.id,t]);const Me=E=>{g(E),S(null),Nt("/"),M&&B(!1)},fe=E=>{if(S(E),A!=="git"&&A!=="preview"&&w("chat"),M){const J=E.__projectName,Q=h?.name;J!==Q&&B(!1)}Nt(`/session/${E.id}`)},j=E=>{if(E?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${E.name}`),localStorage.removeItem(`draft_input_${E.name}`)}catch(J){console.warn("Failed to clear local chat cache for new session:",J)}g(E),S(null),I(J=>J+1),w("chat"),Nt("/"),M&&B(!1)},F=E=>{x?.id===E&&(S(null),Nt("/")),m(J=>J.map(Q=>({...Q,sessions:Q.sessions?.filter(he=>he.id!==E)||[],sessionMeta:{...Q.sessionMeta,total:Math.max(0,(Q.sessionMeta?.total||0)-1)}})))},ve=async()=>{try{const J=await(await mt.projects()).json();if(m(Q=>J.some((be,te)=>{const Je=Q[te];return Je?be.name!==Je.name||be.displayName!==Je.displayName||be.fullPath!==Je.fullPath||JSON.stringify(be.sessionMeta)!==JSON.stringify(Je.sessionMeta)||JSON.stringify(be.sessions)!==JSON.stringify(Je.sessions):!0})||J.length!==Q.length?J:Q),h){const Q=J.find(he=>he.name===h.name);if(Q&&(Rt(h,Q)&&g(Q),x)){const be=[...Q.sessions||[],...Q.codexSessions||[],...Q.geminiSessions||[],...Q.opencodeSessions||[]].find(te=>te.id===x.id);if(!be)T(x.id)||S(null);else{const te={...be,__provider:x.__provider||Ve(be.id,"claude"),__projectName:x.__projectName||Q.name};(te.title!==x.title||te.updated_at!==x.updated_at||te.__provider!==x.__provider||te.__projectName!==x.__projectName)&&S(te)}}}}catch(E){console.error("Error refreshing sidebar:",E)}},ye=E=>{h?.name===E&&(g(null),S(null),Nt("/")),m(J=>J.filter(Q=>Q.name!==E))},ut=l.useCallback(E=>{E&&Et(J=>new Set([...J,E]))},[]),U=l.useCallback(E=>{E&&Et(J=>{const Q=new Set(J);return Q.delete(E),Q})},[]),ot=l.useCallback(E=>{E&&kt(J=>new Set([...J,E]))},[]),L=l.useCallback(E=>{E&&kt(J=>{const Q=new Set(J);return Q.delete(E),Q})},[]),W=l.useCallback((E,J=null)=>{E&&(Et(Q=>{const he=new Set;for(const be of Q)J&&be===J||be.startsWith("new-session-")||he.add(be);return he.add(E),he}),kt(Q=>{const he=new Set;for(const be of Q)J&&be===J||be.startsWith("new-session-")||he.add(be);return he.add(E),he}))},[]),se=()=>{const{t:E}=Mt("common"),[J,Q]=l.useState(!1),[he,be]=l.useState(""),[te,Je]=l.useState("");if(!d)return null;const gt=nt=>nt?nt.replace(/\b[0-9a-f]{40}\b/gi,"").replace(/(?:^|\s|-)([0-9a-f]{7,10})\b/gi,"").replace(/\*\*Full Changelog\*\*:.*$/gim,"").replace(/https?:\/\/github\.com\/[^\/]+\/[^\/]+\/compare\/[^\s)]+/gi,"").replace(/\n\s*\n\s*\n/g,`
|
|
474
|
-
|
|
475
|
-
`).trim():"",yt=async()=>{Q(!0),be(`Starting update...
|
|
476
|
-
`),Je("");try{const nt=await le("/api/system/update",{method:"POST"}),We=await nt.json();nt.ok?(be(Ot=>Ot+We.output+`
|
|
477
|
-
`),be(Ot=>Ot+`
|
|
478
|
-
✅ Update completed successfully!
|
|
479
|
-
`),be(Ot=>Ot+`Please restart the server to apply changes.
|
|
480
|
-
`)):(Je(We.error||"Update failed"),be(Ot=>Ot+`
|
|
481
|
-
❌ Update failed: `+(We.error||"Unknown error")+`
|
|
482
|
-
`))}catch(nt){Je(nt.message),be(We=>We+`
|
|
483
|
-
❌ Update failed: `+nt.message+`
|
|
484
|
-
`)}finally{Q(!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":E("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:E("versionUpdate.title")}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:c?.title||E("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:E("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:E("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:E("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:[E("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:gt(c.body)})})]}),he&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:E("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:he})})]}),!J&&!he&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:E("versionUpdate.manualUpgrade")}),r.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:r.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"npm update -g @axhub/genie"})}),r.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:E("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:E(he?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!he&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>{navigator.clipboard.writeText("npm update -g @axhub/genie")},className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:E("versionUpdate.buttons.copyCommand")}),r.jsx("button",{onClick:yt,disabled:J,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:J?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),E("versionUpdate.buttons.updating")]}):E("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:[!M&&r.jsx("div",{className:`chat-sidebar h-full flex-shrink-0 overflow-hidden transition-all duration-300 ${lt?"w-[22rem]":"w-[4.25rem]"}`,children:r.jsx("div",{className:"h-full overflow-hidden",children:lt?r.jsx(hl,{projects:p,selectedProject:h,selectedSession:x,onProjectSelect:Me,onSessionSelect:fe,onNewSession:j,onSessionDelete:F,onProjectDelete:ye,isLoading:D,loadingProgress:z,onRefresh:ve,onShowSettings:()=>Ce(!0),updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:Qt,isMobile:M,onToggleSidebar:()=>Ge(!1),lockedProjectName:Lt,showNewProject:Ke,setShowNewProject:qe}):r.jsxs("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:[r.jsx("button",{onClick:()=>Ge(!0),className:"flex h-10 w-10 items-center justify-center rounded-xl bg-background/80 text-foreground shadow-sm transition-colors duration-200 hover:bg-background","aria-label":s("versionUpdate.ariaLabels.showSidebar"),title:s("versionUpdate.ariaLabels.showSidebar"),children:r.jsx(yn,{className:"w-4 h-4 text-foreground"})}),r.jsx("button",{onClick:()=>Ce(!0),className:"rounded-xl bg-background/80 p-2 text-muted-foreground shadow-sm transition-colors duration-200 hover:bg-background hover:text-foreground","aria-label":s("versionUpdate.ariaLabels.settings"),title:s("versionUpdate.ariaLabels.settings"),children:r.jsx(Pc,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})}),o&&r.jsxs("button",{onClick:()=>u(!0),className:"relative rounded-xl bg-background/80 p-2 text-muted-foreground shadow-sm transition-colors duration-200 hover:bg-background hover:text-foreground","aria-label":s("versionUpdate.ariaLabels.updateAvailable"),title:s("versionUpdate.ariaLabels.updateAvailable"),children:[r.jsx(Ya,{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"})]})]})})}),M&&r.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${R?"opacity-100 visible":"opacity-0 invisible"}`,children:[r.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:E=>{E.stopPropagation(),B(!1)},onTouchStart:E=>{E.preventDefault(),E.stopPropagation(),B(!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 ${R?"translate-x-0":"-translate-x-full"}`,onClick:E=>E.stopPropagation(),onTouchStart:E=>E.stopPropagation(),children:r.jsx(hl,{projects:p,selectedProject:h,selectedSession:x,onProjectSelect:Me,onSessionSelect:fe,onNewSession:j,onSessionDelete:F,onProjectDelete:ye,isLoading:D,loadingProgress:z,onRefresh:ve,onShowSettings:()=>Ce(!0),updateAvailable:o,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:Qt,isMobile:M,onToggleSidebar:()=>Ge(!1),lockedProjectName:Lt,showNewProject:Ke,setShowNewProject:qe})})]}),r.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:r.jsx(Ob,{selectedProject:h,selectedSession:x,activeTab:A,setActiveTab:w,ws:vt,sendMessage:$t,latestMessage:rt,isMobile:M,isPWA:Qt,onMenuClick:()=>B(!0),isLoading:D,onInputFocusChange:re,onSessionActive:ut,onSessionInactive:U,onSessionProcessing:ot,onSessionNotProcessing:L,processingSessions:Xe,onReplaceTemporarySession:W,onNavigateToSession:E=>Nt(`/session/${E}`),onShowSettings:()=>Ce(!0),autoExpandTools:$,showRawParameters:O,showThinking:ke,autoScrollToBottom:P,sendByCtrlEnter:ee,externalMessageUpdate:jt,urlContext:Oe,urlPrompt:tt,integrationClientId:dt,latestIntegrationMessage:ft,sendIntegrationMessage:qt,onShowNewProject:()=>qe(!0),onNewSession:j,newSessionResetNonce:k})}),b,A==="chat"&&r.jsx(Wb,{isOpen:H,onToggle:Le,autoExpandTools:$,onAutoExpandChange:N,showRawParameters:O,onShowRawParametersChange:ne,showThinking:ke,onShowThinkingChange:xe,autoScrollToBottom:P,onAutoScrollChange:ae,sendByCtrlEnter:ee,onSendByCtrlEnterChange:Ne,isMobile:M}),r.jsx(Ub,{isOpen:Se,onClose:()=>Ce(!1),projects:p,initialTab:ge}),r.jsx(se,{})]})}function hw(){return r.jsx(zm,{i18n:Gm,children:r.jsx(Um,{children:r.jsx(Hb,{children:r.jsx(Kb,{children:r.jsx(Qb,{children:r.jsx(im,{basename:window.__ROUTER_BASENAME__||"",children:r.jsxs(lm,{children:[r.jsx(Vo,{path:"/",element:r.jsx(bc,{})}),r.jsx(Vo,{path:"/session/:sessionId",element:r.jsx(bc,{})}),r.jsx(Vo,{path:"/review",element:r.jsx(Wm,{})})]})})})})})})})}export{hw as default};
|