@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
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import{j as r,T as Ki,P as Gi,E as Xt,S as hn,F as io,g as cu,V as lo,a as Ms,R as Jn,D as fr,G as Ds,W as Ps,l as Vi,h as os,C as du,b as uu,c as Ji,d as qr,e as pu,f as mu,u as fu,i as hu,k as wa,s as gu,m as xu,n as yu,o as vu,p as bu,q as wu,r as ku,t as ju,v as Su,w as Nu,x as Cu,y as Eu}from"./vendor-codemirror-CyOKkaQZ.js";import{a as l,c as Au,R as gn,d as Po,g as Yi,B as Iu,e as _u,f as Ro,u as Tu,h as Mu,i as Du}from"./vendor-react-CP4yFTs7.js";import{bJ as qe,bK as Pr,bL as Yn,bM as Je,bN as Xi,bO as Gt,bP as co,bQ as Rs,bR as tr,bS as Pu,bT as Ru,bU as hr,bV as Lu,bW as Qi,bX as Ou,bY as Fu,bZ as $u,b_ as Bu,b$ as zu,c0 as Uu,c1 as Wu,c2 as Hu,c3 as qu,c4 as ht,c5 as Ls,c6 as kt,c7 as rr,c8 as Ku,c9 as Ge,ca as un,cb as ss,cc as vr,cd as Zi,ce as Os,cf as Gu,cg as Vu,ch as Ju,ci as Yu,cj as Xu,ck as Qu,cl as Zu,cm as ep,cn as tp,co as rp,cp as np,cq as op,cr as sp,cs as ka,ct as ja,cu as Sa,cv as Lo,cw as ap,cx as ip,cy as lp,cz as cp,cA as dp,cB as Rr,cC as up,cD as el,cE as Fs,cF as pp,cG as Na,cH as mp,I as fp,T as hp,U as gp}from"./mermaid-GHXKKRXX-CK8m3lad.js";import{r as xp,a as yp,b as vp}from"./vendor-xterm-DfcmCpbH.js";import{l as Ca,i as bp}from"./index-DW5pGgQ_.js";const wp=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],kp=qe("arrow-down",wp);const jp=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],tl=qe("chevron-left",jp);const Sp=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Wr=qe("chevron-right",Sp);const Np=[["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"}]],as=qe("download",Np);const Cp=[["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"}]],_n=qe("ellipsis",Cp);const Ep=[["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"}]],is=qe("external-link",Ep);const Ap=[["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"}]],rl=qe("eye",Ap);const Ip=[["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"}]],_p=qe("eye-off",Ip);const Tp=[["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"}]],Mp=qe("file-pen-line",Tp);const Dp=[["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"}]],Pp=qe("file-plus-2",Dp);const Rp=[["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"}]],Lp=qe("file-search",Rp);const Op=[["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"}]],_r=qe("folder-open",Op);const Fp=[["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"}]],Ar=qe("folder-plus",Fp);const $p=[["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"}]],Oo=qe("folder",$p);const Bp=[["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"}]],Fo=qe("git-branch",Bp);const zp=[["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"}]],$o=qe("git-commit-horizontal",zp);const Up=[["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"}]],Wp=qe("grip-vertical",Up);const Hp=[["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"}]],Ea=qe("history",Hp);const qp=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Kp=qe("info",qp);const Gp=[["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"}]],nl=qe("key",Gp);const Vp=[["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"}]],ol=qe("languages",Vp);const Jp=[["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"}]],Aa=qe("list-todo",Jp);const Yp=[["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"}]],sl=qe("maximize-2",Yp);const Xp=[["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"}]],Qp=qe("message-square-plus",Xp);const Zp=[["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"}]],em=qe("message-square",Zp);const tm=[["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"}]],Vn=qe("mic",tm);const rm=[["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"}]],nm=qe("minimize-2",rm);const om=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],ls=qe("moon",om);const sm=[["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"}]],Ia=qe("pen-line",sm);const am=[["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"}]],_a=qe("pen",am);const im=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Kr=qe("plus",im);const lm=[["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"}]],cr=qe("refresh-cw",lm);const cm=[["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"}]],dm=qe("save",cm);const um=[["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"}]],pm=qe("server",um);const mm=[["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"}]],al=qe("settings",mm);const fm=[["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"}]],hm=qe("settings-2",fm);const gm=[["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"}]],xm=qe("square-terminal",gm);const ym=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],Ta=qe("star",ym);const vm=[["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"}]],cs=qe("sun",vm);const bm=[["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"}]],Yt=qe("trash-2",bm);const wm=[["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"}]],ds=qe("triangle-alert",wm);const km=[["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"}]],Tn=qe("upload",km);const jm=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wt=qe("x",jm);function Sm(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:g,...h}=p,w=f?.[e]?.[d]||c,v=l.useMemo(()=>h,Object.values(h));return r.jsx(w.Provider,{value:v,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||c,h=l.useContext(g);if(h)return h;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,Nm(s,...t)]}function Nm(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function il(e){const t=Cm(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(Am);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Cm(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=_m(s),c=Im(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Pr(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Em=Symbol("radix.slottable");function Am(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Em}function Im(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function _m(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 Tm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xn=Tm.reduce((e,t)=>{const n=il(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function Mm(e,t){e&&Au.flushSync(()=>e.dispatchEvent(t))}function Dm(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:g,...h}=p,w=f?.[e]?.[d]||c,v=l.useMemo(()=>h,Object.values(h));return r.jsx(w.Provider,{value:v,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||c,h=l.useContext(g);if(h)return h;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,Pm(s,...t)]}function Pm(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Rm(e){const t=Lm(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(Fm);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Lm(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=Bm(s),c=$m(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Pr(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Om=Symbol("radix.slottable");function Fm(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Om}function $m(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Bm(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 zm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ll=zm.reduce((e,t)=>{const n=Rm(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),Bo="rovingFocusGroup.onEntryFocus",Um={bubbles:!1,cancelable:!0},yn="RovingFocusGroup",[us,cl,Wm]=Xi(yn),[Hm,uo]=Dm(yn,[Wm]),[qm,Km]=Hm(yn),dl=l.forwardRef((e,t)=>r.jsx(us.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(us.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Gm,{...e,ref:t})})}));dl.displayName=yn;var Gm=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:s=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...p}=e,f=l.useRef(null),g=Gt(t,f),h=co(a),[w,v]=Rs({prop:i,defaultProp:c??null,onChange:d,caller:yn}),[S,L]=l.useState(!1),k=tr(u),B=cl(n),E=l.useRef(!1),[y,I]=l.useState(0);return l.useEffect(()=>{const $=f.current;if($)return $.addEventListener(Bo,k),()=>$.removeEventListener(Bo,k)},[k]),r.jsx(qm,{scope:n,orientation:o,dir:h,loop:s,currentTabStopId:w,onItemFocus:l.useCallback($=>v($),[v]),onItemShiftTab:l.useCallback(()=>L(!0),[]),onFocusableItemAdd:l.useCallback(()=>I($=>$+1),[]),onFocusableItemRemove:l.useCallback(()=>I($=>$-1),[]),children:r.jsx(ll.div,{tabIndex:S||y===0?-1:0,"data-orientation":o,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:Je(e.onMouseDown,()=>{E.current=!0}),onFocus:Je(e.onFocus,$=>{const _=!E.current;if($.target===$.currentTarget&&_&&!S){const H=new CustomEvent(Bo,Um);if($.currentTarget.dispatchEvent(H),!H.defaultPrevented){const le=B().filter(he=>he.focusable),se=le.find(he=>he.active),W=le.find(he=>he.id===w),ce=[se,W,...le].filter(Boolean).map(he=>he.ref.current);ml(ce,m)}}E.current=!1}),onBlur:Je(e.onBlur,()=>L(!1))})})}),ul="RovingFocusGroupItem",pl=l.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:s=!1,tabStopId:a,children:i,...c}=e,d=Yn(),u=a||d,m=Km(ul,n),p=m.currentTabStopId===u,f=cl(n),{onFocusableItemAdd:g,onFocusableItemRemove:h,currentTabStopId:w}=m;return l.useEffect(()=>{if(o)return g(),()=>h()},[o,g,h]),r.jsx(us.ItemSlot,{scope:n,id:u,focusable:o,active:s,children:r.jsx(ll.span,{tabIndex:p?0:-1,"data-orientation":m.orientation,...c,ref:t,onMouseDown:Je(e.onMouseDown,v=>{o?m.onItemFocus(u):v.preventDefault()}),onFocus:Je(e.onFocus,()=>m.onItemFocus(u)),onKeyDown:Je(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){m.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const S=Ym(v,m.orientation,m.dir);if(S!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let k=f().filter(B=>B.focusable).map(B=>B.ref.current);if(S==="last")k.reverse();else if(S==="prev"||S==="next"){S==="prev"&&k.reverse();const B=k.indexOf(v.currentTarget);k=m.loop?Xm(k,B+1):k.slice(B+1)}setTimeout(()=>ml(k))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:w!=null}):i})})});pl.displayName=ul;var Vm={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Jm(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ym(e,t,n){const o=Jm(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return Vm[o]}function ml(e,t=!1){const n=document.activeElement;for(const o of e)if(o===n||(o.focus({preventScroll:t}),document.activeElement!==n))return}function Xm(e,t){return e.map((n,o)=>e[(t+o)%e.length])}var fl=dl,hl=pl,ps=["Enter"," "],Qm=["ArrowDown","PageUp","Home"],gl=["ArrowUp","PageDown","End"],Zm=[...Qm,...gl],ef={ltr:[...ps,"ArrowRight"],rtl:[...ps,"ArrowLeft"]},tf={ltr:["ArrowLeft"],rtl:["ArrowRight"]},vn="Menu",[pn,rf,nf]=Xi(vn),[Lr,xl]=Sm(vn,[nf,Qi,uo]),po=Qi(),yl=uo(),[of,Or]=Lr(vn),[sf,bn]=Lr(vn),vl=e=>{const{__scopeMenu:t,open:n=!1,children:o,dir:s,onOpenChange:a,modal:i=!0}=e,c=po(t),[d,u]=l.useState(null),m=l.useRef(!1),p=tr(a),f=co(s);return l.useEffect(()=>{const g=()=>{m.current=!0,document.addEventListener("pointerdown",h,{capture:!0,once:!0}),document.addEventListener("pointermove",h,{capture:!0,once:!0})},h=()=>m.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",h,{capture:!0}),document.removeEventListener("pointermove",h,{capture:!0})}},[]),r.jsx(Pu,{...c,children:r.jsx(of,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:u,children:r.jsx(sf,{scope:t,onClose:l.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:f,modal:i,children:o})})})};vl.displayName=vn;var af="MenuAnchor",$s=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e,s=po(n);return r.jsx(Ru,{...s,...o,ref:t})});$s.displayName=af;var Bs="MenuPortal",[lf,bl]=Lr(Bs,{forceMount:void 0}),wl=e=>{const{__scopeMenu:t,forceMount:n,children:o,container:s}=e,a=Or(Bs,t);return r.jsx(lf,{scope:t,forceMount:n,children:r.jsx(hr,{present:n||a.open,children:r.jsx(Lu,{asChild:!0,container:s,children:o})})})};wl.displayName=Bs;var qt="MenuContent",[cf,zs]=Lr(qt),kl=l.forwardRef((e,t)=>{const n=bl(qt,e.__scopeMenu),{forceMount:o=n.forceMount,...s}=e,a=Or(qt,e.__scopeMenu),i=bn(qt,e.__scopeMenu);return r.jsx(pn.Provider,{scope:e.__scopeMenu,children:r.jsx(hr,{present:o||a.open,children:r.jsx(pn.Slot,{scope:e.__scopeMenu,children:i.modal?r.jsx(df,{...s,ref:t}):r.jsx(uf,{...s,ref:t})})})})}),df=l.forwardRef((e,t)=>{const n=Or(qt,e.__scopeMenu),o=l.useRef(null),s=Gt(t,o);return l.useEffect(()=>{const a=o.current;if(a)return Ou(a)},[]),r.jsx(Us,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Je(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),uf=l.forwardRef((e,t)=>{const n=Or(qt,e.__scopeMenu);return r.jsx(Us,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),pf=il("MenuContent.ScrollLock"),Us=l.forwardRef((e,t)=>{const{__scopeMenu:n,loop:o=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:f,onDismiss:g,disableOutsideScroll:h,...w}=e,v=Or(qt,n),S=bn(qt,n),L=po(n),k=yl(n),B=rf(n),[E,y]=l.useState(null),I=l.useRef(null),$=Gt(t,I,v.onContentChange),_=l.useRef(0),H=l.useRef(""),le=l.useRef(0),se=l.useRef(null),W=l.useRef("right"),Q=l.useRef(0),ce=h?$u:l.Fragment,he=h?{as:pf,allowPinchZoom:!0}:void 0,be=K=>{const De=H.current+K,P=B().filter(A=>!A.disabled),j=document.activeElement,T=P.find(A=>A.ref.current===j)?.textValue,ne=P.map(A=>A.textValue),ge=Sf(ne,De,T),Se=P.find(A=>A.textValue===ge)?.ref.current;(function A(ee){H.current=ee,window.clearTimeout(_.current),ee!==""&&(_.current=window.setTimeout(()=>A(""),1e3))})(De),Se&&setTimeout(()=>Se.focus())};l.useEffect(()=>()=>window.clearTimeout(_.current),[]),Fu();const pe=l.useCallback(K=>W.current===se.current?.side&&Cf(K,se.current?.area),[]);return r.jsx(cf,{scope:n,searchRef:H,onItemEnter:l.useCallback(K=>{pe(K)&&K.preventDefault()},[pe]),onItemLeave:l.useCallback(K=>{pe(K)||(I.current?.focus(),y(null))},[pe]),onTriggerLeave:l.useCallback(K=>{pe(K)&&K.preventDefault()},[pe]),pointerGraceTimerRef:le,onPointerGraceIntentChange:l.useCallback(K=>{se.current=K},[]),children:r.jsx(ce,{...he,children:r.jsx(Bu,{asChild:!0,trapped:s,onMountAutoFocus:Je(a,K=>{K.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:r.jsx(zu,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:u,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:f,onDismiss:g,children:r.jsx(fl,{asChild:!0,...k,dir:S.dir,orientation:"vertical",loop:o,currentTabStopId:E,onCurrentTabStopIdChange:y,onEntryFocus:Je(d,K=>{S.isUsingKeyboardRef.current||K.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(Uu,{role:"menu","aria-orientation":"vertical","data-state":Fl(v.open),"data-radix-menu-content":"",dir:S.dir,...L,...w,ref:$,style:{outline:"none",...w.style},onKeyDown:Je(w.onKeyDown,K=>{const P=K.target.closest("[data-radix-menu-content]")===K.currentTarget,j=K.ctrlKey||K.altKey||K.metaKey,T=K.key.length===1;P&&(K.key==="Tab"&&K.preventDefault(),!j&&T&&be(K.key));const ne=I.current;if(K.target!==ne||!Zm.includes(K.key))return;K.preventDefault();const Se=B().filter(A=>!A.disabled).map(A=>A.ref.current);gl.includes(K.key)&&Se.reverse(),kf(Se)}),onBlur:Je(e.onBlur,K=>{K.currentTarget.contains(K.target)||(window.clearTimeout(_.current),H.current="")}),onPointerMove:Je(e.onPointerMove,mn(K=>{const De=K.target,P=Q.current!==K.clientX;if(K.currentTarget.contains(De)&&P){const j=K.clientX>Q.current?"right":"left";W.current=j,Q.current=K.clientX}}))})})})})})})});kl.displayName=qt;var mf="MenuGroup",Ws=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(xn.div,{role:"group",...o,ref:t})});Ws.displayName=mf;var ff="MenuLabel",jl=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(xn.div,{...o,ref:t})});jl.displayName=ff;var Xn="MenuItem",Ma="menu.itemSelect",mo=l.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:o,...s}=e,a=l.useRef(null),i=bn(Xn,e.__scopeMenu),c=zs(Xn,e.__scopeMenu),d=Gt(t,a),u=l.useRef(!1),m=()=>{const p=a.current;if(!n&&p){const f=new CustomEvent(Ma,{bubbles:!0,cancelable:!0});p.addEventListener(Ma,g=>o?.(g),{once:!0}),Mm(p,f),f.defaultPrevented?u.current=!1:i.onClose()}};return r.jsx(Sl,{...s,ref:d,disabled:n,onClick:Je(e.onClick,m),onPointerDown:p=>{e.onPointerDown?.(p),u.current=!0},onPointerUp:Je(e.onPointerUp,p=>{u.current||p.currentTarget?.click()}),onKeyDown:Je(e.onKeyDown,p=>{const f=c.searchRef.current!=="";n||f&&p.key===" "||ps.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});mo.displayName=Xn;var Sl=l.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:o=!1,textValue:s,...a}=e,i=zs(Xn,n),c=yl(n),d=l.useRef(null),u=Gt(t,d),[m,p]=l.useState(!1),[f,g]=l.useState("");return l.useEffect(()=>{const h=d.current;h&&g((h.textContent??"").trim())},[a.children]),r.jsx(pn.ItemSlot,{scope:n,disabled:o,textValue:s??f,children:r.jsx(hl,{asChild:!0,...c,focusable:!o,children:r.jsx(xn.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":o||void 0,"data-disabled":o?"":void 0,...a,ref:u,onPointerMove:Je(e.onPointerMove,mn(h=>{o?i.onItemLeave(h):(i.onItemEnter(h),h.defaultPrevented||h.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Je(e.onPointerLeave,mn(h=>i.onItemLeave(h))),onFocus:Je(e.onFocus,()=>p(!0)),onBlur:Je(e.onBlur,()=>p(!1))})})})}),hf="MenuCheckboxItem",Nl=l.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:o,...s}=e;return r.jsx(_l,{scope:e.__scopeMenu,checked:n,children:r.jsx(mo,{role:"menuitemcheckbox","aria-checked":Qn(n)?"mixed":n,...s,ref:t,"data-state":qs(n),onSelect:Je(s.onSelect,()=>o?.(Qn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Nl.displayName=hf;var Cl="MenuRadioGroup",[gf,xf]=Lr(Cl,{value:void 0,onValueChange:()=>{}}),El=l.forwardRef((e,t)=>{const{value:n,onValueChange:o,...s}=e,a=tr(o);return r.jsx(gf,{scope:e.__scopeMenu,value:n,onValueChange:a,children:r.jsx(Ws,{...s,ref:t})})});El.displayName=Cl;var Al="MenuRadioItem",Il=l.forwardRef((e,t)=>{const{value:n,...o}=e,s=xf(Al,e.__scopeMenu),a=n===s.value;return r.jsx(_l,{scope:e.__scopeMenu,checked:a,children:r.jsx(mo,{role:"menuitemradio","aria-checked":a,...o,ref:t,"data-state":qs(a),onSelect:Je(o.onSelect,()=>s.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Il.displayName=Al;var Hs="MenuItemIndicator",[_l,yf]=Lr(Hs,{checked:!1}),Tl=l.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:o,...s}=e,a=yf(Hs,n);return r.jsx(hr,{present:o||Qn(a.checked)||a.checked===!0,children:r.jsx(xn.span,{...s,ref:t,"data-state":qs(a.checked)})})});Tl.displayName=Hs;var vf="MenuSeparator",Ml=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e;return r.jsx(xn.div,{role:"separator","aria-orientation":"horizontal",...o,ref:t})});Ml.displayName=vf;var bf="MenuArrow",Dl=l.forwardRef((e,t)=>{const{__scopeMenu:n,...o}=e,s=po(n);return r.jsx(Wu,{...s,...o,ref:t})});Dl.displayName=bf;var wf="MenuSub",[rb,Pl]=Lr(wf),an="MenuSubTrigger",Rl=l.forwardRef((e,t)=>{const n=Or(an,e.__scopeMenu),o=bn(an,e.__scopeMenu),s=Pl(an,e.__scopeMenu),a=zs(an,e.__scopeMenu),i=l.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=a,u={__scopeMenu:e.__scopeMenu},m=l.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return l.useEffect(()=>m,[m]),l.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),r.jsx($s,{asChild:!0,...u,children:r.jsx(Sl,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":Fl(n.open),...e,ref:Pr(t,s.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Je(e.onPointerMove,mn(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Je(e.onPointerLeave,mn(p=>{m();const f=n.content?.getBoundingClientRect();if(f){const g=n.content?.dataset.side,h=g==="right",w=h?-5:5,v=f[h?"left":"right"],S=f[h?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+w,y:p.clientY},{x:v,y:f.top},{x:S,y:f.top},{x:S,y:f.bottom},{x:v,y:f.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Je(e.onKeyDown,p=>{const f=a.searchRef.current!=="";e.disabled||f&&p.key===" "||ef[o.dir].includes(p.key)&&(n.onOpenChange(!0),n.content?.focus(),p.preventDefault())})})})});Rl.displayName=an;var Ll="MenuSubContent",Ol=l.forwardRef((e,t)=>{const n=bl(qt,e.__scopeMenu),{forceMount:o=n.forceMount,...s}=e,a=Or(qt,e.__scopeMenu),i=bn(qt,e.__scopeMenu),c=Pl(Ll,e.__scopeMenu),d=l.useRef(null),u=Gt(t,d);return r.jsx(pn.Provider,{scope:e.__scopeMenu,children:r.jsx(hr,{present:o||a.open,children:r.jsx(pn.Slot,{scope:e.__scopeMenu,children:r.jsx(Us,{id:c.contentId,"aria-labelledby":c.triggerId,...s,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{i.isUsingKeyboardRef.current&&d.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Je(e.onFocusOutside,m=>{m.target!==c.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:Je(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:Je(e.onKeyDown,m=>{const p=m.currentTarget.contains(m.target),f=tf[i.dir].includes(m.key);p&&f&&(a.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});Ol.displayName=Ll;function Fl(e){return e?"open":"closed"}function Qn(e){return e==="indeterminate"}function qs(e){return Qn(e)?"indeterminate":e?"checked":"unchecked"}function kf(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function jf(e,t){return e.map((n,o)=>e[(t+o)%e.length])}function Sf(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=jf(e,Math.max(a,0));s.length===1&&(i=i.filter(u=>u!==n));const d=i.find(u=>u.toLowerCase().startsWith(s.toLowerCase()));return d!==n?d:void 0}function Nf(e,t){const{x:n,y:o}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const c=t[a],d=t[i],u=c.x,m=c.y,p=d.x,f=d.y;m>o!=f>o&&n<(p-u)*(o-m)/(f-m)+u&&(s=!s)}return s}function Cf(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Nf(n,t)}function mn(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Ef=vl,Af=$s,If=wl,_f=kl,Tf=Ws,Mf=jl,Df=mo,Pf=Nl,Rf=El,Lf=Il,Of=Tl,Ff=Ml,$f=Dl,Bf=Rl,zf=Ol;function Uf(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:g,...h}=p,w=f?.[e]?.[d]||c,v=l.useMemo(()=>h,Object.values(h));return r.jsx(w.Provider,{value:v,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||c,h=l.useContext(g);if(h)return h;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,Wf(s,...t)]}function Wf(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Hf(e){const t=qf(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(Gf);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function qf(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=Jf(s),c=Vf(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Pr(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Kf=Symbol("radix.slottable");function Gf(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Kf}function Vf(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Jf(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 Yf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Xf=Yf.reduce((e,t)=>{const n=Hf(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),fo="DropdownMenu",[Qf]=Uf(fo,[xl]),Ot=xl(),[Zf,$l]=Qf(fo),Bl=e=>{const{__scopeDropdownMenu:t,children:n,dir:o,open:s,defaultOpen:a,onOpenChange:i,modal:c=!0}=e,d=Ot(t),u=l.useRef(null),[m,p]=Rs({prop:s,defaultProp:a??!1,onChange:i,caller:fo});return r.jsx(Zf,{scope:t,triggerId:Yn(),triggerRef:u,contentId:Yn(),open:m,onOpenChange:p,onOpenToggle:l.useCallback(()=>p(f=>!f),[p]),modal:c,children:r.jsx(Ef,{...d,open:m,onOpenChange:p,dir:o,modal:c,children:n})})};Bl.displayName=fo;var zl="DropdownMenuTrigger",Ul=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:o=!1,...s}=e,a=$l(zl,n),i=Ot(n);return r.jsx(Af,{asChild:!0,...i,children:r.jsx(Xf.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":o?"":void 0,disabled:o,...s,ref:Pr(t,a.triggerRef),onPointerDown:Je(e.onPointerDown,c=>{!o&&c.button===0&&c.ctrlKey===!1&&(a.onOpenToggle(),a.open||c.preventDefault())}),onKeyDown:Je(e.onKeyDown,c=>{o||(["Enter"," "].includes(c.key)&&a.onOpenToggle(),c.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});Ul.displayName=zl;var eh="DropdownMenuPortal",Wl=e=>{const{__scopeDropdownMenu:t,...n}=e,o=Ot(t);return r.jsx(If,{...o,...n})};Wl.displayName=eh;var Hl="DropdownMenuContent",ql=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=$l(Hl,n),a=Ot(n),i=l.useRef(!1);return r.jsx(_f,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...o,ref:t,onCloseAutoFocus:Je(e.onCloseAutoFocus,c=>{i.current||s.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Je(e.onInteractOutside,c=>{const d=c.detail.originalEvent,u=d.button===0&&d.ctrlKey===!0,m=d.button===2||u;(!s.modal||m)&&(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)"}})});ql.displayName=Hl;var th="DropdownMenuGroup",rh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Tf,{...s,...o,ref:t})});rh.displayName=th;var nh="DropdownMenuLabel",oh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Mf,{...s,...o,ref:t})});oh.displayName=nh;var sh="DropdownMenuItem",Kl=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Df,{...s,...o,ref:t})});Kl.displayName=sh;var ah="DropdownMenuCheckboxItem",ih=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Pf,{...s,...o,ref:t})});ih.displayName=ah;var lh="DropdownMenuRadioGroup",ch=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Rf,{...s,...o,ref:t})});ch.displayName=lh;var dh="DropdownMenuRadioItem",uh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Lf,{...s,...o,ref:t})});uh.displayName=dh;var ph="DropdownMenuItemIndicator",mh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Of,{...s,...o,ref:t})});mh.displayName=ph;var fh="DropdownMenuSeparator",Gl=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Ff,{...s,...o,ref:t})});Gl.displayName=fh;var hh="DropdownMenuArrow",gh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx($f,{...s,...o,ref:t})});gh.displayName=hh;var xh="DropdownMenuSubTrigger",yh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(Bf,{...s,...o,ref:t})});yh.displayName=xh;var vh="DropdownMenuSubContent",bh=l.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...o}=e,s=Ot(n);return r.jsx(zf,{...s,...o,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});bh.displayName=vh;var Mn=Bl,Dn=Ul,Pn=Wl,Rn=ql,Zt=Kl,Da=Gl;function wh(e){const t=kh(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(Sh);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function kh(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=Ch(s),c=Nh(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Pr(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var jh=Symbol("radix.slottable");function Sh(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===jh}function Nh(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Ch(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 Eh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wn=Eh.reduce((e,t)=>{const n=wh(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function Ah(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:g,...h}=p,w=f?.[e]?.[d]||c,v=l.useMemo(()=>h,Object.values(h));return r.jsx(w.Provider,{value:v,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||c,h=l.useContext(g);if(h)return h;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,Ih(s,...t)]}function Ih(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function _h(e,t){return l.useReducer((n,o)=>t[n][o]??n,e)}var Ks="ScrollArea",[Vl]=Ah(Ks),[Th,Vt]=Vl(Ks),Jl=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:o="hover",dir:s,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[u,m]=l.useState(null),[p,f]=l.useState(null),[g,h]=l.useState(null),[w,v]=l.useState(null),[S,L]=l.useState(0),[k,B]=l.useState(0),[E,y]=l.useState(!1),[I,$]=l.useState(!1),_=Gt(t,le=>d(le)),H=co(s);return r.jsx(Th,{scope:n,type:o,dir:H,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:m,content:p,onContentChange:f,scrollbarX:g,onScrollbarXChange:h,scrollbarXEnabled:E,onScrollbarXEnabledChange:y,scrollbarY:w,onScrollbarYChange:v,scrollbarYEnabled:I,onScrollbarYEnabledChange:$,onCornerWidthChange:L,onCornerHeightChange:B,children:r.jsx(wn.div,{dir:H,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":S+"px","--radix-scroll-area-corner-height":k+"px",...e.style}})})});Jl.displayName=Ks;var Yl="ScrollAreaViewport",Xl=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:o,nonce:s,...a}=e,i=Vt(Yl,n),c=l.useRef(null),d=Gt(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:s}),r.jsx(wn.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});Xl.displayName=Yl;var sr="ScrollAreaScrollbar",Ql=l.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=Vt(sr,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=s,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),s.type==="hover"?r.jsx(Mh,{...o,ref:t,forceMount:n}):s.type==="scroll"?r.jsx(Dh,{...o,ref:t,forceMount:n}):s.type==="auto"?r.jsx(Zl,{...o,ref:t,forceMount:n}):s.type==="always"?r.jsx(Gs,{...o,ref:t}):null});Ql.displayName=sr;var Mh=l.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=Vt(sr,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=s.scrollArea;let d=0;if(c){const u=()=>{window.clearTimeout(d),i(!0)},m=()=>{d=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",m),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",m)}}},[s.scrollArea,s.scrollHideDelay]),r.jsx(hr,{present:n||a,children:r.jsx(Zl,{"data-state":a?"visible":"hidden",...o,ref:t})})}),Dh=l.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=Vt(sr,e.__scopeScrollArea),a=e.orientation==="horizontal",i=go(()=>d("SCROLL_END"),100),[c,d]=_h("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"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,s.scrollHideDelay,d]),l.useEffect(()=>{const u=s.viewport,m=a?"scrollLeft":"scrollTop";if(u){let p=u[m];const f=()=>{const g=u[m];p!==g&&(d("SCROLL"),i()),p=g};return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[s.viewport,a,d,i]),r.jsx(hr,{present:n||c!=="hidden",children:r.jsx(Gs,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:t,onPointerEnter:Je(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Je(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Zl=l.forwardRef((e,t)=>{const n=Vt(sr,e.__scopeScrollArea),{forceMount:o,...s}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=go(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,m=n.viewport.offsetHeight<n.viewport.scrollHeight;i(c?u:m)}},10);return Gr(n.viewport,d),Gr(n.content,d),r.jsx(hr,{present:o||a,children:r.jsx(Gs,{"data-state":a?"visible":"hidden",...s,ref:t})})}),Gs=l.forwardRef((e,t)=>{const{orientation:n="vertical",...o}=e,s=Vt(sr,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=oc(c.viewport,c.content),m={...o,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function p(f,g){return $h(f,i.current,c,g)}return n==="horizontal"?r.jsx(Ph,{...m,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollLeft,g=Pa(f,c,s.dir);a.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=p(f,s.dir))}}):n==="vertical"?r.jsx(Rh,{...m,ref:t,onThumbPositionChange:()=>{if(s.viewport&&a.current){const f=s.viewport.scrollTop,g=Pa(f,c);a.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=p(f))}}):null}),Ph=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:o,...s}=e,a=Vt(sr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=Gt(t,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(tc,{"data-orientation":"horizontal",...s,ref:u,sizes:n,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ho(n)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.x),onDragScroll:m=>e.onDragScroll(m.x),onWheelScroll:(m,p)=>{if(a.viewport){const f=a.viewport.scrollLeft+m.deltaX;e.onWheelScroll(f),ac(f,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:eo(i.paddingLeft),paddingEnd:eo(i.paddingRight)}})}})}),Rh=l.forwardRef((e,t)=>{const{sizes:n,onSizesChange:o,...s}=e,a=Vt(sr,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=Gt(t,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),r.jsx(tc,{"data-orientation":"vertical",...s,ref:u,sizes:n,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ho(n)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.y),onDragScroll:m=>e.onDragScroll(m.y),onWheelScroll:(m,p)=>{if(a.viewport){const f=a.viewport.scrollTop+m.deltaY;e.onWheelScroll(f),ac(f,p)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:eo(i.paddingTop),paddingEnd:eo(i.paddingBottom)}})}})}),[Lh,ec]=Vl(sr),tc=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:o,hasThumb:s,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:m,onResize:p,...f}=e,g=Vt(sr,n),[h,w]=l.useState(null),v=Gt(t,_=>w(_)),S=l.useRef(null),L=l.useRef(""),k=g.viewport,B=o.content-o.viewport,E=tr(m),y=tr(d),I=go(p,10);function $(_){if(S.current){const H=_.clientX-S.current.left,le=_.clientY-S.current.top;u({x:H,y:le})}}return l.useEffect(()=>{const _=H=>{const le=H.target;h?.contains(le)&&E(H,B)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[k,h,B,E]),l.useEffect(y,[o,y]),Gr(h,I),Gr(g.content,I),r.jsx(Lh,{scope:n,scrollbar:h,hasThumb:s,onThumbChange:tr(a),onThumbPointerUp:tr(i),onThumbPositionChange:y,onThumbPointerDown:tr(c),children:r.jsx(wn.div,{...f,ref:v,style:{position:"absolute",...f.style},onPointerDown:Je(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),S.current=h.getBoundingClientRect(),L.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),$(_))}),onPointerMove:Je(e.onPointerMove,$),onPointerUp:Je(e.onPointerUp,_=>{const H=_.target;H.hasPointerCapture(_.pointerId)&&H.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=L.current,g.viewport&&(g.viewport.style.scrollBehavior=""),S.current=null})})})}),Zn="ScrollAreaThumb",rc=l.forwardRef((e,t)=>{const{forceMount:n,...o}=e,s=ec(Zn,e.__scopeScrollArea);return r.jsx(hr,{present:n||s.hasThumb,children:r.jsx(Oh,{ref:t,...o})})}),Oh=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:o,...s}=e,a=Vt(Zn,n),i=ec(Zn,n),{onThumbPositionChange:c}=i,d=Gt(t,p=>i.onThumbChange(p)),u=l.useRef(void 0),m=go(()=>{u.current&&(u.current(),u.current=void 0)},100);return l.useEffect(()=>{const p=a.viewport;if(p){const f=()=>{if(m(),!u.current){const g=Bh(p,c);u.current=g,c()}};return c(),p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,m,c]),r.jsx(wn.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:Je(e.onPointerDownCapture,p=>{const g=p.target.getBoundingClientRect(),h=p.clientX-g.left,w=p.clientY-g.top;i.onThumbPointerDown({x:h,y:w})}),onPointerUp:Je(e.onPointerUp,i.onThumbPointerUp)})});rc.displayName=Zn;var Vs="ScrollAreaCorner",nc=l.forwardRef((e,t)=>{const n=Vt(Vs,e.__scopeScrollArea),o=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&o?r.jsx(Fh,{...e,ref:t}):null});nc.displayName=Vs;var Fh=l.forwardRef((e,t)=>{const{__scopeScrollArea:n,...o}=e,s=Vt(Vs,n),[a,i]=l.useState(0),[c,d]=l.useState(0),u=!!(a&&c);return Gr(s.scrollbarX,()=>{const m=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(m),d(m)}),Gr(s.scrollbarY,()=>{const m=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(m),i(m)}),u?r.jsx(wn.div,{...o,ref:t,style:{width:a,height:c,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function eo(e){return e?parseInt(e,10):0}function oc(e,t){const n=e/t;return isNaN(n)?0:n}function ho(e){const t=oc(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-n)*t;return Math.max(o,18)}function $h(e,t,n,o="ltr"){const s=ho(n),a=s/2,i=t||a,c=s-i,d=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-c,m=n.content-n.viewport,p=o==="ltr"?[0,m]:[m*-1,0];return sc([d,u],p)(e)}function Pa(e,t,n="ltr"){const o=ho(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-s,i=t.content-t.viewport,c=a-o,d=n==="ltr"?[0,i]:[i*-1,0],u=qu(e,d);return sc([0,i],[0,c])(u)}function sc(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function ac(e,t){return e>0&&e<t}var Bh=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},o=0;return(function s(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,c=n.top!==a.top;(i||c)&&t(),n=a,o=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(o)};function go(e,t){const n=tr(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(n,t)},[n,t])}function Gr(e,t){const n=tr(t);Hu(()=>{let o=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(n)});return s.observe(e),()=>{window.cancelAnimationFrame(o),s.unobserve(e)}}},[e,n])}var ic=Jl,zh=Xl,lc=Ql,Uh=rc,Wh=nc;function Hh(e,t=[]){let n=[];function o(a,i){const c=l.createContext(i),d=n.length;n=[...n,i];const u=p=>{const{scope:f,children:g,...h}=p,w=f?.[e]?.[d]||c,v=l.useMemo(()=>h,Object.values(h));return r.jsx(w.Provider,{value:v,children:g})};u.displayName=a+"Provider";function m(p,f){const g=f?.[e]?.[d]||c,h=l.useContext(g);if(h)return h;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[u,m]}const s=()=>{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 s.scopeName=e,[o,qh(s,...t)]}function qh(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:u})=>{const p=d(a)[`__scope${u}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function Kh(e){const t=Gh(e),n=l.forwardRef((o,s)=>{const{children:a,...i}=o,c=l.Children.toArray(a),d=c.find(Jh);if(d){const u=d.props.children,m=c.map(p=>p===d?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:p);return r.jsx(t,{...i,ref:s,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return r.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Gh(e){const t=l.forwardRef((n,o)=>{const{children:s,...a}=n;if(l.isValidElement(s)){const i=Xh(s),c=Yh(a,s.props);return s.type!==l.Fragment&&(c.ref=o?Pr(o,i):i),l.cloneElement(s,c)}return l.Children.count(s)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Vh=Symbol("radix.slottable");function Jh(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vh}function Yh(e,t){const n={...t};for(const o in t){const s=e[o],a=t[o];/^on[A-Z]/.test(o)?s&&a?n[o]=(...c)=>{const d=a(...c);return s(...c),d}:s&&(n[o]=s):o==="style"?n[o]={...s,...a}:o==="className"&&(n[o]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Xh(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 Qh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xo=Qh.reduce((e,t)=>{const n=Kh(`Primitive.${t}`),o=l.forwardRef((s,a)=>{const{asChild:i,...c}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{}),yo="Tabs",[Zh]=Hh(yo,[uo]),cc=uo(),[eg,Js]=Zh(yo),tg=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,onValueChange:s,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...u}=e,m=co(c),[p,f]=Rs({prop:o,onChange:s,defaultProp:a??"",caller:yo});return r.jsx(eg,{scope:n,baseId:Yn(),value:p,onValueChange:f,orientation:i,dir:m,activationMode:d,children:r.jsx(xo.div,{dir:m,"data-orientation":i,...u,ref:t})})});tg.displayName=yo;var dc="TabsList",uc=l.forwardRef((e,t)=>{const{__scopeTabs:n,loop:o=!0,...s}=e,a=Js(dc,n),i=cc(n);return r.jsx(fl,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:o,children:r.jsx(xo.div,{role:"tablist","aria-orientation":a.orientation,...s,ref:t})})});uc.displayName=dc;var pc="TabsTrigger",mc=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,disabled:s=!1,...a}=e,i=Js(pc,n),c=cc(n),d=gc(i.baseId,o),u=xc(i.baseId,o),m=o===i.value;return r.jsx(hl,{asChild:!0,...c,focusable:!s,active:m,children:r.jsx(xo.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":u,"data-state":m?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:d,...a,ref:t,onMouseDown:Je(e.onMouseDown,p=>{!s&&p.button===0&&p.ctrlKey===!1?i.onValueChange(o):p.preventDefault()}),onKeyDown:Je(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&i.onValueChange(o)}),onFocus:Je(e.onFocus,()=>{const p=i.activationMode!=="manual";!m&&!s&&p&&i.onValueChange(o)})})})});mc.displayName=pc;var fc="TabsContent",hc=l.forwardRef((e,t)=>{const{__scopeTabs:n,value:o,forceMount:s,children:a,...i}=e,c=Js(fc,n),d=gc(c.baseId,o),u=xc(c.baseId,o),m=o===c.value,p=l.useRef(m);return l.useEffect(()=>{const f=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(f)},[]),r.jsx(hr,{present:s||m,children:({present:f})=>r.jsx(xo.div,{"data-state":m?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:u,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:f&&a})})});hc.displayName=fc;function gc(e,t){return`${e}-trigger-${t}`}function xc(e,t){return`${e}-content-${t}`}var yc=uc,vc=mc,bc=hc;const wc=l.forwardRef(({className:e,orientation:t="vertical",...n},o)=>r.jsx(lc,{ref:o,orientation:t,className:ht("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(Uh,{className:"relative flex-1 rounded-full bg-border/80"})}));wc.displayName=lc.displayName;const kc=l.forwardRef(({className:e,children:t,...n},o)=>r.jsxs(ic,{ref:o,className:ht("relative overflow-hidden",e),...n,children:[r.jsx(zh,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsx(wc,{}),r.jsx(Wh,{})]}));kc.displayName=ic.displayName;const _t=l.forwardRef(({className:e,type:t,...n},o)=>r.jsx("input",{type:t,className:ht("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...n}));_t.displayName="Input";const kn=({className:e="w-5 h-5"})=>r.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),vo=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Ls();return r.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},bo=({className:e="w-5 h-5"})=>{const t=l.useId(),n=l.useId(),o=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(#${o})`}),r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:t,x1:"7",x2:"11",y1:"15.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#08B962"}),r.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:n,x1:"8",x2:"11.5",y1:"5.5",y2:"11",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#F94543"}),r.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),r.jsxs("linearGradient",{id:o,x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#FABC12"}),r.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]})},wo=({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"})]}),rg=!1,xe=(e,t={})=>{const n=localStorage.getItem("auth-token"),o={};return t.body instanceof FormData||(o["Content-Type"]="application/json"),n&&(o.Authorization=`Bearer ${n}`),fetch(e,{...t,headers:{...o,...t.headers}})},xt={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:()=>xe("/api/auth/user"),logout:()=>xe("/api/auth/logout",{method:"POST"})},projects:()=>xe("/api/projects"),sessions:(e,t=5,n=0)=>xe(`/api/projects/${e}/sessions?limit=${t}&offset=${n}`),historyIndex:e=>xe(`/api/session-core/projects/${e}/history-index`),providerDiscovery:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("projectPath",t),xe(`/api/session-core/providers/${e}${n.toString()?`?${n.toString()}`:""}`)},providersDiscovery:(e=null)=>{const t=new URLSearchParams;return e&&t.append("projectPath",e),xe(`/api/session-core/providers${t.toString()?`?${t.toString()}`:""}`)},sessionEvents:(e,t,n=null,o=null,s=null,a=0)=>{const i=new URLSearchParams;return n&&i.append("projectName",n),o&&i.append("projectPath",o),s!==null&&(i.append("limit",s),i.append("offset",a)),xe(`/api/session-core/sessions/${e}/${t}/events${i.toString()?`?${i.toString()}`:""}`)},sessionMessages:(e,t,n=null,o=0,s="claude")=>{const a=new URLSearchParams;return e&&a.append("projectName",e),n!==null&&(a.append("limit",n),a.append("offset",o)),xe(`/api/session-core/sessions/${s}/${t}/events${a.toString()?`?${a.toString()}`:""}`)},resolveSession:(e,t=null)=>{const n=new URLSearchParams;return t&&n.append("provider",t),xe(`/api/session-core/sessions/${e}/resolve${n.toString()?`?${n.toString()}`:""}`)},renameProject:(e,t)=>xe(`/api/projects/${e}/rename`,{method:"PUT",body:JSON.stringify({displayName:t})}),deleteSession:(e,t)=>xe(`/api/projects/${e}/sessions/${t}`,{method:"DELETE"}),deleteCodexSession:e=>xe(`/api/codex/sessions/${e}`,{method:"DELETE"}),deleteOpencodeSession:e=>xe(`/api/opencode/sessions/${e}`,{method:"DELETE"}),deleteProject:(e,t=!1)=>xe(`/api/projects/${e}${t?"?force=true":""}`,{method:"DELETE"}),createProject:e=>xe("/api/projects/create",{method:"POST",body:JSON.stringify({path:e})}),createWorkspace:e=>xe("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(e)}),readFile:(e,t)=>xe(`/api/projects/${e}/file?filePath=${encodeURIComponent(t)}`),saveFile:(e,t,n)=>xe(`/api/projects/${e}/file`,{method:"PUT",body:JSON.stringify({filePath:t,content:n})}),getFiles:e=>xe(`/api/projects/${e}/files`),transcribe:e=>xe("/api/transcribe",{method:"POST",body:e,headers:{}}),browseFilesystem:(e=null)=>{const t=new URLSearchParams;return e&&t.append("path",e),xe(`/api/browse-filesystem?${t}`)},createFolder:e=>xe("/api/create-folder",{method:"POST",body:JSON.stringify({path:e})}),get:e=>xe(`/api${e}`)},ng=({onClose:e,onProjectCreated:t})=>{const{t:n}=kt(),[o,s]=l.useState(1),[a,i]=l.useState("existing"),[c,d]=l.useState(""),[u,m]=l.useState(!1),[p,f]=l.useState(null),[g,h]=l.useState([]),[w,v]=l.useState(!1),[S,L]=l.useState(!1),[k,B]=l.useState("~"),[E,y]=l.useState([]),[I,$]=l.useState(!1),[_,H]=l.useState(!1),[le,se]=l.useState(!1),[W,Q]=l.useState(""),[ce,he]=l.useState(!1);l.useEffect(()=>{c.length>2?be(c):(h([]),v(!1))},[c]);const be=async A=>{try{const ee=A.lastIndexOf("/"),Ae=ee>0?A.substring(0,ee):"~",st=await(await xt.browseFilesystem(Ae)).json();if(st.suggestions){const Ke=st.suggestions.filter(we=>we.path.toLowerCase().startsWith(A.toLowerCase())&&we.path.toLowerCase()!==A.toLowerCase());h(Ke.slice(0,5)),v(Ke.length>0)}}catch(ee){console.error("Error loading path suggestions:",ee)}},pe=()=>{if(f(null),o===1){if(!a){f(n("projectWizard.errors.selectType"));return}s(2)}else if(o===2){if(!c.trim()){f(n("projectWizard.errors.providePath"));return}s(3)}},K=()=>{f(null),s(o-1)},De=async()=>{m(!0),f(null);try{const A={workspaceType:a,path:c.trim()},ee=await xt.createWorkspace(A),Ae=await ee.json();if(!ee.ok)throw new Error(Ae.details||Ae.error||n("projectWizard.errors.failedToCreate"));t&&t(Ae.project),e()}catch(A){console.error("Error creating workspace:",A),f(A.message||n("projectWizard.errors.failedToCreate"))}finally{m(!1)}},P=A=>{d(A.path),v(!1)},j=async()=>{L(!0),await T("~")},T=async A=>{try{$(!0);const Ae=await(await xt.browseFilesystem(A)).json();B(Ae.path||A),y(Ae.suggestions||[])}catch(ee){console.error("Error loading folders:",ee)}finally{$(!1)}},ne=(A,ee=!1)=>{d(A),L(!1),ee&&s(3)},ge=async A=>{await T(A)},Se=async()=>{if(W.trim()){he(!0),f(null);try{const A=k.includes("\\")?"\\":"/",ee=`${k}${A}${W.trim()}`,Ae=await xt.createFolder(ee),ye=await Ae.json();if(!Ae.ok)throw new Error(ye.error||n("projectWizard.errors.failedToCreateFolder"));Q(""),se(!1),await T(ye.path||ee)}catch(A){console.error("Error creating folder:",A),f(A.message||n("projectWizard.errors.failedToCreateFolder"))}finally{he(!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(Ar,{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(Wt,{className:"w-5 h-5"})})]}),r.jsx("div",{className:"px-6 pt-4 pb-2",children:r.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(A=>r.jsxs(gn.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${A<o?"bg-green-500 text-white":A===o?"bg-primary text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:A<o?r.jsx(rr,{className:"w-4 h-4"}):A}),r.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:n(A===1?"projectWizard.steps.type":A===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),A<3&&r.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${A<o?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},A))})}),r.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[p&&r.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[r.jsx(Ku,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),r.jsx("div",{className:"flex-1",children:r.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:p})})]}),o===1&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:n("projectWizard.step1.question")}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsx("button",{onClick:()=>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(Ar,{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(Ar,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:n("projectWizard.step1.new.title")}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.step1.new.description")})]})]})})]})]})}),o===2&&r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n(a==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),r.jsxs("div",{className:"relative flex gap-2",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(_t,{type:"text",value:c,onChange:A=>d(A.target.value),placeholder:n(a==="existing"?"projectWizard.step2.existingPlaceholder":"projectWizard.step2.newPlaceholder"),className:"w-full"}),w&&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((A,ee)=>r.jsxs("button",{onClick:()=>P(A),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:A.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:A.path})]},ee))})]}),r.jsx(Ge,{type:"button",variant:"outline",onClick:j,className:"px-3",title:n("projectWizard.folderBrowser.browseFolders"),children:r.jsx(_r,{className:"w-4 h-4"})})]}),r.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n(a==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]})}),o===3&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[r.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:n("projectWizard.step3.reviewConfig")}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.workspaceType")}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:n(a==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:n("projectWizard.step3.path")}),r.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]})]})]}),r.jsx("div",{className:"bg-primary/10 dark:bg-primary/20 rounded-lg p-4 border border-primary/30 dark:border-primary/60",children:r.jsx("p",{className:"text-sm text-primary",children:n(a==="existing"?"projectWizard.step3.existingInfo":"projectWizard.step3.newEmpty")})})]})]}),r.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[r.jsx(Ge,{variant:"outline",onClick:o===1?e:K,disabled:u,children:o===1?n("projectWizard.buttons.cancel"):r.jsxs(r.Fragment,{children:[r.jsx(tl,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.back")]})}),r.jsx(Ge,{onClick:o===3?De:pe,disabled:u||o===1&&!a,children:u?r.jsxs(r.Fragment,{children:[r.jsx(un,{className:"w-4 h-4 mr-2 animate-spin"}),n("projectWizard.buttons.creating")]}):o===3?r.jsxs(r.Fragment,{children:[r.jsx(rr,{className:"w-4 h-4 mr-1"}),n("projectWizard.buttons.createProject")]}):r.jsxs(r.Fragment,{children:[n("projectWizard.buttons.next"),r.jsx(Wr,{className:"w-4 h-4 ml-1"})]})})]})]}),S&&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(_r,{className:"w-4 h-4 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:n("projectWizard.folderBrowser.title")})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>H(!_),className:`p-2 rounded-md transition-colors ${_?"text-primary bg-primary/10 dark:bg-primary/25":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:n(_?"projectWizard.folderBrowser.hideHiddenFolders":"projectWizard.folderBrowser.showHiddenFolders"),children:_?r.jsx(rl,{className:"w-5 h-5"}):r.jsx(_p,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>se(!le),className:`p-2 rounded-md transition-colors ${le?"text-primary bg-primary/10 dark:bg-primary/25":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:n("projectWizard.folderBrowser.createFolder"),children:r.jsx(Kr,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>L(!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(Wt,{className:"w-5 h-5"})})]})]}),le&&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(_t,{type:"text",value:W,onChange:A=>Q(A.target.value),placeholder:n("projectWizard.folderBrowser.newFolderPlaceholder"),className:"flex-1",onKeyDown:A=>{A.key==="Enter"&&Se(),A.key==="Escape"&&(se(!1),Q(""))},autoFocus:!0}),r.jsx(Ge,{size:"sm",onClick:Se,disabled:!W.trim()||ce,children:ce?r.jsx(un,{className:"w-4 h-4 animate-spin"}):n("buttons.create")}),r.jsx(Ge,{size:"sm",variant:"ghost",onClick:()=>{se(!1),Q("")},children:n("buttons.cancel")})]})}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:I?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(un,{className:"w-6 h-6 animate-spin text-gray-400"})}):r.jsxs("div",{className:"space-y-1",children:[k!=="~"&&k!=="/"&&!/^[A-Za-z]:\\?$/.test(k)&&r.jsxs("button",{onClick:()=>{const A=Math.max(k.lastIndexOf("/"),k.lastIndexOf("\\"));let ee;A<=0?ee="/":A===2&&/^[A-Za-z]:/.test(k)?ee=k.substring(0,3):ee=k.substring(0,A),ge(ee)},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(_r,{className:"w-5 h-5 text-gray-400"}),r.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),E.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("projectWizard.folderBrowser.noSubfolders")}):E.filter(A=>_||!A.name.startsWith(".")).sort((A,ee)=>A.name.toLowerCase().localeCompare(ee.name.toLowerCase())).map((A,ee)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>ge(A.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[r.jsx(Ar,{className:"w-5 h-5 text-primary"}),r.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:A.name})]}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:()=>ne(A.path,a==="existing"),className:"text-xs px-3",children:n("buttons.select")})]},ee))]})}),r.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[r.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("projectWizard.folderBrowser.currentPath")}),r.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:k})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[r.jsx(Ge,{variant:"outline",onClick:()=>{L(!1),se(!1),Q("")},children:n("buttons.cancel")}),r.jsx(Ge,{variant:"outline",onClick:()=>ne(k,a==="existing"),children:n("projectWizard.folderBrowser.useCurrentFolder")})]})]})]})})]})},og=(e,t,n)=>{const o=new Date(e),s=t;if(isNaN(o.getTime()))return n?n("status.unknown"):"Unknown";const a=s-o,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`:o.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},sg=(e,t)=>{if(typeof e!="string")return"";const n=e.trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-1))}…`},zr="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",Ln="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",zo="block min-w-0 w-full max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",Ra=({provider:e,className:t="h-3.5 w-3.5"})=>e==="codex"||e==="openai"?r.jsx(vo,{className:t}):e==="gemini"?r.jsx(bo,{className:t}):e==="opencode"?r.jsx(wo,{className:"h-3.5 w-auto max-w-full"}):r.jsx(kn,{className:t});function La({projects:e,selectedProject:t,selectedSession:n,onProjectSelect:o,onSessionSelect:s,onNewSession:a,onSessionDelete:i,onProjectDelete:c,isLoading:d,loadingProgress:u,onRefresh:m,updateAvailable:p,latestVersion:f,currentVersion:g,releaseInfo:h,onShowVersionModal:w,isPWA:v,isMobile:S,onToggleSidebar:L,lockedProjectName:k,showNewProject:B,setShowNewProject:E}){const{t:y}=kt("sidebar"),[I,$]=l.useState(new Set),[_,H]=l.useState(null),[le,se]=l.useState(""),[W,Q]=l.useState({}),[ce,he]=l.useState({}),[be,pe]=l.useState(new Set),[K,De]=l.useState(new Date),[P,j]=l.useState("name"),[T,ne]=l.useState(!1),[ge,Se]=l.useState(null),[A,ee]=l.useState(""),[Ae,ye]=l.useState(null),[st,Ke]=l.useState(null),[we,Le]=l.useState({}),[ze,rt]=l.useState(""),[Xe,Ve]=l.useState(new Set),[fe,Re]=l.useState(null),[et,Ye]=l.useState(null),[Qe,ot]=l.useState(()=>{try{const N=localStorage.getItem("starredProjects");return N?new Set(JSON.parse(N)):new Set}catch(N){return console.error("Error loading starred projects:",N),new Set}}),J=N=>ie=>{ie.target.closest(".overflow-y-auto")||ie.target.closest("[data-scroll-container]")||(ie.preventDefault(),ie.stopPropagation(),N())};l.useEffect(()=>{const N=setInterval(()=>{De(new Date)},6e4);return()=>clearInterval(N)},[]),l.useEffect(()=>{he({}),pe(new Set)},[e]),l.useEffect(()=>{n&&t&&$(N=>new Set([...N,t.name]))},[n,t]),l.useEffect(()=>{k&&$(new Set([k]))},[k,e.length]),l.useEffect(()=>{if(e.length>0&&!d){const N=new Set;e.forEach(ie=>{ie.sessions&&ie.sessions.length>=0&&N.add(ie.name)}),pe(N)}},[e,d]),l.useEffect(()=>{const N=()=>{try{const Z=localStorage.getItem("claude-settings");if(Z){const C=JSON.parse(Z);j(C.projectSortOrder||"name")}}catch(Z){console.error("Error loading sort order:",Z)}};N();const ie=Z=>{Z.key==="claude-settings"&&N()};window.addEventListener("storage",ie);const Me=setInterval(()=>{document.hasFocus()&&N()},1e3);return()=>{window.removeEventListener("storage",ie),clearInterval(Me)}},[]);const oe=N=>{const ie=new Set;I.has(N)||ie.add(N),$(ie)},x=(N,ie)=>{s({...N,__projectName:ie})},M=N=>{const ie=new Set(Qe);ie.has(N)?ie.delete(N):ie.add(N),ot(ie);try{localStorage.setItem("starredProjects",JSON.stringify([...ie]))}catch(Me){console.error("Error saving starred projects:",Me)}},G=N=>Qe.has(N),O=N=>{let ie={};try{ie=JSON.parse(localStorage.getItem("session-provider-map")||"{}")}catch{}const Me=[...N.sessions||[],...ce[N.name]||[]].map(_e=>({..._e,__provider:ie[_e.id]||"claude"})),Z=(N.codexSessions||[]).map(_e=>({..._e,__provider:"codex"})),C=(N.geminiSessions||[]).map(_e=>({..._e,__provider:"gemini"})),D=(N.opencodeSessions||[]).map(_e=>({..._e,__provider:"opencode"})),Ce=_e=>_e.__provider==="codex"?new Date(_e.createdAt||_e.lastActivity):_e.__provider==="gemini"?new Date(_e.createdAt||_e.lastActivity):_e.__provider==="opencode"?new Date(_e.createdAt||_e.lastActivity):new Date(_e.lastActivity);return[...Me,...Z,...C,...D].sort((_e,vt)=>Ce(vt)-Ce(_e))},te=N=>{const ie=O(N);return ie.length===0?new Date(0):ie.reduce((Z,C)=>{const D=new Date(C.lastActivity);return D>Z?D:Z},new Date(0))},Ie=[...e].sort((N,ie)=>{const Me=G(N.name),Z=G(ie.name);if(Me&&!Z)return-1;if(!Me&&Z)return 1;if(P==="date")return te(ie)-te(N);{const C=N.displayName||N.name,D=ie.displayName||ie.name;return C.localeCompare(D)}}),Oe=N=>{H(N.name),se(N.displayName)},Fe=()=>{H(null),se("")},ct=async N=>{try{(await xt.renameProject(N,le)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(ie){console.error("Error renaming project:",ie)}H(null),se("")},Ne=(N,ie,Me,Z="claude")=>{Ye({projectName:N,sessionId:ie,sessionTitle:Me,provider:Z})},Pe=async()=>{if(!et)return;const{projectName:N,sessionId:ie,provider:Me}=et;Ye(null);try{console.log("[Sidebar] Deleting session:",{projectName:N,sessionId:ie,provider:Me});let Z;if(Me==="codex"?Z=await xt.deleteCodexSession(ie):Me==="opencode"?Z=await xt.deleteOpencodeSession(ie):Z=await xt.deleteSession(N,ie),console.log("[Sidebar] Delete response:",{ok:Z.ok,status:Z.status}),Z.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(ie):console.warn("[Sidebar] No onSessionDelete callback provided");else{const C=await Z.text();console.error("[Sidebar] Failed to delete session:",{status:Z.status,error:C}),alert(y("messages.deleteSessionFailed"))}}catch(Z){console.error("[Sidebar] Error deleting session:",Z),alert(y("messages.deleteSessionError"))}},at=N=>{const ie=O(N).length;Re({project:N,sessionCount:ie})},yt=async()=>{if(!fe)return;const{project:N,sessionCount:ie}=fe,Me=ie===0;Re(null),Ve(Z=>new Set([...Z,N.name]));try{const Z=await xt.deleteProject(N.name,!Me);if(Z.ok)c&&c(N.name);else{const C=await Z.json();console.error("Failed to delete project"),alert(C.error||y("messages.deleteProjectFailed"))}}catch(Z){console.error("Error deleting project:",Z),alert(y("messages.deleteProjectError"))}finally{Ve(Z=>{const C=new Set(Z);return C.delete(N.name),C})}},Nt=async N=>{if(!(!(N.sessionMeta?.hasMore!==!1)||W[N.name])){Q(Me=>({...Me,[N.name]:!0}));try{const Me=(N.sessions?.length||0)+(ce[N.name]?.length||0),Z=await xt.sessions(N.name,5,Me);if(Z.ok){const C=await Z.json();he(D=>({...D,[N.name]:[...D[N.name]||[],...C.sessions]})),C.hasMore===!1&&(N.sessionMeta={...N.sessionMeta,hasMore:!1})}}catch(Me){console.error("Error loading more sessions:",Me)}finally{Q(Me=>({...Me,[N.name]:!1}))}}},dt=Ie.filter(N=>{if(!ze.trim())return!0;const ie=ze.toLowerCase(),Me=(N.displayName||N.name).toLowerCase(),Z=N.name.toLowerCase();return Me.includes(ie)||Z.includes(ie)}),pt=!!k,wt=pt?Ie.filter(N=>N.name===k):dt,ke=t||wt[0]||null,q=S?"bottom":"right",de=S?"end":"start",ae=S?4:8;return r.jsxs(r.Fragment,{children:[B&&Po.createPortal(r.jsx(ng,{onClose:()=>E(!1),onProjectCreated:N=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),fe&&Po.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(ds,{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:y("deleteConfirmation.deleteProject")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[y("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:fe.project.displayName||fe.project.name}),"?"]}),fe.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:y("deleteConfirmation.sessionCount",{count:fe.sessionCount})}),r.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:y("deleteConfirmation.allConversationsDeleted")})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:y("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Ge,{variant:"outline",className:"flex-1",onClick:()=>Re(null),children:y("actions.cancel")}),r.jsxs(Ge,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:yt,children:[r.jsx(Yt,{className:"w-4 h-4 mr-2"}),y("actions.delete")]})]})]})}),document.body),et&&Po.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(ds,{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:y("deleteConfirmation.deleteSession")}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[y("deleteConfirmation.confirmDelete")," ",r.jsx("span",{className:"font-medium text-foreground",children:et.sessionTitle||y("sessions.unnamed")}),"?"]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:y("deleteConfirmation.cannotUndo")})]})]})}),r.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[r.jsx(Ge,{variant:"outline",className:"flex-1",onClick:()=>Ye(null),children:y("actions.cancel")}),r.jsxs(Ge,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:Pe,children:[r.jsx(Yt,{className:"w-4 h-4 mr-2"}),y("actions.delete")]})]})]})}),document.body),r.jsxs("div",{className:"h-full flex flex-col bg-muted/10 border-r border-border/60 md:select-none",style:v&&S?{paddingTop:"44px"}:{},children:[r.jsxs("div",{className:"md:flex-shrink-0 md:px-3 md:pt-3",children:[r.jsxs("div",{className:"hidden h-[60px] items-center justify-between gap-3 border-b border-border/60 bg-muted/10 px-4 md:flex",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-8 h-8 rounded-lg flex-shrink-0"}),r.jsx("div",{className:"min-w-0",children:r.jsx("h1",{className:"text-base font-semibold leading-none text-foreground truncate",children:y("app.title")})})]}),L&&r.jsx(Ge,{variant:"ghost",size:"sm",className:"h-8 w-8 flex-shrink-0 rounded-xl bg-muted/70 px-0 text-muted-foreground transition-colors duration-200 hover:bg-muted hover:text-foreground",onClick:L,title:y("tooltips.hideSidebar"),children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),r.jsx("div",{className:"chat-header border-b border-border/60 bg-white p-3 dark:bg-background md:hidden",style:v&&S?{paddingTop:"16px"}:{},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("img",{src:"/logo-64.png",alt:"Logo",className:"w-8 h-8 rounded-lg flex-shrink-0"}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:y("app.title")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:y("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 m()}finally{ne(!1)}},disabled:T,children:r.jsx(cr,{className:`w-4 h-4 text-foreground ${T?"animate-spin":""}`})}),!pt&&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:()=>E(!0),children:r.jsx(Ar,{className:"w-4 h-4"})})]})]})})]}),!d&&!S&&!pt&&r.jsx("div",{className:"hidden"}),e.length>0&&!d&&!pt&&r.jsx("div",{className:"px-3 py-3 md:px-3",children:r.jsxs("div",{className:"relative",children:[r.jsx(ss,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),r.jsx(_t,{type:"text",placeholder:y("projects.searchPlaceholder"),value:ze,onChange:N=>rt(N.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"}),ze&&r.jsx("button",{onClick:()=>rt(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:r.jsx(Wt,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.length>0&&!d&&ke&&r.jsx("div",{className:"px-3 pb-2",children:r.jsxs(Ge,{variant:"subtle",className:"h-9 w-full justify-start gap-2 rounded-lg px-3 text-sm",onClick:()=>a(ke),children:[r.jsx(Kr,{className:"h-4 w-4"}),y("sessions.newSession")]})}),r.jsx(kc,{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:y("projects.projects")})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:y("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(Oo,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:y("projects.noProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:y("projects.runClaudeCli")})]}):wt.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(ss,{className:"w-6 h-6 text-muted-foreground"})}),r.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:y("projects.noMatchingProjects")}),r.jsx("p",{className:"text-sm text-muted-foreground",children:y("projects.tryDifferentSearch")})]}):wt.map(N=>{const ie=I.has(N.name),Me=t?.name===N.name,Z=G(N.name),C=Xe.has(N.name),D=pt&&N.name===k,Ce=D||ie,_e=N.displayName||N.name,vt=sg(_e,S?22:28);return r.jsxs("div",{className:ht("space-y-2",C&&"pointer-events-none opacity-50"),children:[!D&&r.jsxs("div",{className:"group md:group",children:[r.jsx("div",{className:"md:hidden",children:r.jsxs("div",{className:ht("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!==N.name&&o(N),oe(N.name)},onTouchEnd:J(()=>{t?.name!==N.name&&o(N),oe(N.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:ie?r.jsx(_r,{className:ht("h-4 w-4",Z?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Oo,{className:ht("h-4 w-4",Z?"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:_===N.name?r.jsx("input",{type:"text",value:le,onChange:V=>se(V.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:y("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:V=>V.stopPropagation(),onKeyDown:V=>{V.key==="Enter"&&ct(N.name),V.key==="Escape"&&Fe()},style:{fontSize:"16px"}}):r.jsx("div",{className:ht(zo,Me&&"font-semibold"),children:vt})})]}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:_===N.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:V=>{V.stopPropagation(),ct(N.name)},title:y("tooltips.save"),children:r.jsx(rr,{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:V=>{V.stopPropagation(),Fe()},title:y("tooltips.cancel"),children:r.jsx(Wt,{className:"h-3.5 w-3.5"})})]}):r.jsxs(Mn,{children:[r.jsx(Dn,{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:V=>V.stopPropagation(),"aria-label":y("actions.settings"),children:r.jsx(_n,{className:"h-4 w-4"})})}),r.jsx(Pn,{children:r.jsxs(Rn,{side:q,align:de,sideOffset:ae,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:V=>V.stopPropagation(),children:[r.jsxs(Zt,{className:zr,onSelect:V=>{V.preventDefault(),Oe(N)},children:[r.jsx(Ia,{className:"h-4 w-4"}),y("tooltips.renameProject")]}),r.jsxs(Zt,{className:zr,onSelect:V=>{V.preventDefault(),M(N.name)},children:[r.jsx(Ta,{className:ht("h-4 w-4",Z&&"fill-yellow-400 text-yellow-500")}),y(Z?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(Da,{className:"my-1 h-px bg-border"}),r.jsxs(Zt,{className:Ln,onSelect:V=>{V.preventDefault(),at(N)},children:[r.jsx(Yt,{className:"h-4 w-4"}),y("tooltips.deleteProject")]})]})})]})})]})}),r.jsxs("div",{role:"button",tabIndex:0,className:ht("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",_===N.name?"h-auto":"h-9",Me?"text-foreground":"hover:text-foreground"),onClick:()=>{t?.name!==N.name&&o(N),oe(N.name)},onTouchEnd:J(()=>{t?.name!==N.name&&o(N),oe(N.name)}),onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),t?.name!==N.name&&o(N),oe(N.name))},title:N.fullPath||_e,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:ie?r.jsx(_r,{className:ht("h-4 w-4",Z?"text-yellow-600 dark:text-yellow-400":"text-foreground")}):r.jsx(Oo,{className:ht("h-4 w-4",Z?"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:_===N.name?r.jsx("input",{type:"text",value:le,onChange:V=>se(V.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:y("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:V=>{V.key==="Enter"&&ct(N.name),V.key==="Escape"&&Fe()},onClick:V=>V.stopPropagation()}):r.jsx("div",{className:ht(zo,Me&&"font-semibold"),children:vt})})]}),r.jsx("div",{className:"flex shrink-0 items-center gap-1 pl-1",children:_===N.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:V=>{V.stopPropagation(),ct(N.name)},title:y("tooltips.save"),children:r.jsx(rr,{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:V=>{V.stopPropagation(),Fe()},title:y("tooltips.cancel"),children:r.jsx(Wt,{className:"h-3.5 w-3.5"})})]}):r.jsxs(Mn,{children:[r.jsx(Dn,{asChild:!0,children:r.jsx("button",{className:ht("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:V=>V.stopPropagation(),"aria-label":y("actions.settings"),children:r.jsx(_n,{className:"h-4 w-4"})})}),r.jsx(Pn,{children:r.jsxs(Rn,{side:q,align:de,sideOffset:ae,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:V=>V.stopPropagation(),children:[r.jsxs(Zt,{className:zr,onSelect:V=>{V.preventDefault(),Oe(N)},children:[r.jsx(Ia,{className:"h-4 w-4"}),y("tooltips.renameProject")]}),r.jsxs(Zt,{className:zr,onSelect:V=>{V.preventDefault(),M(N.name)},children:[r.jsx(Ta,{className:ht("h-4 w-4",Z&&"fill-yellow-400 text-yellow-500")}),y(Z?"tooltips.removeFromFavorites":"tooltips.addToFavorites")]}),r.jsx(Da,{className:"my-1 h-px bg-border"}),r.jsxs(Zt,{className:Ln,onSelect:V=>{V.preventDefault(),at(N)},children:[r.jsx(Yt,{className:"h-4 w-4"}),y("tooltips.deleteProject")]})]})})]})})]})]}),Ce&&r.jsxs("div",{className:ht("space-y-1",D?"px-1 md:px-0":"px-0"),children:[be.has(N.name)?O(N).length===0&&!W[N.name]?r.jsx("div",{className:"px-3 py-2 text-left",children:r.jsx("p",{className:"text-xs text-muted-foreground",children:y("sessions.noSessions")})}):O(N).map(V=>{const At=V.__provider==="codex",U=V.__provider==="gemini",Y=V.__provider==="opencode",je=At||U||Y,Ze=ge===V.id&&!At,ft=n?.id===V.id,z=At?V.summary||V.name||y("projects.codexSession"):Y?V.summary||V.name||y("projects.opencodeSession"):V.summary||V.name||y("projects.newSession"),me=je&&V.createdAt||V.lastActivity,ue=Ae===V.id||st===V.id;return r.jsxs("div",{className:"group/session relative w-full min-w-0 max-w-full",onMouseEnter:()=>ye(V.id),onMouseLeave:()=>ye(re=>re===V.id?null:re),children:[r.jsx("div",{className:"w-full min-w-0 max-w-full md:hidden",children:r.jsxs("div",{className:ht("mx-1 grid min-h-9 min-w-0 grid-cols-[auto,minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-2xl px-3 py-2 transition-all duration-200",ft?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),onClick:()=>{o(N),x(V,N.name)},onTouchEnd:J(()=>{o(N),x(V,N.name)}),children:[r.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:r.jsx(Ra,{provider:V.__provider})}),r.jsx("div",{className:"min-w-0 flex-1 basis-0 overflow-hidden",children:Ze?r.jsx("input",{type:"text",value:A,onChange:re=>ee(re.target.value),onKeyDown:re=>{re.stopPropagation(),re.key==="Enter"?updateSessionSummary(N.name,V.id,A):re.key==="Escape"&&(Se(null),ee(""))},onClick:re=>re.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:zo,title:z,children:z})}),r.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1",children:Ze?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:re=>{re.stopPropagation(),updateSessionSummary(N.name,V.id,A)},title:y("tooltips.save"),children:r.jsx(rr,{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:re=>{re.stopPropagation(),Se(null),ee("")},title:y("tooltips.cancel"),children:r.jsx(Wt,{className:"h-3.5 w-3.5"})})]}):r.jsx(r.Fragment,{children:r.jsxs(Mn,{children:[r.jsx(Dn,{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:re=>re.stopPropagation(),"aria-label":y("actions.settings"),children:r.jsx(_n,{className:"h-4 w-4"})})}),r.jsx(Pn,{children:r.jsxs(Rn,{side:q,align:de,sideOffset:ae,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:re=>re.stopPropagation(),children:[!At&&r.jsxs(Zt,{className:zr,onSelect:re=>{re.preventDefault(),Se(V.id),ee(V.summary||V.name||y("projects.newSession"))},children:[r.jsx(_a,{className:"h-4 w-4"}),y("tooltips.editSessionName")]}),r.jsxs(Zt,{className:Ln,onSelect:re=>{re.preventDefault(),Ne(N.name,V.id,z,V.__provider)},children:[r.jsx(Yt,{className:"h-4 w-4"}),y("tooltips.deleteSession")]})]})})]})})})]})}),r.jsx("div",{className:"hidden w-full min-w-0 max-w-full md:block",children:r.jsxs("div",{className:ht("grid min-h-9 min-w-0 grid-cols-[minmax(0,1fr),auto] items-center gap-2 overflow-hidden rounded-2xl px-2 py-1.5 transition-all duration-200",ft?"chat-sidebar-item-active":"chat-sidebar-item hover:bg-muted/10"),children:[r.jsxs("button",{className:"flex w-full min-w-0 items-center gap-2 overflow-hidden text-left",onClick:()=>x(V,N.name),onTouchEnd:J(()=>x(V,N.name)),children:[r.jsx("span",{className:ht("flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground transition-opacity",ft||Ze?"opacity-100":"opacity-0 group-hover/session:opacity-100"),children:r.jsx(Ra,{provider:V.__provider})}),Ze?r.jsx("input",{type:"text",value:A,onChange:re=>ee(re.target.value),onKeyDown:re=>{re.stopPropagation(),re.key==="Enter"?updateSessionSummary(N.name,V.id,A):re.key==="Escape"&&(Se(null),ee(""))},onClick:re=>re.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:z,children:z})]}),r.jsx("div",{className:"relative flex shrink-0 items-center justify-end pl-1 min-w-[28px]",children:Ze?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:re=>{re.stopPropagation(),updateSessionSummary(N.name,V.id,A)},title:y("tooltips.save"),children:r.jsx(rr,{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:re=>{re.stopPropagation(),Se(null),ee("")},title:y("tooltips.cancel"),children:r.jsx(Wt,{className:"h-3.5 w-3.5"})})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:ht("text-[11px] text-muted-foreground whitespace-nowrap transition-opacity duration-200",ue?"opacity-0":"opacity-100"),children:og(me,K,y)}),ue&&r.jsx("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 flex items-center justify-end",children:r.jsxs(Mn,{onOpenChange:re=>Ke(re?V.id:null),children:[r.jsx(Dn,{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:re=>re.stopPropagation(),onFocus:()=>ye(V.id),"aria-label":y("actions.settings"),children:r.jsx(_n,{className:"h-4 w-4"})})}),r.jsx(Pn,{children:r.jsxs(Rn,{side:q,align:de,sideOffset:ae,className:"z-50 min-w-40 overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",onClick:re=>re.stopPropagation(),children:[!At&&r.jsxs(Zt,{className:zr,onSelect:re=>{re.preventDefault(),Se(V.id),ee(V.summary||V.name||y("projects.newSession"))},children:[r.jsx(_a,{className:"h-4 w-4"}),y("tooltips.editSessionName")]}),r.jsxs(Zt,{className:Ln,onSelect:re=>{re.preventDefault(),Ne(N.name,V.id,z,V.__provider)},children:[r.jsx(Yt,{className:"h-4 w-4"}),y("tooltips.deleteSession")]})]})})]})})]})})]})})]},V.id)}):Array.from({length:3}).map((V,At)=>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+At*15}%`}})},At)),O(N).length>0&&N.sessionMeta?.hasMore!==!1&&r.jsx(Ge,{variant:"subtle",size:"sm",className:"mt-2 w-full justify-center gap-2 rounded-xl text-muted-foreground hover:text-foreground",onClick:()=>Nt(N),disabled:W[N.name],children:W[N.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"}),y("sessions.loading")]}):r.jsxs(r.Fragment,{children:[r.jsx(vr,{className:"w-3 h-3"}),y("sessions.showMore")]})})]})]},N.name)})})}),p&&r.jsxs("div",{className:"px-3 py-3 flex-shrink-0",children:[r.jsx("div",{className:"hidden md:block",children:r.jsxs(Ge,{variant:"ghost",className:"mb-2 h-auto w-full justify-start gap-3 rounded-lg bg-blue-50/90 p-3 text-left font-normal transition-colors duration-200 hover:bg-blue-100 dark:bg-blue-900/20 dark:hover:bg-blue-900/30",onClick:w,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:h?.title||`Version ${f}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:y("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:w,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:h?.title||`Version ${f}`}),r.jsx("div",{className:"text-xs text-blue-600 dark:text-blue-400",children:y("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:[!pt&&r.jsxs(Ge,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:()=>E(!0),title:y("tooltips.createProject"),children:[r.jsx(Ar,{className:"w-4 h-4"}),r.jsx("span",{className:"text-xs leading-none",children:y("projects.newProject").includes("Project")?"New":y("projects.newProject").substring(0,2)})]}),r.jsxs(Ge,{variant:"ghost",className:"flex h-10 flex-1 items-center justify-center gap-2 rounded-xl bg-background/80 px-3 font-normal text-muted-foreground transition-colors duration-200 hover:bg-background hover:text-foreground",onClick:async()=>{ne(!0);try{await m()}finally{ne(!1)}},disabled:T,title:y("tooltips.refresh"),children:[r.jsx(cr,{className:`w-4 h-4 ${T?"animate-spin":""}`}),r.jsx("span",{className:"text-xs leading-none",children:y("actions.refresh")||"Sync"})]})]})})]})]})}function ag(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Oa(e){return e==null?null:typeof e=="string"?{content:e,isError:!1,toolUseResult:null}:{content:ag(e.content??e.output??e.result??""),isError:!!e.isError,toolUseResult:e.toolUseResult||null,exitCode:e.exitCode??e.exit_code}}function Fa(e,t){return e||""}function ig(e){const t=String(e||"").replace(/\\\s*\n\s*/g," ").trim();if(!t)return"";const o=t.split(/\s*(?:&&|\|\||;|\|)\s*/).map(s=>s.trim()).filter(Boolean).map(s=>s.split(/\s+/)[0]).filter(Boolean);return o.length===0?t:o.slice(0,4).join(" · ")+(o.length>4?"…":"")}function lg(e,t,n){return t?.file_path?t.file_path:t?.path?t.path:e==="Read"&&typeof n=="string"?n:""}function cg(e,t,n,o){const s=lg(e,t,t),a=Fa(s);if(e==="Bash"){const i=t?.command||"";return{activityKind:"command",title:o("activity.actions.runCommand"),summary:ig(i)||o("activity.actions.commandPending"),filePath:s,icon:xm,heavy:!0}}if(e==="Grep"||e==="Glob"){const i=t?.pattern||t?.glob||"",c=Fa(t?.path||""),d=[];return i&&d.push(i),c&&d.push(c),{activityKind:"search",title:o("activity.actions.searchContent"),summary:d.join(" · ")||o("activity.actions.searchPending"),filePath:t?.path||"",icon:ss,heavy:!1}}return e==="Read"?{activityKind:"read",title:o("activity.actions.readFile"),summary:a||o("activity.actions.readPending"),filePath:s,icon:Lp,heavy:!1}:e==="Edit"||e==="ApplyPatch"?{activityKind:"edit",title:o("activity.actions.updateFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:Mp,heavy:!0}:e==="Write"?{activityKind:"write",title:o("activity.actions.createFile"),summary:a||o("activity.actions.filePending"),filePath:s,icon:Pp,heavy:!0}:e==="TodoWrite"?{activityKind:"todo-write",title:o("activity.actions.updateTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:Aa,heavy:!0}:e==="TodoRead"?{activityKind:"todo-read",title:o("activity.actions.readTodo"),summary:o("activity.actions.todoSummary"),filePath:"",icon:Aa,heavy:!1}:e==="exit_plan_mode"?{activityKind:"plan",title:o("activity.actions.generatePlan"),summary:o("activity.actions.planSummary"),filePath:"",icon:Os,heavy:!0}:{activityKind:"tool",title:o("activity.actions.runTool"),summary:e,filePath:s,icon:Gu,heavy:!0}}function dg({status:e,messages:t=[],pendingPermissionRequests:n=[],t:o}){if(n.length>0){const a=n[0];return{phaseText:o("activity.stage.waitingPermission"),detailText:o("activity.requestTool",{tool:a.toolName||o("messageTypes.tool")}),canAbort:!0,startedAt:e?.startedAt||Date.now()}}const s=[...t].reverse().find(a=>a?.isToolUse);if(s&&!Oa(s.toolResult)&&!s.toolEndedAt){const a=Zi(s.toolInput)||{},i=Oa(s.toolResult),c=cg(s.toolName,a,null,o);return{phaseText:i?.isError?o("activity.stage.toolFailed"):c.activityKind==="search"?o("activity.stage.searching"):c.activityKind==="command"?o("activity.stage.runningCommand"):c.activityKind==="edit"||c.activityKind==="write"?o("activity.stage.editingFile"):c.activityKind==="read"?o("activity.stage.readingFile"):c.activityKind.startsWith("todo")?o("activity.stage.updatingTodo"):o("activity.stage.working"),detailText:c.summary,canAbort:e?.canAbort??!0,startedAt:e?.startedAt||Date.now()}}return e||null}const $e={USER_MESSAGE:"user_message",ASSISTANT_TEXT_START:"assistant_text_start",ASSISTANT_TEXT_DELTA:"assistant_text_delta",ASSISTANT_TEXT_END:"assistant_text_end",ASSISTANT_CONTENT_BLOCK:"assistant_content_block",REASONING_START:"reasoning_start",REASONING_DELTA:"reasoning_delta",REASONING_END:"reasoning_end",TOOL_CALL_START:"tool_call_start",TOOL_CALL_INPUT:"tool_call_input",TOOL_CALL_END:"tool_call_end",TOOL_RESULT:"tool_result",PLAN_UPDATE:"plan_update",MODE_UPDATE:"mode_update",AVAILABLE_COMMANDS_UPDATE:"available_commands_update",APPROVAL_REQUEST:"approval_request",APPROVAL_RESOLVED:"approval_resolved",SESSION_STATE_CHANGED:"session_state_changed",SYSTEM_NOTICE:"system_notice",ERROR:"error"};function Ut(e="evt"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}:${crypto.randomUUID()}`:`${e}:${Date.now()}:${Math.random().toString(36).slice(2,10)}`}function jc(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 Rt({kind:e,provider:t="claude",sessionId:n=null,timestamp:o,payload:s={},extensions:a={},rawRef:i=null,eventId:c=null}){return{eventId:c||Ut(e),kind:e,provider:t,sessionId:n,timestamp:jc(o),payload:s,extensions:a,rawRef:i}}function Ys(e){return!!(e&&typeof e=="object"&&typeof e.kind=="string"&&typeof e.eventId=="string")}function Uo({kindPrefix:e="assistant_text",text:t,provider:n,sessionId:o,timestamp:s,messageId:a,extensions:i={},rawRef:c=null}){if(typeof t!="string"||!t.trim())return[];const d=a||Ut(e),u={...i,messageId:d};return[Rt({kind:`${e}_start`,provider:n,sessionId:o,timestamp:s,payload:{messageId:d},extensions:u,rawRef:c}),Rt({kind:`${e}_delta`,provider:n,sessionId:o,timestamp:s,payload:{messageId:d,text:t},extensions:u,rawRef:c}),Rt({kind:`${e}_end`,provider:n,sessionId:o,timestamp:s,payload:{messageId:d},extensions:u,rawRef:c})]}function ug(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const o=`
|
|
2
|
+
|
|
3
|
+
[USER MESSAGE]
|
|
4
|
+
`,s=t.indexOf(o);return s>=0?t.slice(s+o.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 Wo(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 Ir(e){if(typeof e=="string")return e;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}function dr(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function Xs(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map(t=>dr(t)):[]}function Sc(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function pg(e){const t=e?.clientRequestId||e?.extensions?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function mg(e={}){return[...Array.isArray(e?.images)?e.images.map(n=>({type:"image",data:n?.data||n?.image||"",mimeType:n?.mimeType||"application/octet-stream",name:n?.name||n?.filename||""})):[],...Xs(e?.contentBlocks)]}function fg(e,t,n={}){const o=Sc(t);if(!o)return-1;const s=JSON.stringify(Xs(n.contentBlocks));return Tr(e,a=>String(a?.type||"").trim().toLowerCase()!=="user"||pg(a)!==o||String(a?.content||"")!==String(n.text||"")?!1:JSON.stringify(mg(a))===s)}function hg(e){if(!e||typeof e!="object")return null;const t=Array.isArray(e.availableModes)?e.availableModes.filter(o=>o&&typeof o=="object"&&String(o.id||"").trim()).map(o=>({id:String(o.id).trim(),name:String(o.name||o.id||"").trim()||String(o.id).trim(),description:o.description==null?null:String(o.description)})):[],n=typeof e.currentModeId=="string"&&e.currentModeId.trim()?e.currentModeId.trim():null;return!t.length&&!n?null:{availableModes:t,currentModeId:n||t[0]?.id||null}}function gg(e){return(Array.isArray(e?.availableCommands)?e.availableCommands:Array.isArray(e)?e:[]).filter(n=>n&&typeof n=="object"&&String(n.name||"").trim()).map(n=>({name:String(n.name).trim(),description:n.description==null?"":String(n.description),input:n.input&&typeof n.input=="object"?dr(n.input):null,source:"acp",namespace:"acp",type:"acp"}))}function On(e=null,t={}){const n=e&&typeof e=="object"?{...e}:{};return t.title!=null&&(n.title=String(t.title)),t.kind!=null&&(n.kind=String(t.kind)),t.status!=null&&(n.status=String(t.status)),t.rawInput!==void 0&&(n.rawInput=dr(t.rawInput)),t.rawOutput!==void 0&&(n.rawOutput=dr(t.rawOutput)),Array.isArray(t.contentBlocks)&&(n.content=dr(t.contentBlocks)),Array.isArray(t.locations)&&(n.locations=dr(t.locations)),Object.keys(n).length>0?n:null}function xg(e){const t=new Map;for(const n of e||[])if(!(n?.message?.role!=="user"||!Array.isArray(n?.message?.content)))for(const o of n.message.content)o?.type==="tool_result"&&o.tool_use_id&&t.set(o.tool_use_id,{content:o.content,isError:!!o.is_error,timestamp:n.timestamp,toolUseResult:n.toolUseResult||null});return t}function Tr(e,t){for(let n=e.length-1;n>=0;n-=1)if(t(e[n],n))return n;return-1}function $a(e="",t=""){return t?e?e.endsWith(t)?e:`${e}${t}`:t:e}function Fn(e,{messageId:t,timestamp:n,provider:o,isThinking:s=!1,kind:a="assistant"}){const i=Tr(e,d=>d?.eventMessageId===t&&!d.isToolUse&&!!d.isThinking==!!s);if(i>=0){const d={...e[i]};return d.isStreaming=!0,o&&(d.provider=o),n&&(d.timestamp=d.timestamp||n),e[i]=d,{messages:e,index:i}}const c={type:a,content:"",timestamp:n,provider:o,isStreaming:!0,eventMessageId:t};return s&&(c.isThinking=!0),e.push(c),{messages:e,index:e.length-1}}function yg(e,{messageId:t,timestamp:n,provider:o,role:s="assistant"}){const a=Tr(e,i=>i?.eventMessageId===t&&!i.isToolUse&&!i.isThinking&&String(i?.type||"").trim().toLowerCase()===String(s||"assistant").trim().toLowerCase());if(a>=0){const i={...e[a]};return o&&(i.provider=o),n&&!i.timestamp&&(i.timestamp=n),e[a]=i,{messages:e,index:a}}return e.push({type:s,content:"",timestamp:n,provider:o,isStreaming:!1,eventMessageId:t,contentBlocks:[]}),{messages:e,index:e.length-1}}function $n(e,{toolCallId:t,toolName:n,timestamp:o,provider:s}){const a=Tr(e,i=>i?.isToolUse&&(i.toolId===t||i.toolCallId===t));if(a>=0){const i={...e[a]};return n&&(i.toolName=n),s&&(i.provider=s),o&&!i.timestamp&&(i.timestamp=o),e[a]=i,{messages:e,index:a}}return e.push({type:"assistant",content:"",timestamp:o,provider:s,isToolUse:!0,toolName:n||"Unknown Tool",toolId:t,toolCallId:t}),{messages:e,index:e.length-1}}function vg(e=[],t="claude",n=null){if(!Array.isArray(e))return[];const o=[],s=xg(e);for(const a of e){const i=jc(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(m=>m?.type==="text").map(m=>m?.text||"").join(`
|
|
5
|
+
`):d=typeof a.message.content=="string"?a.message.content:String(a.message.content||"");const u=ug(d);u&&(!Wo(d)||u!==d)&&o.push(Rt({kind:$e.USER_MESSAGE,provider:t,sessionId:n,timestamp:i,payload:{text:u},rawRef:c}));continue}if(a?.type==="thinking"&&a?.message?.content){o.push(...Uo({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||Ut("tool"),u=a.toolResult||null;o.push(Rt({kind:$e.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),o.push(Rt({kind:$e.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,input:a.toolInput||""},rawRef:c})),o.push(Rt({kind:$e.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:d,toolName:a.toolName},rawRef:c})),u&&o.push(Rt({kind:$e.TOOL_RESULT,provider:t,sessionId:n,timestamp:u.timestamp||i,payload:{toolCallId:d,content:Ir(u.content),isError:!!u.isError,toolUseResult:u.toolUseResult||null},rawRef:c}));continue}if(a?.type==="tool_result"){o.push(Rt({kind:$e.TOOL_RESULT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:a.toolCallId||null,content:Ir(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"&&!Wo(d.text))o.push(...Uo({text:d.text,provider:t,sessionId:n,timestamp:i,rawRef:c}));else if(d?.type==="tool_use"){const u=d.id||Ut("tool"),m=s.get(d.id);o.push(Rt({kind:$e.TOOL_CALL_START,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),o.push(Rt({kind:$e.TOOL_CALL_INPUT,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,input:Ir(d.input||{})},rawRef:c})),o.push(Rt({kind:$e.TOOL_CALL_END,provider:t,sessionId:n,timestamp:i,payload:{toolCallId:u,toolName:d.name},rawRef:c})),m&&o.push(Rt({kind:$e.TOOL_RESULT,provider:t,sessionId:n,timestamp:m.timestamp||i,payload:{toolCallId:u,content:Ir(m.content),isError:!!m.isError,toolUseResult:m.toolUseResult||null},rawRef:c}))}}else Wo(a.message.content)||o.push(...Uo({text:a.message.content,provider:t,sessionId:n,timestamp:i,rawRef:c}));continue}a?.type&&/error/i.test(a.type)&&o.push(Rt({kind:$e.ERROR,provider:t,sessionId:n,timestamp:i,payload:{message:a.error||a.message||"Provider error"},rawRef:c}))}return o.sort((a,i)=>new Date(a.timestamp)-new Date(i.timestamp))}function Nc(e=[],t,n="claude"){const o=Array.isArray(e)?[...e]:[];if(!Ys(t))return o;const s=t.provider||n,a=t.timestamp||new Date().toISOString(),i=t.payload||{};switch(t.kind){case $e.USER_MESSAGE:{const c=Sc(t),d=fg(o,t,i),u=Xs(i.contentBlocks);if(d>=0){const m=o[d]||{},p=Array.isArray(m.images)&&m.images.length>0?u.filter(f=>f?.type!=="image"):u;o[d]={...m,type:"user",content:i.text||m.content||"",timestamp:m.timestamp||a,provider:s,contentBlocks:p,clientRequestId:c||m.clientRequestId||null,eventId:t.eventId||m.eventId,id:m.id||t.eventId||m.id};break}o.push({type:"user",content:i.text||"",timestamp:a,provider:s,contentBlocks:u,clientRequestId:c});break}case $e.ASSISTANT_TEXT_START:{const c=i.messageId||t.extensions?.messageId||Ut("assistant_text");Fn(o,{messageId:c,timestamp:a,provider:s,isThinking:!1});break}case $e.ASSISTANT_TEXT_DELTA:{const c=i.messageId||t.extensions?.messageId||Ut("assistant_text"),{index:d}=Fn(o,{messageId:c,timestamp:a,provider:s,isThinking:!1}),u={...o[d]};u.content=$a(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||s,o[d]=u;break}case $e.ASSISTANT_TEXT_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Tr(o,u=>u?.eventMessageId===c&&!u.isToolUse&&!u.isThinking);d>=0&&(o[d]={...o[d],isStreaming:!1});break}case $e.ASSISTANT_CONTENT_BLOCK:{const c=i.messageId||t.extensions?.messageId||Ut("assistant_content"),{index:d}=yg(o,{messageId:c,timestamp:a,provider:s,role:"assistant"}),u={...o[d]},m=Array.isArray(u.contentBlocks)?[...u.contentBlocks]:[];i.contentBlock&&typeof i.contentBlock=="object"&&m.push(dr(i.contentBlock)),u.contentBlocks=m,u.provider=u.provider||s,u.timestamp=u.timestamp||a,o[d]=u;break}case $e.REASONING_START:{const c=i.messageId||t.extensions?.messageId||Ut("reasoning");Fn(o,{messageId:c,timestamp:a,provider:s,isThinking:!0});break}case $e.REASONING_DELTA:{const c=i.messageId||t.extensions?.messageId||Ut("reasoning"),{index:d}=Fn(o,{messageId:c,timestamp:a,provider:s,isThinking:!0}),u={...o[d]};u.content=$a(u.content||"",i.text||""),u.timestamp=u.timestamp||a,u.provider=u.provider||s,u.isThinking=!0,o[d]=u;break}case $e.REASONING_END:{const c=i.messageId||t.extensions?.messageId;if(!c)break;const d=Tr(o,u=>u?.eventMessageId===c&&!!u.isThinking);d>=0&&(o[d]={...o[d],isStreaming:!1,isThinking:!0});break}case $e.TOOL_CALL_START:{const c=i.toolCallId||Ut("tool"),{index:d}=$n(o,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:s});o[d]={...o[d],toolName:i.toolName||o[d].toolName,acpToolCall:On(o[d].acpToolCall,i)};break}case $e.TOOL_CALL_INPUT:{const c=i.toolCallId||Ut("tool"),{index:d}=$n(o,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:s});o[d]={...o[d],toolInput:i.input!==void 0?Ir(i.input):i.rawInput!==void 0?Ir(i.rawInput):o[d].toolInput,provider:o[d].provider||s,acpToolCall:On(o[d].acpToolCall,i)};break}case $e.TOOL_CALL_END:{const c=i.toolCallId||t.extensions?.toolCallId;if(!c)break;const{index:d}=$n(o,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:s});o[d]={...o[d],toolName:i.toolName||o[d].toolName,toolEndedAt:a,acpToolCall:On(o[d].acpToolCall,i)};break}case $e.TOOL_RESULT:{const c=i.toolCallId||t.extensions?.toolCallId||Ut("tool"),{index:d}=$n(o,{toolCallId:c,toolName:i.toolName,timestamp:a,provider:s});o[d]={...o[d],toolResult:{content:Ir(i.content??""),isError:!!i.isError,toolUseResult:i.toolUseResult||null,rawOutput:i.rawOutput,contentBlocks:Array.isArray(i.contentBlocks)?dr(i.contentBlocks):null,status:i.status||null,timestamp:a},toolError:!!i.isError,toolEndedAt:o[d].toolEndedAt||a,provider:o[d].provider||s,acpToolCall:On(o[d].acpToolCall,i)};break}case $e.PLAN_UPDATE:{const c=Array.isArray(i.entries)?dr(i.entries):[],d=Tr(o,m=>!!m?.isPlanUpdate),u={...d>=0?o[d]:{},id:(d>=0?o[d]?.id:null)||`plan:${t.sessionId||s}`,type:"assistant",content:String(i.message||"Plan updated"),timestamp:a,provider:s,isPlanUpdate:!0,planEntries:c};d>=0?o[d]=u:o.push(u);break}case $e.APPROVAL_REQUEST:i.message&&o.push({type:"assistant",content:i.message,timestamp:a,provider:s,isApprovalRequest:!0,approvalRequest:i});break;case $e.APPROVAL_RESOLVED:i.message&&o.push({type:"assistant",content:i.message,timestamp:a,provider:s,approvalResolution:i});break;case $e.SYSTEM_NOTICE:if(i.message){const c=o[o.length-1];c&&c.type==="assistant"&&!c.isToolUse&&(c.content||"").trim()===String(i.message).trim()||o.push({type:"assistant",content:i.message,timestamp:a,provider:s,isSystemNotice:!0})}break;case $e.ERROR:o.push({type:"error",content:i.message||"Provider error",timestamp:a,provider:s,rawRef:t.rawRef||null,extensions:t.extensions||{}});break}return o}function Cc(e=[],t="claude"){return Array.isArray(e)?e.length>0&&!Ys(e[0])?Cc(vg(e,t),t):e.reduce((n,o)=>Nc(n,o,t),[]):[]}function bg(e=[]){const t={modeState:null,availableCommands:[]};for(const n of Array.isArray(e)?e:[])if(Ys(n)){if(n.kind===$e.MODE_UPDATE){const o=hg(n.payload||{});o&&(t.modeState=t.modeState?{availableModes:o.availableModes.length>0?o.availableModes:t.modeState.availableModes,currentModeId:o.currentModeId||t.modeState.currentModeId||null}:o)}n.kind===$e.AVAILABLE_COMMANDS_UPDATE&&(t.availableCommands=gg(n.payload||{}))}return t}const ve={IDLE:"idle",CONNECTING:"connecting",QUEUED:"queued",STREAMING:"streaming",AWAITING_APPROVAL:"awaiting_approval",COMPLETED:"completed",ABORTED:"aborted",ERRORED:"errored"},to=new Set([ve.CONNECTING,ve.QUEUED,ve.STREAMING,ve.AWAITING_APPROVAL]);function lr(e){return e==null?"":String(e).replace(/\r\n/g,`
|
|
6
|
+
`).trim()}function Ba(e){return!e||typeof e!="object"?{content:"",isError:!1}:{content:lr(e.content),isError:!!e.isError}}function wg(e,t){if(!e||!t)return!1;const n=String(e.type||""),o=String(t.type||"");if(n!==o)return!1;const s=!!e.isToolUse,a=!!t.isToolUse;if(s!==a)return!1;if(s&&a){const i=Ba(e.toolResult),c=Ba(t.toolResult);return lr(e.toolName)===lr(t.toolName)&&lr(e.toolInput)===lr(t.toolInput)&&i.content===c.content&&i.isError===c.isError}return!!e.isThinking!=!!t.isThinking?!1:lr(e.content)===lr(t.content)}function kg(e,t){const n=Math.min(e.length,t.length);let o=0;for(;o<n&&wg(e[o],t[o]);)o+=1;return o}function jg(e=[],t=[],n={}){const o=Array.isArray(e)?e:[],s=Array.isArray(t)?t:[],a=!!n.preserveLocalTail;if(o.length===0)return s;if(s.length===0)return a?o:s;const i=kg(o,s);return i===o.length&&i===s.length?s:a&&i===s.length&&o.length>s.length?o:s}function Bn(e,t){return typeof t=="function"?t(e):t}function za(e,t={}){const n=to.has(e),o=to.has(e);return{isLoading:n,canAbortSession:o,...t}}function ms(e,t=ve.IDLE){const n=String(e||"").trim().toLowerCase();return Object.values(ve).includes(n)?n:t}function Sg(e,t){return!e||typeof e!="object"?t:e.kind===$e.SESSION_STATE_CHANGED?ms(e.payload?.state,t):e.kind===$e.APPROVAL_REQUEST?ve.AWAITING_APPROVAL:e.kind===$e.APPROVAL_RESOLVED?ve.STREAMING:e.kind===$e.ERROR?ve.ERRORED:e.kind===$e.ASSISTANT_TEXT_START||e.kind===$e.ASSISTANT_TEXT_DELTA||e.kind===$e.ASSISTANT_CONTENT_BLOCK||e.kind===$e.REASONING_START||e.kind===$e.REASONING_DELTA||e.kind===$e.TOOL_CALL_START||e.kind===$e.TOOL_CALL_INPUT||e.kind===$e.TOOL_CALL_END||e.kind===$e.TOOL_RESULT||e.kind===$e.PLAN_UPDATE||e.kind===$e.SYSTEM_NOTICE?ve.STREAMING:t}function Ng(e,t){const n=t?.payload||{},o=n.requestId||t?.extensions?.requestId||null,s=n.toolCall&&typeof n.toolCall=="object"?n.toolCall:null,a=Array.isArray(n.options)?n.options:Array.isArray(n.context?.options)?n.context.options:[];return!o||e.some(i=>i?.requestId===o)?e:[...e,{requestId:o,toolName:s?.title||n.toolName||"UnknownTool",input:s?.rawInput??n.input,context:{...n.context||{},kind:s?.kind||n.context?.kind||null,options:a},toolCall:s,options:a,message:n.message||null,sessionId:t?.sessionId||n.sessionId||null,receivedAt:t?.timestamp||new Date().toISOString()}]}function Cg(e,t){const o=(t?.payload||{}).requestId||t?.extensions?.requestId||null;return o?e.filter(s=>s?.requestId!==o):e}function Eg(e,t){return t?e===ve.AWAITING_APPROVAL||to.has(e)?e:ve.STREAMING:e===ve.COMPLETED||e===ve.ABORTED||e===ve.ERRORED?e:ve.IDLE}function Ag(e=[]){return{messages:e,pendingPermissionRequests:[],phase:ve.IDLE,isLoading:!1,canAbortSession:!1}}function Ig(e,t){switch(t.type){case"replace_messages":return{...e,messages:Bn(e.messages,t.value)};case"replace_permissions":return{...e,pendingPermissionRequests:Bn(e.pendingPermissionRequests,t.value)};case"set_phase":{const n=ms(t.phase,e.phase);return{...e,phase:n,...za(n,t.overrides)}}case"set_loading":{const n=!!Bn(e.isLoading,t.value),o=Eg(e.phase,n);return{...e,phase:o,isLoading:n,canAbortSession:n?e.canAbortSession||to.has(o):!1}}case"set_can_abort":return{...e,canAbortSession:!!Bn(e.canAbortSession,t.value)};case"apply_conversation_event":{const n=Nc(e.messages,t.event,t.provider),o=Sg(t.event,e.phase);let s=e.pendingPermissionRequests;if(t.event?.kind===$e.APPROVAL_REQUEST)s=Ng(s,t.event);else if(t.event?.kind===$e.APPROVAL_RESOLVED)s=Cg(s,t.event);else if(t.event?.kind===$e.SESSION_STATE_CHANGED){const a=ms(t.event?.payload?.state,"");(a===ve.COMPLETED||a===ve.ABORTED||a===ve.ERRORED||a===ve.IDLE)&&(s=[])}return{...e,messages:n,pendingPermissionRequests:s,phase:o,...za(o)}}default:return e}}function Nr(e){return e&&e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function _g(e){if(!e||typeof e!="string")return e;try{return e.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return e}}function fs(e){try{return typeof e!="string"?e:e.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(t,n)=>{let o=parseInt(n,10);if(!Number.isFinite(o))return t;o<1e12&&(o*=1e3);const s=new Date(o),a=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(s),i=-s.getTimezoneOffset(),c=i>=0?"+":"-",d=Math.abs(i),u=Math.floor(d/60),m=d%60,p=`GMT${c}${u}${m?`:${String(m).padStart(2,"0")}`:""}`,h=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,L=>L.toUpperCase()),w=h?`${p} (${h})`:p,v=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],S=`${s.getDate()} ${v[s.getMonth()]} ${s.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${a} ${w}** - ${S}`})}catch{return e}}function Tg(e){const t=String(e||"").trim();if(!t||t.startsWith("# AGENTS.md instructions for ")||t.includes("<environment_context>"))return"";if(t.startsWith("[DYNAMIC CONTEXT V1]")){const o=`
|
|
7
|
+
|
|
8
|
+
[USER MESSAGE]
|
|
9
|
+
`,s=t.indexOf(o);return s>=0?t.slice(s+o.length).trim():""}const n=t.match(/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i);return n?String(n[1]||"").trim():t}function Qs(e=[]){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];if(t.isToolUse||t.isPlanUpdate||t.approvalRequest||t.approvalResolution)return[t];if(typeof t.content!="string")return[t];const n=Tg(t.content);return n?n===t.content?[t]:[{...t,content:n}]:[]}):[]}function Mg(e=[],t=[]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const o=e[n],s=t[n];if(o?.type!==s?.type||o?.role!==s?.role||o?.content!==s?.content||o?.timestamp!==s?.timestamp||!!o?.isToolUse!=!!s?.isToolUse)return!1}return!0}function Zs({phaseText:e,detailText:t="",canAbort:n=!0,startedAt:o=Date.now(),elapsedSeconds:s}={}){return{phaseText:e,detailText:t,canAbort:n,startedAt:o,elapsedSeconds:s}}function Dg(e,t,n=null){const o=n?.startedAt||Date.now(),s=typeof e=="string"?e:e?.message||e?.status||e?.text||"",a=String(s||"").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")),Zs({phaseText:c,detailText:a,canAbort:e?.can_interrupt!==!1,startedAt:o,elapsedSeconds:e?.elapsedSeconds})}const Pg=({node:e,inline:t,className:n,children:o,...s})=>{const{t:a}=kt("chat"),[i,c]=l.useState(!1),d=Array.isArray(o)?o.join(""):String(o??""),u=/[\r\n]/.test(d);if(t||e&&e.type==="inlineCode"||!u)return r.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${n||""}`,...s,children:o});const f=/language-(\w+)/.exec(n||""),g=f?f[1]:"text",h=d,w=()=>{const v=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator?.clipboard?.writeText)navigator.clipboard.writeText(h).then(v).catch(()=>{const S=document.createElement("textarea");S.value=h,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select();try{document.execCommand("copy")}catch{}document.body.removeChild(S),v()});else{const S=document.createElement("textarea");S.value=h,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select();try{document.execCommand("copy")}catch{}document.body.removeChild(S),v()}}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:w,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(Qu,{language:g,style:Zu,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})]})},Rg={code:Pg,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})},hs=({children:e,className:t})=>{const n=_g(String(e??"")),o=l.useMemo(()=>[Vu,Ju],[]),s=l.useMemo(()=>[Yu],[]);return r.jsx("div",{className:t,children:r.jsx(Xu,{remarkPlugins:o,rehypePlugins:s,components:Rg,children:n})})};l.memo(({message:e,prevMessage:t,provider:n,showThinking:o,isActiveStreamingCard:s})=>{const{t:a}=kt("chat"),i=e.provider||e.__provider||n||"claude",c=i==="codex",d=i==="gemini",u=i==="opencode",m=t&&t.type===e.type&&(t.type==="assistant"||t.type==="user"||t.type==="tool"||t.type==="error");return r.jsx("div",{className:`chat-message ${e.type} ${m?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?r.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[r.jsxs("div",{className:"bg-primary text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[r.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&r.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((p,f)=>r.jsx("img",{src:p.data,alt:p.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(p.data,"_blank")},f))}),r.jsx("div",{className:"text-xs text-primary-foreground/80 mt-1 text-right",children:new Date(e.timestamp).toLocaleTimeString()})]}),!m&&r.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-primary rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):r.jsxs("div",{className:"w-full",children:[!m&&r.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.type==="error"?r.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):e.type==="tool"?r.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):r.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:c?r.jsx(vo,{className:"w-full h-full"}):d?r.jsx(bo,{className:"w-full h-full"}):u?r.jsx(wo,{className:"h-full w-auto max-w-full text-gray-900 dark:text-white"}):r.jsx(kn,{className:"w-full h-full"})}),r.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.type==="error"?a("messageTypes.error"):e.type==="tool"?a("messageTypes.tool"):c?a("messageTypes.codex"):d?a("messageTypes.gemini"):u?"OpenCode":a("messageTypes.claude")})]}),r.jsxs("div",{className:"w-full",children:[e.isToolUse?r.jsx(ep,{toolName:e.toolName||"Tool",argsText:typeof e.toolInput=="string"?e.toolInput:JSON.stringify(e.toolInput??{},null,2),result:e.toolResult,isError:!!(e.toolResult?.isError||e.isError),status:e.isStreaming||e.toolResult==null?{type:"running"}:e.toolResult?.isError||e.isError?{type:"incomplete",reason:"error"}:{type:"complete"}}):e.isThinking?r.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:r.jsxs("details",{className:"group",open:s,children:[r.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[r.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r.jsx("span",{children:a("thinking.emoji")})]}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:r.jsx(hs,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):r.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[o&&e.reasoning&&r.jsxs("details",{className:"mb-3",open:s,children:[r.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:a("thinking.emoji")}),r.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:r.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const p=fs(String(e.content||"")),f=p.trim();if((f.startsWith("{")||f.startsWith("["))&&(f.endsWith("}")||f.endsWith("]")))try{const g=JSON.parse(f),h=JSON.stringify(g,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:h})})})]})}catch{}return e.type==="assistant"?r.jsx(hs,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:p}):r.jsx("div",{className:"whitespace-pre-wrap",children:p})})()]}),r.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${m?"opacity-0 group-hover:opacity-100":""}`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})});const Lg=[{id:"claude",label:"Claude Code",Logo:kn},{id:"codex",label:"Codex",Logo:vo},{id:"gemini",label:"Gemini",Logo:bo},{id:"opencode",label:"OpenCode",Logo:wo}];function Og({provider:e,onSelect:t}){return r.jsx("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2",children:Lg.map(({id:n,label:o,Logo:s})=>r.jsxs("button",{onMouseDown:a=>a.preventDefault(),onClick:()=>t(n),className:`group relative w-full flex items-center gap-3 rounded-2xl border px-4 py-3 text-left transition-all duration-200 ${e===n?"border-primary/50 bg-primary/5 text-foreground shadow-sm":"border-border/60 bg-muted/10 text-muted-foreground hover:bg-muted/20 hover:text-foreground"}`,children:[n==="opencode"?r.jsx(s,{className:"h-10 w-auto max-w-full flex-shrink-0 text-foreground"}):r.jsx(s,{className:"h-10 w-10 flex-shrink-0"}),r.jsx("div",{className:"text-left font-medium text-[14px] leading-6",children:o})]},n))})}function Fg(e,t){const n=e.split(`
|
|
10
|
+
`),o=t.split(`
|
|
11
|
+
`),s=[];let a=0,i=0;for(;a<n.length||i<o.length;){const c=n[a],d=o[i];a>=n.length?(s.push({type:"added",content:d,lineNum:i+1}),i+=1):i>=o.length?(s.push({type:"removed",content:c,lineNum:a+1}),a+=1):c===d?(a+=1,i+=1):(s.push({type:"removed",content:c,lineNum:a+1}),s.push({type:"added",content:d,lineNum:i+1}),a+=1,i+=1)}return s}function $g({selectedProject:e,selectedSession:t,currentSessionId:n,provider:o,chatMessages:s,threadMessages:a,isLoading:i,isLoadingSessionMessages:c,isLoadingMoreMessages:d,hasMoreMessages:u,totalMessages:m,sessionMessages:p,visibleMessageCount:f,pendingPermissionRequests:g,scrollContainerRef:h,messagesEndRef:w,onScroll:v,onLoadEarlierSessionMessages:S,onLoadEarlierMessages:L,onProviderSelection:k,onFileOpen:B,onShowSettings:E,onGrantToolPermission:y,onPermissionDecision:I,autoExpandTools:$,showRawParameters:_}){const{t:H}=kt("chat"),le=o==="codex"?"Codex":o==="gemini"?"Gemini":o==="opencode"?"OpenCode":"Claude",se=l.useMemo(()=>{const ce=new Map;return(he,be)=>{const pe=`${he.length}-${be.length}-${he.slice(0,50)}`;if(ce.has(pe))return ce.get(pe);const K=Fg(he,be);if(ce.set(pe,K),ce.size>100){const De=ce.keys().next().value;ce.delete(De)}return K}},[]),W=s.length===0?null:r.jsxs(r.Fragment,{children:[d&&r.jsx("div",{className:"pb-3 text-center text-gray-500 dark:text-gray-400",children:r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),r.jsx("p",{className:"text-sm",children:H("session.loading.olderMessages")})]})}),u&&!d&&r.jsx("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:m>0&&r.jsxs("span",{children:[H("session.messages.showingOf",{shown:p.length,total:m})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:S,children:H("session.messages.loadEarlier")}),r.jsx("span",{className:"ml-1 text-xs",children:H("session.messages.scrollToLoad")})]})}),!t&&!u&&s.length>f&&r.jsxs("div",{className:"mb-3 text-center text-gray-500 dark:text-gray-400 text-sm",children:[H("session.messages.showingLast",{count:f,total:s.length})," •",r.jsx("button",{className:"ml-1 text-primary hover:text-primary underline",onClick:L,children:H("session.messages.loadEarlier")})]})]}),Q=s.length===0?null:r.jsx(r.Fragment,{children:g.map(ce=>r.jsx(tp,{request:ce,className:"mx-1 my-3 sm:mx-0",onSelectOption:he=>I(ce.requestId,{optionId:he,outcome:{outcome:"selected",optionId:he}}),onCancel:()=>I(ce.requestId,{cancelled:!0,outcome:{outcome:"cancelled"}})},ce.requestId))});return e?r.jsx("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:c&&s.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:H("session.loading.sessionMessages")})]})}):s.length===0?r.jsx("div",{className:"flex h-full items-center justify-center overflow-y-auto px-4 py-8 sm:px-6",children:!t&&!n?r.jsxs("div",{className:"w-full max-w-3xl text-center",children:[r.jsx("h2",{className:"mb-2 text-3xl font-semibold tracking-tight text-foreground sm:text-4xl",children:H("providerSelection.title")}),r.jsx("p",{className:"mx-auto mb-8 max-w-xl text-base text-muted-foreground",children:H("providerSelection.description")}),r.jsx(Og,{provider:o,onSelect:k})]}):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:H("session.continue.title")}),r.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:H("session.continue.description")})]})}):r.jsx(rp,{messages:a,convertMessage:np,isRunning:i,scrollContainerRef:h,onScroll:v,messagesEndRef:w,provider:o,providerLabel:le,createDiff:se,onFileOpen:B,onShowSettings:E,onGrantToolPermission:y,showRawParameters:_,autoExpandTools:$,selectedProject:e,markdownRenderer:hs,topContent:W,bottomContent:Q})}):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(em,{className:"h-7 w-7"})}),r.jsx("p",{className:"text-base font-medium text-foreground",children:"Select a project to start chatting"})]})})}const zn=({children:e,content:t,position:n="top",className:o="",delay:s=500})=>{const[a,i]=l.useState(!1),[c,d]=l.useState(null),u=()=>{const g=setTimeout(()=>{i(!0)},s);d(g)},m=()=>{c&&(clearTimeout(c),d(null)),i(!1)},p=()=>{switch(n){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},f=()=>{switch(n){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return t?r.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:m,children:[e,a&&r.jsxs("div",{className:ht("absolute z-50 w-max max-w-[min(32rem,calc(100vw-2rem))] px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-normal break-words pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",p(),o),children:[t,r.jsx("div",{className:ht("absolute w-0 h-0 border-4 border-transparent",f())})]})]}):e};function Bg(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zg(e){if(typeof e!="string")return"";const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]||e}function Ec(e,t=""){let n=[];for(const o of Array.isArray(e)?e:[]){const s=t?`${t}/${o.name}`:o.name;o.type==="directory"&&o.children?n=n.concat(Ec(o.children,s)):o.type==="file"&&n.push({name:o.name,path:s,relativePath:o.path})}return n}const Vr="1",Ua=5,Wa="replace",gs="append";function ur(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function or(e){return typeof e=="string"&&e.trim().length>0}function xs(e){if(typeof e!="string")return"";try{return decodeURIComponent(e).trim()}catch{return e.trim()}}function ko(e,{allowEmptyPath:t=!0}={}){return typeof e=="string"?!t&&!e.trim()?null:{path:e,displayName:""}:!ur(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 Jr(e){return ko(e)?.path||""}function Ug(e){const t=ko(e);return t?or(t.displayName)?t.displayName:zg(t.path):""}function Wg(e,t=72){if(typeof e!="string")return"";const n=e.trim().replace(/\s+/g," ");if(n.length<=t)return n;const o=n.split(/\s*>\s*/).filter(Boolean);if(o.length<=1)return`...${n.slice(-(t-3))}`;const s=[];let a=3;for(let c=o.length-1;c>=0;c-=1){const d=o[c],u=a+d.length+(s.length>0?3:0);if(s.length>0&&u>t)break;s.unshift(d),a=u}const i=`... > ${s.join(" > ")}`;return i.length<=t?i:`...${i.slice(-(t-3))}`}function Ha(e){if(!e)return"";const t=[];or(e.label)&&t.push(e.label.trim());const n=Wg(e.selector);return n&&t.push(n),t.join(" · ")}function Hg(e){return e?or(e.systemContext)||or(Jr(e.currentFile))||Array.isArray(e.selectedElements)&&e.selectedElements.length>0?!0:ur(e.extensions)&&Object.keys(e.extensions).length>0:!1}function qg(e){return e?or(e.systemContext)||or(Jr(e.currentFile))?!0:Array.isArray(e.selectedElements)&&e.selectedElements.length>0:!1}function Ac(e){if(!ur(e)||e.version!==Vr||typeof e.systemContext!="string")return null;const t=ko(e.currentFile);if(!t||!Array.isArray(e.selectedElements))return null;const n=[];for(const s of e.selectedElements){if(!ur(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})}if(e.extensions!==void 0&&!ur(e.extensions))return null;const o={version:Vr,systemContext:e.systemContext,currentFile:t,selectedElements:n};return e.extensions!==void 0&&(o.extensions={...e.extensions}),o}function Kg(e){if(!ur(e)||e.version!==void 0&&e.version!==Vr||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=ko(e.currentFile);if(!n)return null;t.currentFile=n}if(e.selectedElements!==void 0){const n=[];for(const o of e.selectedElements){if(!ur(o)||typeof o.tag!="string"||typeof o.selector!="string"||typeof o.label!="string")return null;n.push({tag:o.tag,selector:o.selector,label:o.label})}t.selectedElements=n}if(e.extensions!==void 0){if(!ur(e.extensions))return null;t.extensions={...e.extensions}}return t}function Gg(e){return`${e.tag}::${e.selector}::${e.label}`}function Vg(e){if(!Array.isArray(e)||e.length===0)return[];const t=new Set,n=[];for(const o of e){const s=Gg(o);t.has(s)||(t.add(s),n.push(o))}return n}function Jg(){return{version:Vr,systemContext:"",currentFile:{path:"",displayName:""},selectedElements:[]}}function Yg(e,t){const n=Ac(e)||Jg(),o=Kg(t);if(!o)return null;const s={...n};return o.systemContext!==void 0&&(s.systemContext=o.systemContext),o.currentFile!==void 0&&(s.currentFile=o.currentFile),o.selectedElements!==void 0&&(s.selectedElements=Vg([...Array.isArray(n.selectedElements)?n.selectedElements:[],...o.selectedElements])),o.extensions!==void 0&&(s.extensions={...ur(n.extensions)?n.extensions:{},...o.extensions}),s}function Xg(e){return typeof e!="string"?Wa:e.trim().toLowerCase()===gs?gs:Wa}function qa(e){if(e==null||e==="")return null;let t=e;if(typeof e=="string"){const o=xs(e);if(!o)return null;try{t=JSON.parse(o)}catch{return console.warn("[DynamicContext] Ignored invalid context JSON string."),null}}const n=Ac(t);return n||(console.warn("[DynamicContext] Ignored invalid context payload."),null)}function Qg(e){if(!e)return null;const t={version:Vr,systemContext:e.systemContext||"",currentFile:Jr(e.currentFile),selectedElements:Array.isArray(e.selectedElements)?e.selectedElements:[]};return e.extensions!==void 0&&(t.extensions=e.extensions),t}function Zg(e,t){return`<dynamic_context version="${Vr}">
|
|
12
|
+
${JSON.stringify(e,null,2)}
|
|
13
|
+
</dynamic_context>
|
|
14
|
+
|
|
15
|
+
<user_message>
|
|
16
|
+
${t}
|
|
17
|
+
</user_message>`}function ex({visibleDynamicContext:e,visibleSelectedElements:t,hiddenSelectedElements:n,onDismissSystemContext:o,onDismissCurrentFile:s,onDismissSelectedElement:a}){const{t:i}=kt("chat");return e?r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[or(e.systemContext)&&r.jsx(zn,{content:e.systemContext,className:"whitespace-normal break-words max-w-sm",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[260px] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-300 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5h16M4 12h16M4 19h16"})}),r.jsx("span",{className:"truncate",children:i("input.dynamicContext.systemChip")}),r.jsx("button",{type:"button",onClick:o,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:i("input.dynamicContext.removeSystem"),"aria-label":i("input.dynamicContext.removeSystem"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),or(Jr(e.currentFile))&&r.jsx(zn,{content:Jr(e.currentFile),className:"whitespace-normal break-words max-w-sm",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[260px] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-emerald-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),r.jsx("span",{className:"truncate",children:Ug(e.currentFile)}),r.jsx("button",{type:"button",onClick:s,className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:i("input.dynamicContext.removeCurrentFile"),"aria-label":i("input.dynamicContext.removeCurrentFile"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),t.map((c,d)=>r.jsx(zn,{content:Ha(c),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-normal break-words",delay:200,children:r.jsxs("div",{className:"inline-flex max-w-[min(22rem,calc(100vw-4rem))] items-center gap-1.5 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-foreground",title:c.selector,children:[r.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 15l2 5L7 17l3-10 10 3-5 2z"})}),r.jsx("span",{className:"truncate",children:c.tag||i("input.dynamicContext.elementFallback")}),r.jsx("button",{type:"button",onClick:()=>a(c),className:"ml-0.5 text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors",title:i("input.dynamicContext.removeElement"),"aria-label":i("input.dynamicContext.removeElement"),children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},`${c.selector}-${d}`)),n.length>0&&r.jsx(zn,{content:n.map(Ha).join(`
|
|
18
|
+
`),className:"max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words",delay:200,children:r.jsxs("div",{className:"inline-flex items-center gap-1 rounded-lg border border-border/70 bg-background px-2 py-1 text-xs text-muted-foreground",children:["+",n.length]})})]})}):null}function tx({file:e,onRemove:t,uploadProgress:n,error:o}){const[s,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:s,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,"%"]})}),o&&r.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:r.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),r.jsx("button",{onClick:t,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",children:r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}function rx({attachedImages:e,uploadingImages:t,imageErrors:n,onRemove:o}){return e.length?r.jsx("div",{className:"chat-subtle-surface mb-2 rounded-xl p-2.5",children:r.jsx("div",{className:"flex flex-wrap gap-2",children:e.map((s,a)=>r.jsx(tx,{file:s,onRemove:()=>o(a),uploadProgress:t.get(s.name),error:n.get(s.name)},`${s.name}-${a}`))})}):null}function nx(e){if(typeof e?.percentage=="number")return`${Math.min(100,Math.max(0,e.percentage))}%`;if(typeof e?.used=="number"&&typeof e?.total=="number"&&e.total>0){const t=Math.round(e.used/e.total*100);return`${Math.min(100,Math.max(0,t))}%`}return"0%"}function ox({composer:e,statusPresentation:t,shouldShowClaudeStatus:n,isLoading:o,chatMessages:s,sendByCtrlEnter:a}){const{t:i}=kt("chat"),{provider:c,currentModel:d,modelOptions:u,selectedModelLabel:m,isModelSelectionLocked:p,isOpencodeModelLoading:f,permissionMode:g,acpModes:h,acpModeId:w,handleAcpModeChange:v,selectedPermissionShortLabel:S,permissionDropdownTitle:L,providerModeConfig:k,getPermissionModeLabel:B,providerThinkingConfig:E,thinkingMode:y,setThinkingMode:I,tokenBudget:$,input:_,isInputFocused:H,setIsInputFocused:le,textareaRef:se,inputContainerRef:W,inputHighlightRef:Q,showFileDropdown:ce,filteredFiles:he,selectedFileIndex:be,selectFile:pe,showCommandMenu:K,filteredCommands:De,selectedCommandIndex:P,handleCommandSelect:j,commandQuery:T,frequentCommands:ne,slashPosition:ge,setShowCommandMenu:Se,setSelectedCommandIndex:A,setSlashPosition:ee,setCommandQuery:Ae,getRootProps:ye,getInputProps:st,isDragActive:Ke,openImagePicker:we,attachedImages:Le,uploadingImages:ze,imageErrors:rt,removeAttachedImage:Xe,visibleDynamicContext:Ve,visibleSelectedElements:fe,hiddenSelectedElements:Re,handleDismissSystemContext:et,handleDismissCurrentFile:Ye,handleDismissSelectedElement:Qe,renderInputWithMentions:ot,handleInputChange:J,handleTextareaClick:oe,handleKeyDown:x,handlePaste:M,syncInputOverlayScroll:G,handleTextareaInput:O,activeInputProvider:te,isActiveProviderNotInstalled:Ie,unavailablePlaceholder:Oe,isInputDisabled:Fe,activeProviderInstallReason:ct,activeProviderInstallHint:Ne,isCheckingProviderInstallation:Pe,checkProviderInstallation:at,providerCheckLoadingByName:yt,handleSubmit:Nt,isUserScrolledUp:dt,scrollToBottom:pt,setProviderModel:wt,setPermissionMode:ke,selectedSession:q,handleAbortSession:de,modelSelectorRef:ae,permissionSelectorRef:N,activeProviderInstallState:ie,activeInputProviderLabel:Me}=e;return r.jsxs("div",{className:"flex-shrink-0 bg-background px-3 py-3 sm:px-4 sm:py-4 pb-2 sm:pb-4 md:pb-6",children:[r.jsx("div",{className:"flex-1",children:r.jsx(op,{phaseText:t?.phaseText,detailText:t?.detailText,elapsedSeconds:t?.elapsedSeconds,startedAt:t?.startedAt,canAbort:t?.canAbort,isLoading:n,onAbort:de,provider:c})}),r.jsx("div",{ref:W,className:"mx-auto mb-3 w-full max-w-4xl"}),r.jsxs("form",{onSubmit:Nt,className:"relative mx-auto w-full max-w-4xl",children:[dt&&s.length>0&&r.jsx("button",{type:"button",onClick:pt,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"})})}),Ke&&r.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center rounded-2xl border border-dashed border-primary bg-primary/5",children:r.jsxs("div",{className:"rounded-xl border border-border/70 bg-background p-4",children:[r.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),r.jsx("p",{className:"text-sm font-medium",children:"将图片拖到这里"})]})}),r.jsx(rx,{attachedImages:Le,uploadingImages:ze,imageErrors:rt,onRemove:Xe}),r.jsx(ex,{visibleDynamicContext:Ve,visibleSelectedElements:fe,hiddenSelectedElements:Re,onDismissSystemContext:et,onDismissCurrentFile:Ye,onDismissSelectedElement:Qe}),ce&&he.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:he.map((Z,C)=>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 ${C===be?"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:D=>{D.preventDefault(),D.stopPropagation()},onClick:D=>{D.preventDefault(),D.stopPropagation(),pe(Z)},children:[r.jsx("div",{className:"font-medium text-sm",children:Z.name}),r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:Z.path})]},Z.path))}),r.jsx(sp,{commands:De,selectedIndex:P,onSelect:j,onClose:()=>{Se(!1),ee(-1),Ae(""),A(-1)},position:{top:se.current?Math.max(16,se.current.getBoundingClientRect().top-316):0,left:se.current?se.current.getBoundingClientRect().left:16,bottom:se.current?window.innerHeight-se.current.getBoundingClientRect().top+8:90},isOpen:K,frequentCommands:T?[]:ne}),r.jsxs("div",{...ye(),className:`chat-composer-shell relative overflow-visible rounded-[20px] transition-all duration-200 ${e.isTextareaExpanded?"chat-input-expanded":""} ${H?"border-primary/40 ring-2 ring-primary/10":"hover:border-border hover:shadow-md"}`,children:[r.jsx("input",{...st()}),r.jsx("div",{ref:Q,"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:ot(_)})}),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:se,value:_,onChange:J,onClick:oe,onKeyDown:x,onPaste:M,onScroll:Z=>G(Z.target),onFocus:()=>le(!0),onBlur:()=>le(!1),onInput:O,placeholder:Ie?Oe:i("input.placeholder",{provider:te==="codex"?i("messageTypes.codex"):te==="gemini"?i("messageTypes.gemini"):te==="opencode"?"OpenCode":i("messageTypes.claude")}),disabled:Fe,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"}})}),Ie&&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:ct||Oe}),Ne&&r.jsx("div",{className:"mt-1 font-mono text-[11px] opacity-90 break-all",children:Ne}),r.jsx("div",{className:"mt-2",children:r.jsx("button",{type:"button",onClick:()=>at(te,{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:Pe,children:i(Pe?"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:()=>{Fe||we()},disabled:Fe,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground sm:h-9 sm:w-9 sm:rounded-lg",title:i("input.attachImages"),children:[r.jsx(Kr,{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:ae,className:"relative min-w-0 max-w-full flex-[0_1_auto]",children:r.jsxs(ka,{value:d||void 0,onValueChange:wt,disabled:Fe||f||p,children:[r.jsx(ja,{className:"h-8 w-auto !min-w-0 max-w-full shrink justify-start gap-1 rounded-full border-0 bg-transparent px-1.5 text-xs font-normal text-muted-foreground shadow-none hover:bg-accent/60 hover:text-muted-foreground focus:ring-0 sm:h-8 sm:px-1.5 sm:text-xs",children:r.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[f&&r.jsx(un,{className:"h-3.5 w-3.5 flex-shrink-0 animate-spin text-muted-foreground"}),r.jsx("span",{className:"truncate max-w-[120px] sm:max-w-[240px] md:max-w-[300px] text-xs font-normal text-muted-foreground",children:f?i("input.loadingModels"):m}),r.jsx(vr,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(Sa,{children:f?r.jsx(Lo,{value:"__loading",disabled:!0,children:i("input.loadingModels")}):u.map(({value:Z,label:C})=>r.jsx(Lo,{value:Z,children:C},Z))})]})}),r.jsx("div",{className:"relative min-w-0 max-w-full flex-[0_1_auto]",ref:N,children:r.jsxs(ka,{value:g,onValueChange:Z=>{ke(Z),q&&localStorage.setItem(`permissionMode-${q.id}`,Z)},disabled:Fe,children:[r.jsx(ja,{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:S||L||i("input.clickToChangeMode")}),r.jsx(vr,{className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground sm:hidden"})]})}),r.jsx(Sa,{children:r.jsxs(ap,{children:[r.jsx(ip,{children:L}),k.modes.map(Z=>r.jsx(Lo,{value:Z,children:B(Z,{short:!0})},Z))]})})]})}),r.jsx(lp,{modes:h,value:w,onValueChange:v,disabled:Fe||!q?.id,label:"智能体模式"}),E.enabled&&r.jsx(cp,{selectedMode:y,onModeChange:I,className:"sm:flex-none"}),$!==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:nx($)})]}),r.jsx("div",{className:"w-px h-4 bg-gray-200 dark:bg-gray-700 mx-1 hidden sm:block"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative group hidden sm:block",children:[r.jsx("button",{type:"button",className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",title:i("input.commands"),children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),r.jsx("div",{className:"chat-floating-panel absolute bottom-full right-0 z-50 mb-2 hidden w-64 rounded-lg p-3 text-xs text-muted-foreground group-hover:block",children:r.jsx("p",{children:i(a?"input.hintText.ctrlEnter":"input.hintText.enter")})})]}),r.jsx("button",{type:"submit",disabled:!_.trim()||Fe,onMouseDown:Z=>{Z.preventDefault(),Nt(Z)},onTouchStart:Z=>{Z.preventDefault(),Nt(Z)},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 sx={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"},Ic={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"},ax={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"},ix={OPTIONS:[{value:"kimi-k2.5",label:"Kimi K2.5"}],DEFAULT:"kimi-k2.5"},lx=["claude","codex","gemini","opencode"],Un="unknown",cx="installed",Ho="not_installed",dx="checking",ux=["claude","codex","gemini","opencode"],px=300*1e3;function Ht(e){const t=String(e||"").trim().toLowerCase();return lx.includes(t)?t:"claude"}function mx(e){switch(e){case"codex":return Ic;case"gemini":return ax;case"opencode":return ix;default:return sx}}function jo(e){return`${Ht(e)}-model`}function ea(e){return`${jo(e)}-selection-source`}function Wn(e){const t=Ht(e),n=jo(t),o=ea(t);return localStorage.getItem(o)!=="manual"?"":localStorage.getItem(n)||""}function fx(e,t){const n=Ht(e);localStorage.setItem(jo(n),t),localStorage.setItem(ea(n),"manual")}function hx(e){const t=Ht(e);localStorage.removeItem(jo(t)),localStorage.removeItem(ea(t))}function _c(e){if(typeof e!="string")return!1;const t=e.trim().toLowerCase();return t.length>0&&t!=="custom"&&t!=="default"}const gx=new Set(Ic.OPTIONS.map(e=>String(e?.value||"").trim().toLowerCase()).filter(Boolean));function xx(e){if(!_c(e))return!1;const t=e.trim().toLowerCase();return gx.has(t)?!0:/^(gpt-\d|o[1345](?:$|[-.])|codex(?:$|[-.]))/i.test(t)}function yx(e,t){return Ht(e)==="codex"?xx(t):_c(t)}function Hn(e){return typeof e=="string"&&/^codex-\d+$/.test(e.trim())}const Ka=new WeakMap;let vx=0;function bx(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 o=(()=>{const i=e?.timestamp instanceof Date?e.timestamp.getTime():new Date(e?.timestamp||Date.now()).getTime();return Number.isNaN(i)?Date.now():i})(),s=String(e?.role||e?.type||"assistant"),a=String(e?.provider||e?.__provider||"");if(e&&typeof e=="object"){const i=Ka.get(e);if(i)return i;const c=`${s}:${a}:${o}:runtime-${vx++}`;return Ka.set(e,c),c}return`${s}:${a}:${o}:${t}`}const bt={setItem:(e,t)=>{try{if(e.startsWith("chat_messages_")&&typeof t=="string")try{const n=JSON.parse(t);if(Array.isArray(n)&&n.length>50){const o=n.slice(-50);t=JSON.stringify(o)}}catch(n){console.warn("Could not parse chat messages for truncation:",n)}localStorage.setItem(e,t)}catch(n){if(n.name==="QuotaExceededError"){const o=Object.keys(localStorage),s=o.filter(i=>i.startsWith("chat_messages_")).sort();s.length>3&&s.slice(0,s.length-3).forEach(i=>{localStorage.removeItem(i)}),o.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(e,t)}catch(i){if(e.startsWith("chat_messages_")&&typeof t=="string")try{const c=JSON.parse(t);Array.isArray(c)&&c.length>10&&localStorage.setItem(e,JSON.stringify(c.slice(-10)))}catch(c){console.error("Final save attempt failed:",c)}else console.error("Failed to save to localStorage even after cleanup:",i)}}else console.error("localStorage error:",n)}},getItem:e=>{try{return localStorage.getItem(e)}catch(t){return console.error("localStorage getItem error:",t),null}},removeItem:e=>{try{localStorage.removeItem(e)}catch(t){console.error("localStorage removeItem error:",t)}}};function Tc(e){return e?`chat_messages_${e}`:""}function Mc(e,t=null){return e?t?`chat_messages_${e}__session_${t}`:Tc(e):""}function wx(e,t=null){const n=Mc(e,t);if(!n)return[];const o=bt.getItem(n);if(!o)return[];try{return Qs(JSON.parse(o))}catch(s){return console.warn("Failed to parse cached chat messages:",s),[]}}function Dc(e,t=null,n=[]){const o=Mc(e,t);if(!o)return;const s=Qs(n);if(s.length===0){bt.removeItem(o);return}bt.setItem(o,JSON.stringify(s)),t&&bt.removeItem(Tc(e))}const Pc="claude-settings";function kx(){const e=bt.getItem(Pc);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 jx(e){if(!e)return{success:!1};const t=kx(),n=t.allowedTools.includes(e),o=n?t.allowedTools:[...t.allowedTools,e],s=t.disallowedTools.filter(i=>i!==e),a={...t,allowedTools:o,disallowedTools:s,lastUpdated:new Date().toISOString()};return bt.setItem(Pc,JSON.stringify(a)),{success:!0,alreadyAllowed:n,updatedSettings:a}}const Sx=100;function Ga(e){const t=e?.extensions?.clientRequestId||e?.payload?.clientRequestId||null;return typeof t=="string"&&t.trim()?t.trim():null}function Nx(e,t){if(!e||!t)return!1;const n=Ga(e),o=Ga(t);return n&&o&&n===o?e.kind===t.kind&&e.provider===t.provider&&e.sessionId===t.sessionId:e.eventId&&t.eventId&&e.eventId===t.eventId?!0:e.kind===t.kind&&e.provider===t.provider&&e.sessionId===t.sessionId&&e.timestamp===t.timestamp&&JSON.stringify(e.payload||{})===JSON.stringify(t.payload||{})}function Cx({selectedProject:e,selectedProjectRef:t,selectedSession:n,currentSessionId:o,setCurrentSessionId:s,provider:a,runtimePhase:i,isLoading:c,isLoadingRef:d,processingSessions:u,autoScrollToBottom:m,externalMessageUpdate:p,ws:f,sendMessage:g,chatMessages:h,setChatMessages:w,setIsLoading:v,setCanAbortSession:S,setRuntimePhase:L,setClaudeStatus:k,setPendingPermissionRequests:B,resetStreamingState:E,clearLocalRunGuard:y,localRunGuardRef:I,pendingViewSessionRef:$,isSystemSessionChange:_,setIsSystemSessionChange:H,onSessionInactive:le,onSessionNotProcessing:se,onSessionProcessing:W}){const[Q,ce]=l.useState([]),[he,be]=l.useState(!1),[pe,K]=l.useState(!1),[De,P]=l.useState(0),[j,T]=l.useState(!1),[ne,ge]=l.useState(0),[Se,A]=l.useState(null),[ee,Ae]=l.useState(!1),[ye,st]=l.useState(100),Ke=l.useRef(null),we=l.useRef(null),Le=l.useRef(!1),ze=l.useRef(!1),rt=l.useRef(0),Xe=l.useRef(!1),Ve=l.useRef(null),fe=l.useRef({height:0,top:0}),Re=l.useRef(new Map),et=l.useRef(p),Ye=e?.fullPath||e?.path||null;l.useEffect(()=>()=>{Re.current.forEach(q=>clearTimeout(q)),Re.current.clear()},[]);const Qe=l.useCallback(async(q,de,ae=!1,N="claude",ie=null)=>{if(!q||!de)return[];const Me=!ae;Me?be(!0):K(!0);try{const Z=ie??(ae?rt.current:0),C=await xt.sessionEvents(N,de,q,Ye,Sx,Z);if(!C.ok)throw new Error("Failed to load session messages");const D=await C.json();if(Me&&D.tokenUsage&&A(D.tokenUsage),D.hasMore!==void 0){T(D.hasMore),ge(D.total);const _e=Z+(D.events?.length||0);return rt.current=_e,P(_e),D.events||[]}const Ce=D.events||D.messages||[];return T(!1),ge(Ce.length),rt.current=Ce.length,P(Ce.length),Ce}catch(Z){return console.error("Error loading session messages:",Z),[]}finally{Me?be(!1):K(!1)}},[Ye]),ot=l.useCallback((q,de="claude")=>Cc(q,de).map(ae=>({...ae,provider:ae.provider||de})),[]),J=n?.__provider||a||"claude",oe=l.useMemo(()=>ot(Q,J),[J,ot,Q]),x=l.useCallback((q=[])=>{let de=null;for(const ae of q)if(!(!ae||typeof ae!="object")){if(ae.kind==="error"){de=ve.ERRORED;continue}if(ae.kind==="session_state_changed"){const N=String(ae.payload?.state||"").trim().toLowerCase();Object.values(ve).includes(N)&&(de=N);continue}if(ae.kind==="approval_request"){de=ve.AWAITING_APPROVAL;continue}if(ae.kind==="approval_resolved"){de=ve.STREAMING;continue}(ae.kind==="assistant_text_start"||ae.kind==="assistant_text_delta"||ae.kind==="assistant_content_block"||ae.kind==="reasoning_start"||ae.kind==="reasoning_delta"||ae.kind==="tool_call_start"||ae.kind==="tool_call_input"||ae.kind==="tool_call_end"||ae.kind==="tool_result"||ae.kind==="plan_update"||ae.kind==="system_notice")&&(de=ve.STREAMING)}return de},[]),M=l.useCallback((q=[])=>{const de=x(q);return de===ve.COMPLETED||de===ve.ABORTED||de===ve.ERRORED?de:null},[x]),G=l.useCallback(q=>!(q===ve.COMPLETED||q===ve.ABORTED||q===ve.ERRORED),[]),O=l.useCallback((q,de)=>de&&(L(de),(de===ve.COMPLETED||de===ve.ABORTED||de===ve.ERRORED)&&(y(q),k(null),q&&(le?.(q),se?.(q))),de),[y,le,se,k,L]),te=l.useCallback(async(q,de)=>{const ae=t.current;if(!ae?.name||!q)return null;const N=await Qe(ae.name,q,!1,de||J);return Array.isArray(N)&&N.length>0&&ce(N),x(N)},[J,x,Qe,t]),Ie=l.useCallback(async(q,de)=>{const ae=await te(q,de);return O(q,ae)},[te,O]),Oe=l.useCallback((q,de=[])=>{const ae=x(de);return O(q,ae),ae},[x,O]),Fe=l.useCallback((q,de)=>de===ve.COMPLETED||de===ve.ABORTED||de===ve.ERRORED?(O(q,de),de):null,[O]),ct=l.useCallback((q,de)=>{if(!q)return;const ae=Re.current.get(q);ae&&clearTimeout(ae);const N=setTimeout(()=>{Re.current.delete(q);const ie=n?.id||o||null;!ie||ie!==q||(Ie(q,de),g&&g({type:"check-session-status",sessionId:q,provider:de||J}))},1200);Re.current.set(q,N)},[J,o,Ie,n?.id,g]),Ne=l.useCallback(()=>{we.current&&(we.current.scrollTop=we.current.scrollHeight)},[]),Pe=l.useCallback(()=>{if(!we.current)return!1;const{scrollTop:q,scrollHeight:de,clientHeight:ae}=we.current;return de-q-ae<50},[]),at=l.useCallback(async(q=null)=>{const de=q||we.current;if(!de||ze.current||pe||!j||!n||!e)return!1;const ae=n.__provider||a||"claude";ze.current=!0;const N=de.scrollHeight,ie=de.scrollTop,Me=rt.current;try{const Z=await Qe(e.name,n.id,!0,ae,Me);return Z.length>0&&(Ve.current={height:N,top:ie},ce(C=>[...Z,...C])),!0}finally{ze.current=!1}},[j,pe,Qe,a,e,n]),yt=l.useCallback(async()=>{if(we.current){const q=we.current,de=Pe();Ae(!de),q.scrollTop<100?Xe.current||await at(q)&&(Xe.current=!0):Xe.current=!1}},[Pe,at]);l.useLayoutEffect(()=>{if(!Ve.current||!we.current)return;const{height:q,top:de}=Ve.current,ae=we.current,ie=ae.scrollHeight-q;ae.scrollTop=de+Math.max(ie,0),Ve.current=null},[h.length]),l.useEffect(()=>{let q=!1,de=null;return(async()=>{if(n&&e){const N=n.__provider||Ht(localStorage.getItem("selected-provider"));Le.current=!0,sessionStorage.removeItem("pendingSessionId");const ie=o!==null&&o!==n.id;let Me=null;if(ie?(_||(E(),y(),$.current=null,w([]),ce([]),k(null),S(!1)),rt.current=0,P(0),T(!1),ge(0),A(null),v(!1)):o===null&&(rt.current=0,P(0),T(!1),ge(0)),s(n.id),_)q||H(!1);else{const Z=await Qe(e.name,n.id,!1,n.__provider||N||"claude");if(q)return;ce(Z),Me=Oe(n.id,Z),Me||L(ve.IDLE),f&&g&&G(Me)&&g({type:"check-session-status",sessionId:n.id,provider:N})}}else{const ie=$.current?.sessionId||null||d.current&&(o||I.current.sessionId)||null,Me=!!(ie||d.current);_||Me||(E(),y(),$.current=null,w([]),ce([]),k(null),S(!1),v(!1)),s(ie),rt.current=0,P(0),T(!1),ge(0),A(null)}de=setTimeout(()=>{q||(Le.current=!1)},250)})(),()=>{q=!0,de&&clearTimeout(de)}},[n?.id,n?.__provider,e?.name,e?.fullPath,e?.path,Qe,_,E,y,Oe,g,L,G,f]),l.useEffect(()=>{const q=et.current;if(p<=q||(et.current=p,!n||!e))return;(async()=>{try{const ae=n.__provider||Ht(localStorage.getItem("selected-provider")),N=await Qe(e.name,n.id,!1,n.__provider||ae||"claude");ce(N),m&&Pe()&&setTimeout(()=>Ne(),200)}catch(ae){console.error("Error reloading messages from external update:",ae)}})()},[m,p,Pe,Qe,Ne,e,n]),l.useEffect(()=>{et.current=p},[p,e?.name,n?.id]),l.useEffect(()=>{n?.id&&($.current=null)},[$,n?.id]),l.useEffect(()=>{const q=n?.id||o||null,de=I.current,ae=!!(de.startedAt&&(!de.sessionId||!q||de.sessionId===q)&&i!==ve.IDLE);w(N=>jg(N,oe,{preserveLocalTail:ae}))},[oe,o,I,i,n?.id,w]),l.useEffect(()=>{e?.name&&Dc(e.name,n?.id||null,h)},[h,e?.name,n?.id]),l.useEffect(()=>{const q=Qs(h);Mg(h,q)||w(q)},[h,w]),l.useEffect(()=>{o&&c&&W&&W(o)},[o,c,W]),l.useEffect(()=>{if(o&&u){const q=u.has(o),de=M(Q);if(q&&de){se?.(o);return}q&&!c&&i!==ve.COMPLETED&&i!==ve.ABORTED&&i!==ve.ERRORED&&L(ve.STREAMING,{canAbortSession:!0})}},[o,M,c,se,u,i,Q,L]);const Nt=l.useMemo(()=>n||h.length<=ye?h:h.slice(-ye),[h,n,ye]),dt=l.useMemo(()=>{const q=Nt.map((ae,N)=>({...ae,__threadMessageId:bx(ae,N)}));return q.length===0||!c||q.some(ae=>ae?.type==="assistant"&&!!(ae.isStreaming||ae.isToolUse||ae.isThinking||ae.reasoning))?q:[...q,{id:"__assistant-loading-indicator__",type:"assistant",content:"",timestamp:new Date,isLoadingIndicator:!0,__provider:n?.__provider||a||"claude"}]},[c,a,n?.__provider,Nt]);l.useEffect(()=>{if(!m&&we.current){const q=we.current;fe.current={height:q.scrollHeight,top:q.scrollTop}}}),l.useEffect(()=>{if(we.current&&h.length>0)if(m)ee||setTimeout(()=>Ne(),50);else{const q=we.current,de=fe.current.height,ae=fe.current.top,ie=q.scrollHeight-de;ie>0&&ae>0&&(q.scrollTop=ae+ie)}},[m,h.length,ee,Ne]),l.useEffect(()=>{we.current&&h.length>0&&!Le.current&&(Ae(!1),setTimeout(()=>{Ne()},200))},[h.length,Ne,e?.name,n?.id]),l.useEffect(()=>{const q=we.current;if(q)return q.addEventListener("scroll",yt),()=>q.removeEventListener("scroll",yt)},[yt]),l.useEffect(()=>{if(!e||!n?.id||n.id.startsWith("new-session-")){A(null);return}if((n.__provider||a||"claude")!=="claude")return;(async()=>{try{const ae=`/api/projects/${e.name}/sessions/${n.id}/token-usage`,N=await xe(ae);if(N.ok){const ie=await N.json();A(ie)}else A(null)}catch(ae){console.error("Failed to fetch initial token usage:",ae)}})()},[a,e,n?.__provider,n?.id]);const pt=l.useCallback(()=>{st(q=>q+100)},[]),wt=l.useCallback(q=>{!q||typeof q!="object"||ce(de=>{const ae=Array.isArray(de)?de:[];return ae.some(N=>Nx(N,q))?ae:[...ae,q]})},[]),ke=l.useCallback(()=>{$.current=null,sessionStorage.removeItem("pendingSessionId"),s(null),ce([]),w([]),B([]),H(!1),L(ve.IDLE),k(null),S(!1),A(null),Ae(!1),e?.name&&(bt.removeItem(`chat_messages_${e.name}`),bt.removeItem(`draft_input_${e.name}`))},[$,e?.name,S,w,k,s,H,B,L]);return{sessionMessages:Q,setSessionMessages:ce,isLoadingSessionMessages:he,isLoadingMoreMessages:pe,messagesOffset:De,hasMoreMessages:j,totalMessages:ne,tokenBudget:Se,setTokenBudget:A,scrollContainerRef:we,messagesEndRef:Ke,isUserScrolledUp:ee,setIsUserScrolledUp:Ae,visibleMessageCount:ye,threadMessages:dt,scrollToBottom:Ne,handleScroll:yt,loadOlderMessages:at,loadEarlierMessages:pt,loadSessionMessages:Qe,appendSessionConversationEvent:wt,inferRuntimePhaseFromSessionEvents:x,inferTerminalPhaseFromSessionEvents:M,recoverAndSettleSessionRuntime:Ie,recoverTerminalSessionPhase:Fe,scheduleSessionStatusRecovery:ct,resetSessionHistoryForNewChat:ke}}function Va(e,t={}){const n=Array.isArray(t?.availableModes)?t.availableModes.filter(s=>s&&typeof s=="object"&&String(s.id||"").trim()).map(s=>({id:String(s.id).trim(),name:String(s.name||s.id||"").trim()||String(s.id).trim(),description:typeof s.description=="string"?s.description:""})):[],o=typeof t?.currentModeId=="string"&&t.currentModeId.trim()?t.currentModeId.trim():null;return!o&&n.length===0?e||null:{availableModes:n.length>0?n:Array.isArray(e?.availableModes)?e.availableModes:[],currentModeId:o||e?.currentModeId||null}}function Ex(e={}){return Array.isArray(e?.availableCommands)?e.availableCommands.filter(t=>t&&typeof t=="object"&&String(t.name||"").trim()).map(t=>({name:String(t.name).trim(),description:typeof t.description=="string"?t.description:"",input:t.input&&typeof t.input=="object"?t.input:null,type:"acp",source:"acp",namespace:"acp"})):[]}function Ax({latestMessage:e,provider:t,claudeStatus:n,selectedProject:o,selectedSession:s,currentSessionId:a,setCurrentSessionId:i,isLoading:c,runtimePhase:d,sendMessage:u,persistCurrentChatCache:m,setRuntimePhase:p,setIsSystemSessionChange:f,setPendingPermissionRequests:g,setIsLoading:h,setCanAbortSession:w,setClaudeStatus:v,setChatMessages:S,setTokenBudget:L,setAcpSessionModeState:k,setAcpAvailableCommands:B,applyRealtimeConversationEvent:E,streamBufferRef:y,streamTimerRef:I,clearLocalRunGuard:$,syncLocalRunGuardSession:_,shouldIgnoreStaleIdleSignal:H,pendingViewSessionRef:le,appendSessionConversationEvent:se,recoverAndSettleSessionRuntime:W,recoverTerminalSessionPhase:Q,inferRuntimePhaseFromSessionEvents:ce,inferTerminalPhaseFromSessionEvents:he,scheduleSessionStatusRecovery:be,sessionMessages:pe,setSessionMessages:K,loadSessionMessages:De,onSessionInactive:P,onSessionNotProcessing:j,onSessionProcessing:T,onReplaceTemporarySession:ne,onNavigateToSession:ge,t:Se}){const A=l.useRef(null),ee=l.useRef(new Set),Ae=s?.__provider||t||"claude";l.useEffect(()=>()=>{I.current&&(clearTimeout(I.current),I.current=null),y.current=""},[y,I]),l.useEffect(()=>{A.current=n},[n]),l.useEffect(()=>{if(!e)return;const ye=e.data?.message||e.data,Ke=["projects_updated","session-created"].includes(e.type),we=new Set(["claude-complete","codex-complete","session-aborted","claude-error","codex-error"]),Le=e.type==="conversation-event"?String(e.event?.payload?.state||"").trim().toLowerCase():"",ze=e.type==="conversation-event"&&(e.event?.kind==="error"||e.event?.kind==="session_state_changed"&&["streaming","awaiting_approval","completed","aborted","errored"].includes(Le)),Xe=e.type==="claude-response"&&ye&&ye.type==="system"&&ye.subtype==="init"?ye?.session_id:null,Ve=sessionStorage.getItem("pendingSessionId");let fe=s?.id||a||le.current?.sessionId||null;const Re=Xe&&(!fe||Xe===fe),et=Ke||Re,Ye=!e.sessionId&&le.current&&!le.current.sessionId&&(/error/i.test(e.type||"")||e.type==="conversation-event"&&e.event?.kind==="error"),Qe=x=>{x&&(P?.(x),j?.(x))},ot=x=>{x&&T?.(x)};if(!et){if(!fe&&e.sessionId&&!Hn(e.sessionId)&&le.current&&!le.current.sessionId&&(fe=e.sessionId,le.current.sessionId=e.sessionId,i(e.sessionId)),!fe&&(e.sessionId&&(we.has(e.type)||ze)&&(Le==="streaming"||Le==="awaiting_approval"?ot(e.sessionId):Qe(e.sessionId)),!Ye)||!e.sessionId&&!Ye)return;if(!Ye&&e.sessionId!==fe){const x=Hn(fe),M=!!(e.sessionId&&Ve&&e.sessionId===Ve);if(x&&(M||!Hn(e.sessionId||"")))i(e.sessionId),le.current&&(le.current.sessionId=e.sessionId);else{e.sessionId&&(we.has(e.type)||ze)&&(Le==="streaming"||Le==="awaiting_approval"?ot(e.sessionId):Qe(e.sessionId)),console.log("Skipping message for different session:",e.sessionId,"current:",fe);return}}}const J=e?.event?.sessionId||e.sessionId||fe||null,oe=!!(J&&ee.current.has(J));if(e.type==="conversation-event"&&e.event){const x=e.event.sessionId||e.sessionId||fe||null,M=e.event.rawRef?.type||null,G=e.event.kind==="session_state_changed"?String(e.event.payload?.state||"").trim().toLowerCase():"";if(x&&ee.current.add(x),G==="idle"&&H(x,M)){be(x,e.event.provider||Ae);return}if(x&&(x===(s?.id||null)||x===(a||null)||x===(le.current?.sessionId||null))&&se(e.event),E(e.event,e.event.provider||Ae),e.event.kind==="mode_update"&&k(te=>Va(te,e.event.payload)),e.event.kind==="available_commands_update"&&B(Ex(e.event.payload)),e.event.kind==="approval_request"&&p(ve.AWAITING_APPROVAL),e.event.kind==="approval_resolved"&&p(ve.STREAMING),(e.event.kind==="assistant_text_start"||e.event.kind==="assistant_text_delta"||e.event.kind==="assistant_content_block"||e.event.kind==="reasoning_start"||e.event.kind==="reasoning_delta"||e.event.kind==="tool_call_start"||e.event.kind==="tool_call_input"||e.event.kind==="tool_call_end"||e.event.kind==="tool_result"||e.event.kind==="plan_update")&&p(ve.STREAMING),(e.event.kind==="error"||e.event.payload?.state==="errored")&&($(x),p(ve.ERRORED),v(null),x&&(Qe(x),W(x,e.event.provider||Ae))),e.event.kind==="session_state_changed"){const te=G;te==="streaming"?(p(ve.STREAMING),x&&T&&T(x)):te==="awaiting_approval"?(p(ve.AWAITING_APPROVAL),x&&T&&T(x)):te==="completed"?($(x),p(ve.COMPLETED),v(null),x&&(Qe(x),W(x,e.event.provider||Ae))):te==="aborted"?($(x),p(ve.ABORTED),v(null),x&&(Qe(x),W(x,e.event.provider||Ae))):te==="errored"&&($(x),p(ve.ERRORED),v(null),x&&(Qe(x),W(x,e.event.provider||Ae)))}return}switch(e.type){case"ws-connection-state":e.state==="connecting"&&(d===ve.QUEUED||c)?p(ve.CONNECTING,{canAbortSession:!1}):e.state==="connected"&&d===ve.CONNECTING&&p(ve.QUEUED);break;case"connection-error":p(ve.ERRORED),v(null),S(x=>[...x,{type:"error",content:e.error||"Unable to reach the chat server. Message was not sent.",timestamp:new Date}]);break;case"error":p(ve.ERRORED),w(!1),v(null),S(x=>[...x,{type:"error",content:e.error||"The chat server reported an unexpected error.",timestamp:new Date}]);break;case"session-created":if(e.sessionId){const x=Ht(e.provider||Ae||t||"claude"),M=le.current?.sessionId||a||null,G=Hn(e.sessionId);if(!(!a||x==="codex"&&e.sessionId!==a)||G)break;sessionStorage.setItem("pendingSessionId",e.sessionId);try{const te=localStorage.getItem("session-provider-map"),Ie=te?JSON.parse(te):{};Ie[e.sessionId]=x,localStorage.setItem("session-provider-map",JSON.stringify(Ie))}catch{}m(e.sessionId),e.modes&&k(te=>Va(te,e.modes)),le.current&&(le.current.sessionId=e.sessionId),i(e.sessionId),_(e.sessionId),T?.(e.sessionId),f(!0),ne&&ne(e.sessionId,M),g(te=>te.map(Ie=>Ie.sessionId?Ie:{...Ie,sessionId:e.sessionId})),ge&&ge(e.sessionId),typeof window<"u"&&typeof window.refreshProjects=="function"&&window.refreshProjects()}break;case"token-budget":e.data&&L(e.data);break;case"claude-response":{const x=oe&&!(e.data?.type==="system"&&e.data?.subtype==="init");if(!x&&ye&&typeof ye=="object"&&ye.type){if(ye.type==="content_block_delta"&&ye.delta?.text){const M=Nr(ye.delta.text);y.current+=M,I.current||(I.current=setTimeout(()=>{const G=y.current;y.current="",I.current=null,G&&S(O=>{const te=[...O],Ie=te[te.length-1];return Ie&&Ie.type==="assistant"&&!Ie.isToolUse&&Ie.isStreaming?te[te.length-1]={...Ie,content:(Ie.content||"")+G}:te.push({type:"assistant",content:G,timestamp:new Date,isStreaming:!0}),te})},100));return}if(ye.type==="content_block_stop"){I.current&&(clearTimeout(I.current),I.current=null);const M=y.current;y.current="",M&&S(G=>{const O=[...G],te=O[O.length-1];return te&&te.type==="assistant"&&!te.isToolUse&&te.isStreaming?O[O.length-1]={...te,content:(te.content||"")+M}:O.push({type:"assistant",content:M,timestamp:new Date,isStreaming:!0}),O}),S(G=>{const O=[...G],te=O[O.length-1];return te&&te.type==="assistant"&&te.isStreaming&&(O[O.length-1]={...te,isStreaming:!1}),O});return}}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id!==a&&Re){f(!0),m(e.data.session_id),ge?.(e.data.session_id);return}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&!a&&Re){f(!0),m(e.data.session_id),ge?.(e.data.session_id);return}if(e.data.type==="system"&&e.data.subtype==="init"&&e.data.session_id&&a&&e.data.session_id===a&&Re)return;if(x)break;if(Array.isArray(ye.content)){for(const M of ye.content)if(M.type==="tool_use"){const G=M.input?JSON.stringify(M.input,null,2):"";S(O=>[...O,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:M.name,toolInput:G,toolId:M.id,toolResult:null}])}else if(M.type==="text"&&M.text?.trim()){let G=Nr(M.text);G=fs(G),S(O=>[...O,{type:"assistant",content:G,timestamp:new Date}])}}else if(typeof ye.content=="string"&&ye.content.trim()){let M=Nr(ye.content);M=fs(M),S(G=>[...G,{type:"assistant",content:M,timestamp:new Date}])}if(ye.role==="user"&&Array.isArray(ye.content))for(const M of ye.content)M.type==="tool_result"&&S(G=>G.map(O=>O.isToolUse&&O.toolId===M.tool_use_id?{...O,toolResult:{content:M.content,isError:M.is_error,timestamp:new Date}}:O));break}case"claude-output":if(oe)break;{const x=String(e.data||"");x.trim()&&(y.current+=y.current?`
|
|
19
|
+
${x}`:x,I.current||(I.current=setTimeout(()=>{const M=y.current;y.current="",I.current=null,M&&S(G=>{const O=[...G],te=O[O.length-1];return te&&te.type==="assistant"&&!te.isToolUse&&te.isStreaming?O[O.length-1]={...te,content:te.content?`${te.content}
|
|
20
|
+
${M}`:M}:O.push({type:"assistant",content:M,timestamp:new Date,isStreaming:!0}),O})},100)))}break;case"claude-interactive-prompt":S(x=>[...x,{type:"assistant",content:e.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":if(oe||t!=="claude"||!e.requestId)break;g(x=>x.some(M=>M.requestId===e.requestId)?x:[...x,{requestId:e.requestId,toolName:e.toolName||"UnknownTool",input:e.input,context:e.context,toolCall:e.toolCall||null,options:Array.isArray(e.options)?e.options:Array.isArray(e.context?.options)?e.context.options:[],message:e.message||null,sessionId:e.sessionId||null,receivedAt:new Date}]),h(!0),w(!0),v(Zs({phaseText:Se("activity.stage.waitingPermission"),detailText:e.toolName?Se("activity.requestTool",{tool:dp(e.toolName)}):Se("activity.permission.title"),canAbort:!0}));break;case"claude-permission-cancelled":if(oe||!e.requestId)break;g(x=>{const M=x.filter(G=>G.requestId!==e.requestId);return M.length===0&&v(null),M});break;case"claude-error":if(oe)break;$(e.sessionId||a||null),h(!1),w(!1),v(null),S(x=>[...x,{type:"error",content:`出错了:${e.error}`,timestamp:new Date}]);break;case"claude-complete":{if(oe)break;const x=e.sessionId||a||sessionStorage.getItem("pendingSessionId");$(x),(x===a||!a)&&(h(!1),w(!1),v(null)),x&&(P?.(x),j?.(x));const M=sessionStorage.getItem("pendingSessionId");M&&!a&&e.exitCode===0&&(i(M),sessionStorage.removeItem("pendingSessionId")),o&&e.exitCode===0&&bt.removeItem(`chat_messages_${o.name}`),g([]);break}case"codex-response":{const x=e.data;if(!x||oe)break;if(x.type==="item_delta"&&x.delta){const M=Nr(String(x.delta));if(M){const G=`codex:${x.itemType||"item"}:${x.itemId||"unknown"}`;S(O=>{const te=[...O];let Ie=-1;for(let Oe=te.length-1;Oe>=0;Oe-=1){const Fe=te[Oe];if(Fe?.codexItemKey===G&&Fe.type==="assistant"&&!Fe.isToolUse){Ie=Oe;break}}if(Ie===-1)te.push({type:"assistant",content:M,timestamp:new Date,isStreaming:!0,isThinking:!!x.isReasoning,codexItemKey:G});else{const Oe=te[Ie],Fe=Oe.content||"";Fe.endsWith(M)||(Oe.content=Fe+M),Oe.isStreaming=!0}return te})}break}if(x.type==="item_done"){const M=`codex:${x.itemType||"item"}:${x.itemId||"unknown"}`,G=typeof x.content=="string"?Nr(x.content):"";S(O=>{const te=[...O];let Ie=-1;for(let Oe=te.length-1;Oe>=0;Oe-=1){const Fe=te[Oe];if(Fe?.codexItemKey===M&&Fe.type==="assistant"&&!Fe.isToolUse){Ie=Oe;break}}if(Ie!==-1){const Oe=te[Ie];G&&G!==(Oe.content||"")&&(Oe.content=G),Oe.isStreaming=!1}else G.trim()&&te.push({type:"assistant",content:G,timestamp:new Date,isStreaming:!1,isThinking:!!x.isReasoning});return te});break}if(x.type==="item")switch(x.itemType){case"agent_message":if(x.message?.content?.trim()){const M=Nr(x.message.content);S(G=>{const O=G[G.length-1];return O&&O.type==="assistant"&&!O.isToolUse&&!O.isThinking&&(O.content||"").trim()===M.trim()?G:[...G,{type:"assistant",content:M,timestamp:new Date}]})}break;case"reasoning":if(x.message?.content?.trim()){const M=Nr(x.message.content);S(G=>{const O=G[G.length-1];return O&&O.type==="assistant"&&!O.isToolUse&&O.isThinking&&(O.content||"").trim()===M.trim()?G:[...G,{type:"assistant",content:M,timestamp:new Date,isThinking:!0}]})}break;case"command_execution":x.command&&S(M=>[...M,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:x.command,toolResult:x.output||null,exitCode:x.exitCode}]);break;case"file_change":if(x.changes?.length>0){const M=x.changes.map(G=>`${G.kind}: ${G.path}`).join(`
|
|
21
|
+
`);S(G=>[...G,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:M,toolResult:`Status: ${x.status}`}])}break;case"mcp_tool_call":S(M=>[...M,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${x.server}:${x.tool}`,toolInput:JSON.stringify(x.arguments,null,2),toolResult:x.result?JSON.stringify(x.result,null,2):x.error?.message||null}]);break;case"error":x.message?.content&&S(M=>[...M,{type:"error",content:x.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",x.itemType,x)}x.type==="turn_complete"&&h(!1),x.type==="turn_failed"&&(h(!1),S(M=>[...M,{type:"error",content:x.error?.message||"Turn failed",timestamp:new Date}]));break}case"codex-complete":{if(oe)break;const x=e.sessionId||a||sessionStorage.getItem("pendingSessionId");$(x),(x===a||!a)&&(h(!1),w(!1),v(null),S(O=>O.map(te=>te?.codexItemKey&&te.isStreaming?{...te,isStreaming:!1}:te))),x&&(P?.(x),j?.(x));const M=sessionStorage.getItem("pendingSessionId"),G=e.actualSessionId||M;M&&!a&&(i(G),f(!0),ge?.(G),sessionStorage.removeItem("pendingSessionId")),o&&x&&De(o.name,x,!1,"codex").then(O=>{Array.isArray(O)&&O.length>0&&K(O)}).catch(O=>{console.error("Error reloading Codex session after completion:",O)}),o&&bt.removeItem(`chat_messages_${o.name}`);break}case"codex-error":if(oe)break;$(e.sessionId||a||null),h(!1),w(!1),S(x=>x.map(M=>M?.codexItemKey&&M.isStreaming?{...M,isStreaming:!1}:M)),S(x=>[...x,{type:"error",content:e.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{if(oe)break;const x=e.sessionId||a;$(x),x===a&&(h(!1),w(!1),v(null)),x&&(P?.(x),j?.(x)),g([]),S(M=>[...M,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}]);break}case"session-status":{if(oe)break;const x=e.sessionId,M=e.provider||s?.__provider||Ae,G=x===a||s&&x===s.id,O=ce(pe),te=he(pe);if(G&&e.isProcessing){if(te){Q(x,te);break}h(!0),w(!0),T?.(x)}else if(G&&e.isProcessing===!1){if(H(x,"session-status")){be(x,M);break}W(x,M).then(Ie=>{if(!(Ie===ve.COMPLETED||Ie===ve.ABORTED||Ie===ve.ERRORED)){if(O===ve.STREAMING||O===ve.AWAITING_APPROVAL){p(O);return}h(!1),w(!1),v(null)}})}break}case"claude-status":{const x=e.data;if(x){let M={text:"Working...",tokens:0,can_interrupt:!0};x.message?M.text=x.message:x.status?M.text=x.status:typeof x=="string"&&(M.text=x),x.tokens?M.tokens=x.tokens:x.token_count&&(M.tokens=x.token_count),x.can_interrupt!==void 0&&(M.can_interrupt=x.can_interrupt);const G=Dg(x,Se,A.current);A.current=G,v(G),h(!0),w(M.can_interrupt)}break}}},[Ae,se,E,$,a,ce,he,c,e,De,ge,ne,P,j,T,le,m,t,W,Q,d,be,o,s,pe,B,k,w,S,v,i,h,f,g,K,L,H,_,Se])}function pr(e){return Array.isArray?Array.isArray(e):Oc(e)==="[object Array]"}function Ix(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function _x(e){return e==null?"":Ix(e)}function nr(e){return typeof e=="string"}function Rc(e){return typeof e=="number"}function Tx(e){return e===!0||e===!1||Mx(e)&&Oc(e)=="[object Boolean]"}function Lc(e){return typeof e=="object"}function Mx(e){return Lc(e)&&e!==null}function zt(e){return e!=null}function qo(e){return!e.trim().length}function Oc(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Dx="Incorrect 'index' type",Px=e=>`Invalid value for key ${e}`,Rx=e=>`Pattern length exceeds max of ${e}.`,Lx=e=>`Missing ${e} property in key`,Ox=e=>`Property 'weight' in key '${e}' must be a positive integer`,Ja=Object.prototype.hasOwnProperty;class Fx{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(o=>{let s=Fc(o);this._keys.push(s),this._keyMap[s.id]=s,n+=s.weight}),this._keys.forEach(o=>{o.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Fc(e){let t=null,n=null,o=null,s=1,a=null;if(nr(e)||pr(e))o=e,t=Ya(e),n=ys(e);else{if(!Ja.call(e,"name"))throw new Error(Lx("name"));const i=e.name;if(o=i,Ja.call(e,"weight")&&(s=e.weight,s<=0))throw new Error(Ox(i));t=Ya(i),n=ys(i),a=e.getFn}return{path:t,id:n,weight:s,src:o,getFn:a}}function Ya(e){return pr(e)?e:e.split(".")}function ys(e){return pr(e)?e.join("."):e}function $x(e,t){let n=[],o=!1;const s=(a,i,c)=>{if(zt(a))if(!i[c])n.push(a);else{let d=i[c];const u=a[d];if(!zt(u))return;if(c===i.length-1&&(nr(u)||Rc(u)||Tx(u)))n.push(_x(u));else if(pr(u)){o=!0;for(let m=0,p=u.length;m<p;m+=1)s(u[m],i,c+1)}else i.length&&s(u,i,c+1)}};return s(e,nr(t)?t.split("."):t,0),o?n:n[0]}const Bx={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},zx={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},Ux={location:0,threshold:.6,distance:100},Wx={useExtendedSearch:!1,getFn:$x,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Be={...zx,...Bx,...Ux,...Wx};const Hx=/[^ ]+/g;function qx(e=1,t=3){const n=new Map,o=Math.pow(10,t);return{get(s){const a=s.match(Hx).length;if(n.has(a))return n.get(a);const i=1/Math.pow(a,.5*e),c=parseFloat(Math.round(i*o)/o);return n.set(a,c),c},clear(){n.clear()}}}class ta{constructor({getFn:t=Be.getFn,fieldNormWeight:n=Be.fieldNormWeight}={}){this.norm=qx(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,o)=>{this._keysMap[n.id]=o})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,nr(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();nr(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,o=this.size();n<o;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!zt(t)||qo(t))return;let o={v:t,i:n,n:this.norm.get(t)};this.records.push(o)}_addObject(t,n){let o={i:n,$:{}};this.keys.forEach((s,a)=>{let i=s.getFn?s.getFn(t):this.getFn(t,s.path);if(zt(i)){if(pr(i)){let c=[];const d=[{nestedArrIndex:-1,value:i}];for(;d.length;){const{nestedArrIndex:u,value:m}=d.pop();if(zt(m))if(nr(m)&&!qo(m)){let p={v:m,i:u,n:this.norm.get(m)};c.push(p)}else pr(m)&&m.forEach((p,f)=>{d.push({nestedArrIndex:f,value:p})})}o.$[a]=c}else if(nr(i)&&!qo(i)){let c={v:i,n:this.norm.get(i)};o.$[a]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function $c(e,t,{getFn:n=Be.getFn,fieldNormWeight:o=Be.fieldNormWeight}={}){const s=new ta({getFn:n,fieldNormWeight:o});return s.setKeys(e.map(Fc)),s.setSources(t),s.create(),s}function Kx(e,{getFn:t=Be.getFn,fieldNormWeight:n=Be.fieldNormWeight}={}){const{keys:o,records:s}=e,a=new ta({getFn:t,fieldNormWeight:n});return a.setKeys(o),a.setIndexRecords(s),a}function qn(e,{errors:t=0,currentLocation:n=0,expectedLocation:o=0,distance:s=Be.distance,ignoreLocation:a=Be.ignoreLocation}={}){const i=t/e.length;if(a)return i;const c=Math.abs(o-n);return s?i+c/s:c?1:i}function Gx(e=[],t=Be.minMatchCharLength){let n=[],o=-1,s=-1,a=0;for(let i=e.length;a<i;a+=1){let c=e[a];c&&o===-1?o=a:!c&&o!==-1&&(s=a-1,s-o+1>=t&&n.push([o,s]),o=-1)}return e[a-1]&&a-o>=t&&n.push([o,a-1]),n}const Cr=32;function Vx(e,t,n,{location:o=Be.location,distance:s=Be.distance,threshold:a=Be.threshold,findAllMatches:i=Be.findAllMatches,minMatchCharLength:c=Be.minMatchCharLength,includeMatches:d=Be.includeMatches,ignoreLocation:u=Be.ignoreLocation}={}){if(t.length>Cr)throw new Error(Rx(Cr));const m=t.length,p=e.length,f=Math.max(0,Math.min(o,p));let g=a,h=f;const w=c>1||d,v=w?Array(p):[];let S;for(;(S=e.indexOf(t,h))>-1;){let I=qn(t,{currentLocation:S,expectedLocation:f,distance:s,ignoreLocation:u});if(g=Math.min(I,g),h=S+m,w){let $=0;for(;$<m;)v[S+$]=1,$+=1}}h=-1;let L=[],k=1,B=m+p;const E=1<<m-1;for(let I=0;I<m;I+=1){let $=0,_=B;for(;$<_;)qn(t,{errors:I,currentLocation:f+_,expectedLocation:f,distance:s,ignoreLocation:u})<=g?$=_:B=_,_=Math.floor((B-$)/2+$);B=_;let H=Math.max(1,f-_+1),le=i?p:Math.min(f+_,p)+m,se=Array(le+2);se[le+1]=(1<<I)-1;for(let Q=le;Q>=H;Q-=1){let ce=Q-1,he=n[e.charAt(ce)];if(w&&(v[ce]=+!!he),se[Q]=(se[Q+1]<<1|1)&he,I&&(se[Q]|=(L[Q+1]|L[Q])<<1|1|L[Q+1]),se[Q]&E&&(k=qn(t,{errors:I,currentLocation:ce,expectedLocation:f,distance:s,ignoreLocation:u}),k<=g)){if(g=k,h=ce,h<=f)break;H=Math.max(1,2*f-h)}}if(qn(t,{errors:I+1,currentLocation:f,expectedLocation:f,distance:s,ignoreLocation:u})>g)break;L=se}const y={isMatch:h>=0,score:Math.max(.001,k)};if(w){const I=Gx(v,c);I.length?d&&(y.indices=I):y.isMatch=!1}return y}function Jx(e){let t={};for(let n=0,o=e.length;n<o;n+=1){const s=e.charAt(n);t[s]=(t[s]||0)|1<<o-n-1}return t}const ro=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 Bc{constructor(t,{location:n=Be.location,threshold:o=Be.threshold,distance:s=Be.distance,includeMatches:a=Be.includeMatches,findAllMatches:i=Be.findAllMatches,minMatchCharLength:c=Be.minMatchCharLength,isCaseSensitive:d=Be.isCaseSensitive,ignoreDiacritics:u=Be.ignoreDiacritics,ignoreLocation:m=Be.ignoreLocation}={}){if(this.options={location:n,threshold:o,distance:s,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m},t=d?t:t.toLowerCase(),t=u?ro(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const p=(g,h)=>{this.chunks.push({pattern:g,alphabet:Jx(g),startIndex:h})},f=this.pattern.length;if(f>Cr){let g=0;const h=f%Cr,w=f-h;for(;g<w;)p(this.pattern.substr(g,Cr),g),g+=Cr;if(h){const v=f-Cr;p(this.pattern.substr(v),v)}}else p(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,ignoreDiacritics:o,includeMatches:s}=this.options;if(t=n?t:t.toLowerCase(),t=o?ro(t):t,this.pattern===t){let w={isMatch:!0,score:0};return s&&(w.indices=[[0,t.length-1]]),w}const{location:a,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:m}=this.options;let p=[],f=0,g=!1;this.chunks.forEach(({pattern:w,alphabet:v,startIndex:S})=>{const{isMatch:L,score:k,indices:B}=Vx(t,w,v,{location:a+S,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:s,ignoreLocation:m});L&&(g=!0),f+=k,L&&B&&(p=[...p,...B])});let h={isMatch:g,score:g?f/this.chunks.length:1};return g&&s&&(h.indices=p),h}}class br{constructor(t){this.pattern=t}static isMultiMatch(t){return Xa(t,this.multiRegex)}static isSingleMatch(t){return Xa(t,this.singleRegex)}search(){}}function Xa(e,t){const n=e.match(t);return n?n[1]:null}class Yx extends br{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 Xx extends br{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const o=t.indexOf(this.pattern)===-1;return{isMatch:o,score:o?0:1,indices:[0,t.length-1]}}}class Qx extends br{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 Zx extends br{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 e0 extends br{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 t0 extends br{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 zc extends br{constructor(t,{location:n=Be.location,threshold:o=Be.threshold,distance:s=Be.distance,includeMatches:a=Be.includeMatches,findAllMatches:i=Be.findAllMatches,minMatchCharLength:c=Be.minMatchCharLength,isCaseSensitive:d=Be.isCaseSensitive,ignoreDiacritics:u=Be.ignoreDiacritics,ignoreLocation:m=Be.ignoreLocation}={}){super(t),this._bitapSearch=new Bc(t,{location:n,threshold:o,distance:s,includeMatches:a,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Uc extends br{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,o;const s=[],a=this.pattern.length;for(;(o=t.indexOf(this.pattern,n))>-1;)n=o+a,s.push([o,n-1]);const i=!!s.length;return{isMatch:i,score:i?0:1,indices:s}}}const vs=[Yx,Uc,Qx,Zx,t0,e0,Xx,zc],Qa=vs.length,r0=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,n0="|";function o0(e,t={}){return e.split(n0).map(n=>{let o=n.trim().split(r0).filter(a=>a&&!!a.trim()),s=[];for(let a=0,i=o.length;a<i;a+=1){const c=o[a];let d=!1,u=-1;for(;!d&&++u<Qa;){const m=vs[u];let p=m.isMultiMatch(c);p&&(s.push(new m(p,t)),d=!0)}if(!d)for(u=-1;++u<Qa;){const m=vs[u];let p=m.isSingleMatch(c);if(p){s.push(new m(p,t));break}}}return s})}const s0=new Set([zc.type,Uc.type]);class a0{constructor(t,{isCaseSensitive:n=Be.isCaseSensitive,ignoreDiacritics:o=Be.ignoreDiacritics,includeMatches:s=Be.includeMatches,minMatchCharLength:a=Be.minMatchCharLength,ignoreLocation:i=Be.ignoreLocation,findAllMatches:c=Be.findAllMatches,location:d=Be.location,threshold:u=Be.threshold,distance:m=Be.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:o,includeMatches:s,minMatchCharLength:a,findAllMatches:c,ignoreLocation:i,location:d,threshold:u,distance:m},t=n?t:t.toLowerCase(),t=o?ro(t):t,this.pattern=t,this.query=o0(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:o,isCaseSensitive:s,ignoreDiacritics:a}=this.options;t=s?t:t.toLowerCase(),t=a?ro(t):t;let i=0,c=[],d=0;for(let u=0,m=n.length;u<m;u+=1){const p=n[u];c.length=0,i=0;for(let f=0,g=p.length;f<g;f+=1){const h=p[f],{isMatch:w,indices:v,score:S}=h.search(t);if(w){if(i+=1,d+=S,o){const L=h.constructor.type;s0.has(L)?c=[...c,...v]:c.push(v)}}else{d=0,i=0,c.length=0;break}}if(i){let f={isMatch:!0,score:d/i};return o&&(f.indices=c),f}}return{isMatch:!1,score:1}}}const bs=[];function i0(...e){bs.push(...e)}function ws(e,t){for(let n=0,o=bs.length;n<o;n+=1){let s=bs[n];if(s.condition(e,t))return new s(e,t)}return new Bc(e,t)}const no={AND:"$and",OR:"$or"},ks={PATH:"$path",PATTERN:"$val"},js=e=>!!(e[no.AND]||e[no.OR]),l0=e=>!!e[ks.PATH],c0=e=>!pr(e)&&Lc(e)&&!js(e),Za=e=>({[no.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Wc(e,t,{auto:n=!0}={}){const o=s=>{let a=Object.keys(s);const i=l0(s);if(!i&&a.length>1&&!js(s))return o(Za(s));if(c0(s)){const d=i?s[ks.PATH]:a[0],u=i?s[ks.PATTERN]:s[d];if(!nr(u))throw new Error(Px(d));const m={keyId:ys(d),pattern:u};return n&&(m.searcher=ws(u,t)),m}let c={children:[],operator:a[0]};return a.forEach(d=>{const u=s[d];pr(u)&&u.forEach(m=>{c.children.push(o(m))})}),c};return js(e)||(e=Za(e)),o(e)}function d0(e,{ignoreFieldNorm:t=Be.ignoreFieldNorm}){e.forEach(n=>{let o=1;n.matches.forEach(({key:s,norm:a,score:i})=>{const c=s?s.weight:null;o*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(t?1:a))}),n.score=o})}function u0(e,t){const n=e.matches;t.matches=[],zt(n)&&n.forEach(o=>{if(!zt(o.indices)||!o.indices.length)return;const{indices:s,value:a}=o;let i={indices:s,value:a};o.key&&(i.key=o.key.src),o.idx>-1&&(i.refIndex=o.idx),t.matches.push(i)})}function p0(e,t){t.score=e.score}function m0(e,t,{includeMatches:n=Be.includeMatches,includeScore:o=Be.includeScore}={}){const s=[];return n&&s.push(u0),o&&s.push(p0),e.map(a=>{const{idx:i}=a,c={item:t[i],refIndex:i};return s.length&&s.forEach(d=>{d(a,c)}),c})}class en{constructor(t,n={},o){this.options={...Be,...n},this.options.useExtendedSearch,this._keyStore=new Fx(this.options.keys),this.setCollection(t,o)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof ta))throw new Error(Dx);this._myIndex=n||$c(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){zt(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let o=0,s=this._docs.length;o<s;o+=1){const a=this._docs[o];t(a,o)&&(this.removeAt(o),o-=1,s-=1,n.push(a))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:o,includeScore:s,shouldSort:a,sortFn:i,ignoreFieldNorm:c}=this.options;let d=nr(t)?nr(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return d0(d,{ignoreFieldNorm:c}),a&&d.sort(i),Rc(n)&&n>-1&&(d=d.slice(0,n)),m0(d,this._docs,{includeMatches:o,includeScore:s})}_searchStringList(t){const n=ws(t,this.options),{records:o}=this._myIndex,s=[];return o.forEach(({v:a,i,n:c})=>{if(!zt(a))return;const{isMatch:d,score:u,indices:m}=n.searchIn(a);d&&s.push({item:a,idx:i,matches:[{score:u,value:a,norm:c,indices:m}]})}),s}_searchLogical(t){const n=Wc(t,this.options),o=(c,d,u)=>{if(!c.children){const{keyId:p,searcher:f}=c,g=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(d,p),searcher:f});return g&&g.length?[{idx:u,item:d,matches:g}]:[]}const m=[];for(let p=0,f=c.children.length;p<f;p+=1){const g=c.children[p],h=o(g,d,u);if(h.length)m.push(...h);else if(c.operator===no.AND)return[]}return m},s=this._myIndex.records,a={},i=[];return s.forEach(({$:c,i:d})=>{if(zt(c)){let u=o(n,c,d);u.length&&(a[d]||(a[d]={idx:d,item:c,matches:[]},i.push(a[d])),u.forEach(({matches:m})=>{a[d].matches.push(...m)}))}}),i}_searchObjectList(t){const n=ws(t,this.options),{keys:o,records:s}=this._myIndex,a=[];return s.forEach(({$:i,i:c})=>{if(!zt(i))return;let d=[];o.forEach((u,m)=>{d.push(...this._findMatches({key:u,value:i[m],searcher:n}))}),d.length&&a.push({idx:c,item:i,matches:d})}),a}_findMatches({key:t,value:n,searcher:o}){if(!zt(n))return[];let s=[];if(pr(n))n.forEach(({v:a,i,n:c})=>{if(!zt(a))return;const{isMatch:d,score:u,indices:m}=o.searchIn(a);d&&s.push({score:u,key:t,value:a,idx:i,norm:c,indices:m})});else{const{v:a,n:i}=n,{isMatch:c,score:d,indices:u}=o.searchIn(a);c&&s.push({score:d,key:t,value:a,norm:i,indices:u})}return s}}en.version="7.1.0";en.createIndex=$c;en.parseIndex=Kx;en.config=Be;en.parseQuery=Wc;i0(a0);var Ko={exports:{}},Go,ei;function f0(){if(ei)return Go;ei=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Go=e,Go}var Vo,ti;function h0(){if(ti)return Vo;ti=1;var e=f0();function t(){}function n(){}return n.resetWarningCache=t,Vo=function(){function o(i,c,d,u,m,p){if(p!==e){var f=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw f.name="Invariant Violation",f}}o.isRequired=o;function s(){return o}var a={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:s,element:o,elementType:o,instanceOf:s,node:o,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},Vo}var ri;function g0(){return ri||(ri=1,Ko.exports=h0()()),Ko.exports}var x0=g0();const ut=Yi(x0),y0=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 Yr(e,t,n){const o=v0(e),{webkitRelativePath:s}=e,a=typeof t=="string"?t:typeof s=="string"&&s.length>0?s:`./${e.name}`;return typeof o.path!="string"&&ni(o,"path",a),ni(o,"relativePath",a),o}function v0(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const o=t.split(".").pop().toLowerCase(),s=y0.get(o);s&&Object.defineProperty(e,"type",{value:s,writable:!1,configurable:!1,enumerable:!0})}return e}function ni(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const b0=[".DS_Store","Thumbs.db"];function w0(e){return Rr(this,void 0,void 0,function*(){return oo(e)&&k0(e.dataTransfer)?C0(e.dataTransfer,e.type):j0(e)?S0(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?N0(e):[]})}function k0(e){return oo(e)}function j0(e){return oo(e)&&oo(e.target)}function oo(e){return typeof e=="object"&&e!==null}function S0(e){return Ss(e.target.files).map(t=>Yr(t))}function N0(e){return Rr(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>Yr(n))})}function C0(e,t){return Rr(this,void 0,void 0,function*(){if(e.items){const n=Ss(e.items).filter(s=>s.kind==="file");if(t!=="drop")return n;const o=yield Promise.all(n.map(E0));return oi(Hc(o))}return oi(Ss(e.files).map(n=>Yr(n)))})}function oi(e){return e.filter(t=>b0.indexOf(t.name)===-1)}function Ss(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const o=e[n];t.push(o)}return t}function E0(e){if(typeof e.webkitGetAsEntry!="function")return si(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?qc(t):si(e,t)}function Hc(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?Hc(n):[n]],[])}function si(e,t){return Rr(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,Yr(i)}}const o=e.getAsFile();if(!o)throw new Error(`${e} is not a File`);return Yr(o,(n=t?.fullPath)!==null&&n!==void 0?n:void 0)})}function A0(e){return Rr(this,void 0,void 0,function*(){return e.isDirectory?qc(e):I0(e)})}function qc(e){const t=e.createReader();return new Promise((n,o)=>{const s=[];function a(){t.readEntries(i=>Rr(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(A0));s.push(c),a()}else try{const c=yield Promise.all(s);n(c)}catch(c){o(c)}}),i=>{o(i)})}a()})}function I0(e){return Rr(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(o=>{const s=Yr(o,e.fullPath);t(s)},o=>{n(o)})})})}var Kn={},ai;function _0(){return ai||(ai=1,Kn.__esModule=!0,Kn.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var o=e.name||"",s=(e.type||"").toLowerCase(),a=s.replace(/\/.*$/,"");return n.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?o.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):s===c})}return!0}),Kn}var T0=_0();const Jo=Yi(T0);function ii(e){return P0(e)||D0(e)||Gc(e)||M0()}function M0(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
22
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function D0(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function P0(e){if(Array.isArray(e))return Ns(e)}function li(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,o)}return n}function ci(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?li(Object(n),!0).forEach(function(o){Kc(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):li(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Kc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fn(e,t){return O0(e)||L0(e,t)||Gc(e,t)||R0()}function R0(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
23
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Gc(e,t){if(e){if(typeof e=="string")return Ns(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 Ns(e,t)}}function Ns(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function L0(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o=[],s=!0,a=!1,i,c;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(o.push(i.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,c=d}finally{try{!s&&n.return!=null&&n.return()}finally{if(a)throw c}}return o}}function O0(e){if(Array.isArray(e))return e}var F0=typeof Jo=="function"?Jo:Jo.default,$0="file-invalid-type",B0="file-too-large",z0="file-too-small",U0="too-many-files",W0=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=t.split(","),o=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:$0,message:"File type must be ".concat(o)}},di=function(t){return{code:B0,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},ui=function(t){return{code:z0,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},H0={code:U0,message:"Too many files"};function q0(e){return e.type===""&&typeof e.getAsFile=="function"}function Vc(e,t){var n=e.type==="application/x-moz-file"||F0(e,t)||q0(e);return[n,n?null:W0(t)]}function Jc(e,t,n){if(Er(e.size))if(Er(t)&&Er(n)){if(e.size>n)return[!1,di(n)];if(e.size<t)return[!1,ui(t)]}else{if(Er(t)&&e.size<t)return[!1,ui(t)];if(Er(n)&&e.size>n)return[!1,di(n)]}return[!0,null]}function Er(e){return e!=null}function K0(e){var t=e.files,n=e.accept,o=e.minSize,s=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=Vc(d,n),m=fn(u,1),p=m[0],f=Jc(d,o,s),g=fn(f,1),h=g[0],w=c?c(d):null;return p&&h&&!w})}function so(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function on(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 pi(e){e.preventDefault()}function G0(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function V0(e){return e.indexOf("Edge/")!==-1}function J0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return G0(e)||V0(e)}function er(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(o){for(var s=arguments.length,a=new Array(s>1?s-1:0),i=1;i<s;i++)a[i-1]=arguments[i];return t.some(function(c){return!so(o)&&c&&c.apply(void 0,[o].concat(a)),so(o)})}}function Y0(){return"showOpenFilePicker"in window}function X0(e){if(Er(e)){var t=Object.entries(e).filter(function(n){var o=fn(n,2),s=o[0],a=o[1],i=!0;return Yc(s)||(console.warn('Skipped "'.concat(s,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(a)||!a.every(Xc))&&(console.warn('Skipped "'.concat(s,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,o){var s=fn(o,2),a=s[0],i=s[1];return ci(ci({},n),{},Kc({},a,i))},{});return[{description:"Files",accept:t}]}return e}function Q0(e){if(Er(e))return Object.entries(e).reduce(function(t,n){var o=fn(n,2),s=o[0],a=o[1];return[].concat(ii(t),[s],ii(a))},[]).filter(function(t){return Yc(t)||Xc(t)}).join(",")}function Z0(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function ey(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function Yc(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||e==="application/*"||/\w+\/[-+.\w]+/g.test(e)}function Xc(e){return/^.*\.[\w]+$/.test(e)}var ty=["children"],ry=["open"],ny=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],oy=["refKey","onChange","onClick"];function mi(e){return iy(e)||ay(e)||Qc(e)||sy()}function sy(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
24
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ay(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function iy(e){if(Array.isArray(e))return Cs(e)}function Yo(e,t){return dy(e)||cy(e,t)||Qc(e,t)||ly()}function ly(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
25
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qc(e,t){if(e){if(typeof e=="string")return Cs(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 Cs(e,t)}}function Cs(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function cy(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var o=[],s=!0,a=!1,i,c;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(o.push(i.value),!(t&&o.length===t));s=!0);}catch(d){a=!0,c=d}finally{try{!s&&n.return!=null&&n.return()}finally{if(a)throw c}}return o}}function dy(e){if(Array.isArray(e))return e}function fi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,o)}return n}function gt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?fi(Object(n),!0).forEach(function(o){Es(e,o,n[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fi(Object(n)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(n,o))})}return e}function Es(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ao(e,t){if(e==null)return{};var n=uy(e,t),o,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)o=a[s],!(t.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}function uy(e,t){if(e==null)return{};var n={},o=Object.keys(e),s,a;for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var ra=l.forwardRef(function(e,t){var n=e.children,o=ao(e,ty),s=ed(o),a=s.open,i=ao(s,ry);return l.useImperativeHandle(t,function(){return{open:a}},[a]),gn.createElement(l.Fragment,null,n(gt(gt({},i),{},{open:a})))});ra.displayName="Dropzone";var Zc={disabled:!1,getFilesFromEvent:w0,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};ra.defaultProps=Zc;ra.propTypes={children:ut.func,accept:ut.objectOf(ut.arrayOf(ut.string)),multiple:ut.bool,preventDropOnDocument:ut.bool,noClick:ut.bool,noKeyboard:ut.bool,noDrag:ut.bool,noDragEventsBubbling:ut.bool,minSize:ut.number,maxSize:ut.number,maxFiles:ut.number,disabled:ut.bool,getFilesFromEvent:ut.func,onFileDialogCancel:ut.func,onFileDialogOpen:ut.func,useFsAccessApi:ut.bool,autoFocus:ut.bool,onDragEnter:ut.func,onDragLeave:ut.func,onDragOver:ut.func,onDrop:ut.func,onDropAccepted:ut.func,onDropRejected:ut.func,onError:ut.func,validator:ut.func};var As={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function ed(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=gt(gt({},Zc),e),n=t.accept,o=t.disabled,s=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,c=t.multiple,d=t.maxFiles,u=t.onDragEnter,m=t.onDragLeave,p=t.onDragOver,f=t.onDrop,g=t.onDropAccepted,h=t.onDropRejected,w=t.onFileDialogCancel,v=t.onFileDialogOpen,S=t.useFsAccessApi,L=t.autoFocus,k=t.preventDropOnDocument,B=t.noClick,E=t.noKeyboard,y=t.noDrag,I=t.noDragEventsBubbling,$=t.onError,_=t.validator,H=l.useMemo(function(){return Q0(n)},[n]),le=l.useMemo(function(){return X0(n)},[n]),se=l.useMemo(function(){return typeof v=="function"?v:hi},[v]),W=l.useMemo(function(){return typeof w=="function"?w:hi},[w]),Q=l.useRef(null),ce=l.useRef(null),he=l.useReducer(py,As),be=Yo(he,2),pe=be[0],K=be[1],De=pe.isFocused,P=pe.isFileDialogActive,j=l.useRef(typeof window<"u"&&window.isSecureContext&&S&&Y0()),T=function(){!j.current&&P&&setTimeout(function(){if(ce.current){var oe=ce.current.files;oe.length||(K({type:"closeDialog"}),W())}},300)};l.useEffect(function(){return window.addEventListener("focus",T,!1),function(){window.removeEventListener("focus",T,!1)}},[ce,P,W,j]);var ne=l.useRef([]),ge=l.useRef([]),Se=function(oe){Q.current&&Q.current.contains(oe.target)||(oe.preventDefault(),ne.current=[])};l.useEffect(function(){return k&&(document.addEventListener("dragover",pi,!1),document.addEventListener("drop",Se,!1)),function(){k&&(document.removeEventListener("dragover",pi),document.removeEventListener("drop",Se))}},[Q,k]),l.useEffect(function(){var J=function(O){ge.current=[].concat(mi(ge.current),[O.target]),on(O)&&K({isDragGlobal:!0,type:"setDragGlobal"})},oe=function(O){ge.current=ge.current.filter(function(te){return te!==O.target&&te!==null}),!(ge.current.length>0)&&K({isDragGlobal:!1,type:"setDragGlobal"})},x=function(){ge.current=[],K({isDragGlobal:!1,type:"setDragGlobal"})},M=function(){ge.current=[],K({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",J,!1),document.addEventListener("dragleave",oe,!1),document.addEventListener("dragend",x,!1),document.addEventListener("drop",M,!1),function(){document.removeEventListener("dragenter",J),document.removeEventListener("dragleave",oe),document.removeEventListener("dragend",x),document.removeEventListener("drop",M)}},[Q]),l.useEffect(function(){return!o&&L&&Q.current&&Q.current.focus(),function(){}},[Q,L,o]);var A=l.useCallback(function(J){$?$(J):console.error(J)},[$]),ee=l.useCallback(function(J){J.preventDefault(),J.persist(),et(J),ne.current=[].concat(mi(ne.current),[J.target]),on(J)&&Promise.resolve(s(J)).then(function(oe){if(!(so(J)&&!I)){var x=oe.length,M=x>0&&K0({files:oe,accept:H,minSize:i,maxSize:a,multiple:c,maxFiles:d,validator:_}),G=x>0&&!M;K({isDragAccept:M,isDragReject:G,isDragActive:!0,type:"setDraggedFiles"}),u&&u(J)}}).catch(function(oe){return A(oe)})},[s,u,A,I,H,i,a,c,d,_]),Ae=l.useCallback(function(J){J.preventDefault(),J.persist(),et(J);var oe=on(J);if(oe&&J.dataTransfer)try{J.dataTransfer.dropEffect="copy"}catch{}return oe&&p&&p(J),!1},[p,I]),ye=l.useCallback(function(J){J.preventDefault(),J.persist(),et(J);var oe=ne.current.filter(function(M){return Q.current&&Q.current.contains(M)}),x=oe.indexOf(J.target);x!==-1&&oe.splice(x,1),ne.current=oe,!(oe.length>0)&&(K({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),on(J)&&m&&m(J))},[Q,m,I]),st=l.useCallback(function(J,oe){var x=[],M=[];J.forEach(function(G){var O=Vc(G,H),te=Yo(O,2),Ie=te[0],Oe=te[1],Fe=Jc(G,i,a),ct=Yo(Fe,2),Ne=ct[0],Pe=ct[1],at=_?_(G):null;if(Ie&&Ne&&!at)x.push(G);else{var yt=[Oe,Pe];at&&(yt=yt.concat(at)),M.push({file:G,errors:yt.filter(function(Nt){return Nt})})}}),(!c&&x.length>1||c&&d>=1&&x.length>d)&&(x.forEach(function(G){M.push({file:G,errors:[H0]})}),x.splice(0)),K({acceptedFiles:x,fileRejections:M,isDragReject:M.length>0,type:"setFiles"}),f&&f(x,M,oe),M.length>0&&h&&h(M,oe),x.length>0&&g&&g(x,oe)},[K,c,H,i,a,d,f,g,h,_]),Ke=l.useCallback(function(J){J.preventDefault(),J.persist(),et(J),ne.current=[],on(J)&&Promise.resolve(s(J)).then(function(oe){so(J)&&!I||st(oe,J)}).catch(function(oe){return A(oe)}),K({type:"reset"})},[s,st,A,I]),we=l.useCallback(function(){if(j.current){K({type:"openDialog"}),se();var J={multiple:c,types:le};window.showOpenFilePicker(J).then(function(oe){return s(oe)}).then(function(oe){st(oe,null),K({type:"closeDialog"})}).catch(function(oe){Z0(oe)?(W(oe),K({type:"closeDialog"})):ey(oe)?(j.current=!1,ce.current?(ce.current.value=null,ce.current.click()):A(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."))):A(oe)});return}ce.current&&(K({type:"openDialog"}),se(),ce.current.value=null,ce.current.click())},[K,se,W,S,st,A,le,c]),Le=l.useCallback(function(J){!Q.current||!Q.current.isEqualNode(J.target)||(J.key===" "||J.key==="Enter"||J.keyCode===32||J.keyCode===13)&&(J.preventDefault(),we())},[Q,we]),ze=l.useCallback(function(){K({type:"focus"})},[]),rt=l.useCallback(function(){K({type:"blur"})},[]),Xe=l.useCallback(function(){B||(J0()?setTimeout(we,0):we())},[B,we]),Ve=function(oe){return o?null:oe},fe=function(oe){return E?null:Ve(oe)},Re=function(oe){return y?null:Ve(oe)},et=function(oe){I&&oe.stopPropagation()},Ye=l.useMemo(function(){return function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},oe=J.refKey,x=oe===void 0?"ref":oe,M=J.role,G=J.onKeyDown,O=J.onFocus,te=J.onBlur,Ie=J.onClick,Oe=J.onDragEnter,Fe=J.onDragOver,ct=J.onDragLeave,Ne=J.onDrop,Pe=ao(J,ny);return gt(gt(Es({onKeyDown:fe(er(G,Le)),onFocus:fe(er(O,ze)),onBlur:fe(er(te,rt)),onClick:Ve(er(Ie,Xe)),onDragEnter:Re(er(Oe,ee)),onDragOver:Re(er(Fe,Ae)),onDragLeave:Re(er(ct,ye)),onDrop:Re(er(Ne,Ke)),role:typeof M=="string"&&M!==""?M:"presentation"},x,Q),!o&&!E?{tabIndex:0}:{}),Pe)}},[Q,Le,ze,rt,Xe,ee,Ae,ye,Ke,E,y,o]),Qe=l.useCallback(function(J){J.stopPropagation()},[]),ot=l.useMemo(function(){return function(){var J=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},oe=J.refKey,x=oe===void 0?"ref":oe,M=J.onChange,G=J.onClick,O=ao(J,oy),te=Es({accept:H,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:Ve(er(M,Ke)),onClick:Ve(er(G,Qe)),tabIndex:-1},x,ce);return gt(gt({},te),O)}},[ce,n,c,Ke,o]);return gt(gt({},pe),{},{isFocused:De&&!o,getRootProps:Ye,getInputProps:ot,rootRef:Q,inputRef:ce,open:Ve(we)})}function py(e,t){switch(t.type){case"focus":return gt(gt({},e),{},{isFocused:!0});case"blur":return gt(gt({},e),{},{isFocused:!1});case"openDialog":return gt(gt({},As),{},{isFileDialogActive:!0});case"closeDialog":return gt(gt({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return gt(gt({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return gt(gt({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"setDragGlobal":return gt(gt({},e),{},{isDragGlobal:t.isDragGlobal});case"reset":return gt({},As);default:return e}}function hi(){}const gi={claude:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions","plan"]},codex:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions"]},gemini:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions"]},opencode:{defaultMode:"bypassPermissions",modes:["default","acceptEdits","bypassPermissions","plan"]}},xi={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 yi(e){return gi[e]||gi.claude}function vi(e){return xi[e]||xi.claude}function my(e){return e==="claude"||e==="codex"}function fy(e){if(e==="think")return"low";if(e==="think-hard")return"medium";if(e==="think-harder")return"high";if(e==="ultrathink")return"xhigh"}let bi=!1;function hy(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function gy(e){return new Promise((t,n)=>{if(!(e instanceof Blob)){n(new Error("无效的图片文件"));return}const o=new FileReader;o.onload=()=>t(typeof o.result=="string"?o.result:""),o.onerror=()=>n(o.error||new Error("读取图片失败")),o.readAsDataURL(e)})}async function xy(e=[]){const t=Array.isArray(e)?e:[];return Promise.all(t.map(async(n,o)=>{const s=await gy(n);if(!s)throw new Error("图片编码失败");return{name:n?.name||`image-${o+1}.png`,data:s,size:Number(n?.size)||0,mimeType:n?.type||"application/octet-stream"}}))}function yy(e){const t=String(e||"").trim();if(!t)return"";const n=t.split(/[\\/]/);return n[n.length-1]||t}function vy(e=[]){return Array.from(new Set(Array.isArray(e)?e.filter(Boolean):[])).map(t=>{const n=String(t||"").trim();return n?{type:"resource_link",uri:n,name:yy(n)}:null}).filter(Boolean)}function by(e,t=0){if(!e||typeof e!="object")return null;const n=String(e.modeId||e.id||e.value||"").trim();if(!n)return null;const o=`Mode ${t+1}`;return{id:n,name:String(e.name||e.label||n||o).trim()||o,description:typeof e.description=="string"?e.description:""}}function Xo(e=null){const t=e?.acpModes?.availableModes||e?.modes?.availableModes||e?.availableModes||[],n=Array.isArray(t)?t.map((s,a)=>by(s,a)).filter(Boolean):[],o=String(e?.acpModes?.currentModeId||e?.acpModes?.currentMode?.modeId||e?.modes?.currentModeId||e?.modes?.currentMode?.modeId||e?.currentModeId||e?.currentMode?.modeId||"").trim();return{availableModes:n,currentModeId:o}}function wi(e){return String(e||"").trim().replace(/^\//,"").toLowerCase()}function wy(e,t=0){if(!e||typeof e!="object")return null;const n=String(e.name||e.command||e.id||"").trim();if(!n)return null;const o=n.startsWith("/")?n:`/${n}`;return{...e,id:String(e.id||o||`acp-${t}`).trim(),name:o,description:typeof e.description=="string"?e.description:"",type:"acp",source:"acp"}}function ky(e=null){const t=e?.acpAvailableCommands||e?.availableCommands||e?.acpCommands||[];return Array.isArray(t)?t.map((n,o)=>wy(n,o)).filter(Boolean):[]}function jy(e=[],t=[]){const n=Array.isArray(t)?t:[],o=Array.isArray(e)?e:[],s=new Set(n.map(i=>wi(i?.name)).filter(Boolean)),a=o.filter(i=>!s.has(wi(i?.name)));return[...n,...a]}function Sy({selectedProject:e,selectedSession:t,selectedProjectRef:n,currentSessionId:o,canAbortSession:s,isLoading:a,setChatMessages:i,setCanAbortSession:c,setRuntimePhase:d,setClaudeStatus:u,pendingPermissionRequests:m,setPendingPermissionRequests:p,sendMessage:f,onSessionActive:g,onInputFocusChange:h,onShowSettings:w,onFileOpen:v,appendSessionConversationEvent:S,startLocalRunGuard:L,pendingViewSessionRef:k,scrollToBottom:B,setIsUserScrolledUp:E,tokenBudget:y,chatMessages:I,setSessionMessages:$,resetRuntimeForNewChat:_,urlContext:H,urlPrompt:le,integrationClientId:se,latestIntegrationMessage:W,sendIntegrationMessage:Q,sendByCtrlEnter:ce}){const{t:he}=kt("chat"),[be,pe]=l.useState(()=>typeof window<"u"&&e?.name&&bt.getItem(`draft_input_${e.name}`)||""),[K,De]=l.useState(!1),[P,j]=l.useState([]),[T,ne]=l.useState(new Map),[ge,Se]=l.useState(new Map),[A,ee]=l.useState(!1),[Ae,ye]=l.useState([]),[st,Ke]=l.useState([]),[we,Le]=l.useState([]),[ze,rt]=l.useState(-1),[Xe,Ve]=l.useState(0),[fe,Re]=l.useState(-1),[et,Ye]=l.useState(!1),[Qe,ot]=l.useState([]),[J,oe]=l.useState([]),[x,M]=l.useState([]),[G,O]=l.useState(""),[te,Ie]=l.useState(!1),[Oe,Fe]=l.useState(-1),[ct,Ne]=l.useState(-1),[Pe,at]=l.useState(()=>{const b=Ht(localStorage.getItem("selected-provider"));return yi(b).defaultMode}),yt=l.useMemo(()=>Xo(t),[t]),[Nt,dt]=l.useState(()=>yt.currentModeId),[pt,wt]=l.useState("none"),[ke,q]=l.useState(()=>Ht(localStorage.getItem("selected-provider"))),[de,ae]=l.useState(()=>Wn("claude")),[N,ie]=l.useState(()=>Wn("codex")),[Me,Z]=l.useState(()=>Wn("gemini")),[C,D]=l.useState(()=>Wn("opencode")),[Ce,_e]=l.useState({}),[vt,V]=l.useState({}),[At,U]=l.useState({}),[Y,je]=l.useState({}),[Ze,ft]=l.useState({}),[z,me]=l.useState({}),ue=l.useMemo(()=>qa(H),[H]),[re,Ee]=l.useState(ue),[Ue,tt]=l.useState(ue),[jt,mt]=l.useState(!1),We=l.useRef(null),nt=l.useRef(null),Ct=l.useRef(null),Mt=l.useRef(null),wr=l.useRef(null),Ft=l.useRef(null),Dt=l.useRef(ue),kr=l.useRef(!1),ar=l.useRef(null),la=l.useRef(ke),ir=l.useMemo(()=>yi(ke),[ke]),gr=l.useMemo(()=>jy(Qe,J),[J,Qe]),jr=l.useMemo(()=>vi(ke),[ke]),jn=ke==="claude"?de:ke==="codex"?N:ke==="gemini"?Me:C,ca=l.useMemo(()=>mx(ke).OPTIONS,[ke]),Co=l.useMemo(()=>(Ce[ke]||[]).map(b=>({value:b,label:b})),[Ce,ke]),Sr=t?.__provider===ke&&yx(ke,t?.model)?t.model.trim():"",Pt=Sr||jn,Sn=l.useMemo(()=>{const b=Co.length>0?Co:ca;return!Sr||b.some(R=>R.value===Sr)?b:[{value:Sr,label:Sr},...b]},[Co,ca,Sr]),Cd=Sn.find(b=>b.value===Pt)?.label||Pt||he("providerSelection.selectModel"),Ed=!!Sr,Ad=ke==="opencode"&&!!At.opencode,Eo=l.useCallback((b,{short:R=!1}={})=>{let F=he("codex.modes.default");return b==="acceptEdits"?F=he("codex.modes.acceptEdits"):b==="bypassPermissions"?F=he("codex.modes.bypassPermissions"):b==="plan"&&(F=he("codex.modes.plan")),R?F.replace(/\s*模式$/,"").replace(/\s*Mode$/,""):F},[he]),Id=l.useMemo(()=>Eo(Pe,{short:!0}),[Eo,Pe]),_d=l.useMemo(()=>he("codex.permissionMode").replace(/^权限/,"").replace(/^Permission\s+/i,""),[he]),Ao=l.useCallback(async(b,{force:R=!1}={})=>{if(!ux.includes(b))return null;ft(F=>({...F,[b]:!0})),me(F=>({...F,[b]:null})),je(F=>({...F,[b]:{status:dx}}));try{const X=await xe(`/api/cli/providers/${b}/installation-status${R?"?force=true":""}`),Te=await X.json().catch(()=>({}));if(!X.ok||Te?.success!==!0)throw new Error(Te?.error||`Failed to check ${b} installation`);const He=Te.installed?cx:Ho;return je(it=>({...it,[b]:{status:He,command:Te.command||null,resolvedPath:Te.resolvedPath||null,reason:Te.reason||null,installHint:Te.installHint||null,checkedAt:Te.checkedAt||null,cacheHit:!!Te.cacheHit}})),He}catch(F){return je(X=>({...X,[b]:{status:Un}})),me(X=>({...X,[b]:F.message})),Un}finally{ft(F=>({...F,[b]:!1}))}},[me,ft,je]),Td=l.useCallback(b=>{if(!b)return;const R=Ht(b);q(R),localStorage.setItem("selected-provider",R),Ao(R)},[Ao]);l.useEffect(()=>{const b=Sn.map(R=>R.value);!jn||b.includes(jn)||(ke==="claude"?ae(""):ke==="codex"?ie(""):ke==="gemini"?Z(""):ke==="opencode"&&D(""),hx(ke))},[ke,jn,Sn]),l.useEffect(()=>{if(!e)return;const b=e.fullPath||e.path;if(!b)return;const R=`runtime-models:v2:${ke}:${b}`,F=Zi(bt.getItem(R)),X=Array.isArray(F?.models)?F.models:[],Te=typeof F?.currentModel=="string"?F.currentModel.trim():"",He=Number(F?.timestamp||0);if(X.length>0&&Date.now()-He<px){_e(lt=>({...lt,[ke]:X})),Te&&V(lt=>({...lt,[ke]:{...lt?.[ke]||{},currentModel:Te}}));return}let It=!1;return U(lt=>({...lt,[ke]:!0})),xt.providerDiscovery(ke,b).then(async lt=>{if(!lt.ok)throw new Error(`HTTP ${lt.status}`);return lt.json()}).then(lt=>{if(It)return;const $t=Array.isArray(lt?.models)?lt.models.map(xr=>xr.id):[],Qt=typeof lt?.currentModel=="string"?lt.currentModel.trim():"";V(xr=>({...xr,[ke]:lt})),_e(xr=>({...xr,[ke]:$t})),$t.length>0&&bt.setItem(R,JSON.stringify({models:$t,currentModel:Qt||"",timestamp:Date.now()}))}).catch(()=>{It||_e(lt=>({...lt,[ke]:X}))}).finally(()=>{It||U(lt=>({...lt,[ke]:!1}))}),()=>{It=!0}},[ke,e]),l.useEffect(()=>{Dt.current=Ue},[Ue]);const da=l.useRef(bi);l.useEffect(()=>{if(da.current)return;const b=xs(le);b&&(pe(b),kr.current=!0,da.current=!0,bi=!0)},[le]),l.useEffect(()=>{Ee(ue),tt(ue),mt(!1)},[ue]);const Jt=l.useCallback((b,R,F={})=>{!R||typeof Q!="function"||Q({type:b,requestId:R,payload:{...F,clientId:se||null}})},[se,Q]),ua=l.useCallback((b,R=null)=>{if(typeof b?.context!="object"||b.context==null||Array.isArray(b.context)){console.warn("[DynamicContext] Ignored integration.context.update because context is not an object."),Jt("integration.error",R,{code:"INVALID_PAYLOAD",message:"context must be an object"});return}if(Xg(b.mode)===gs){const Te=Yg(Dt.current,b.context);if(!Te){console.warn("[DynamicContext] Ignored invalid append context payload."),Jt("integration.error",R,{code:"INVALID_PAYLOAD",message:"append context payload is invalid"});return}Ee(Te),tt(Te),mt(!1),Jt("integration.ack",R,{accepted:!0,applied:!0});return}const X=qa(b.context);if(!X){Jt("integration.error",R,{code:"INVALID_PAYLOAD",message:"context payload does not satisfy contextV1"});return}Ee(X),tt(X),mt(!1),Jt("integration.ack",R,{accepted:!0,applied:!0})},[Jt]),pa=l.useCallback((b,R=null)=>{if(typeof b?.prompt!="string"){Jt("integration.error",R,{code:"INVALID_PAYLOAD",message:"prompt must be a string"});return}const F=xs(b.prompt);if(pe(F),kr.current=!0,b.autoSend===!0&&F&&n.current&&!a&&Ft.current){const X={preventDefault:()=>{}};Ft.current(X,F)}Jt("integration.ack",R,{accepted:!0,applied:!0})},[a,n,Jt]),ma=l.useCallback((b=null)=>{Jt("integration.ack",b,{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:t?.id||null})},[t?.id,Jt]);l.useEffect(()=>{if(!W?.__messageSeq)return;const R=W?.type;if(R==="integration.context.update"){ua(W.payload||{},W.requestId||null);return}if(R==="integration.prompt.update"){pa(W.payload||{},W.requestId||null);return}R==="integration.ping"&&ma(W.requestId||null)},[ua,pa,W,ma]);const tn=l.useMemo(()=>jt||!Ue||!qg(Ue)?null:Ue,[jt,Ue]),Md=l.useMemo(()=>tn?.selectedElements?.slice(0,Ua)||[],[tn]),Dd=l.useMemo(()=>tn?.selectedElements?.slice(Ua)||[],[tn]),Pd=l.useCallback(()=>{tt(b=>!b||!or(b.systemContext)?b:{...b,systemContext:""})},[]),Rd=l.useCallback(()=>{tt(b=>!b||!or(Jr(b.currentFile))?b:{...b,currentFile:{path:"",displayName:""}})},[]),Ld=l.useCallback(b=>{tt(R=>{if(!R||!Array.isArray(R.selectedElements)||R.selectedElements.length===0)return R;const F=R.selectedElements.findIndex(X=>X.tag===b.tag&&X.selector===b.selector&&X.label===b.label);return F<0?R:{...R,selectedElements:R.selectedElements.filter((X,Te)=>Te!==F)}})},[]);l.useEffect(()=>{if(t?.id){const b=localStorage.getItem(`permissionMode-${t.id}`);b&&ir.modes.includes(b)?at(b):at(ir.defaultMode)}},[t?.id,ir]),l.useEffect(()=>{ir.modes.includes(Pe)||at(ir.defaultMode)},[Pe,ir]),l.useEffect(()=>{if(!jr.enabled){pt!==jr.defaultMode&&wt(jr.defaultMode);return}jr.modes.includes(pt)||wt(jr.defaultMode)},[jr,pt]),l.useEffect(()=>{if(t&&t.__provider&&t.__provider!==ke){const b=Ht(t.__provider);q(b),localStorage.setItem("selected-provider",b)}if(t?.id&&t?.__provider)try{const b=localStorage.getItem("session-provider-map"),R=b?JSON.parse(b):{};R[t.id]!==t.__provider&&(R[t.id]=t.__provider,localStorage.setItem("session-provider-map",JSON.stringify(R)))}catch{}},[ke,t]),l.useEffect(()=>{la.current!==ke&&(p([]),la.current=ke)},[ke,p]),l.useEffect(()=>{p(b=>b.filter(R=>!R.sessionId||R.sessionId===t?.id))},[t?.id,p]),l.useEffect(()=>{const b=Xo(t),R=new Set(b.availableModes.map(F=>F.id));dt(F=>b.currentModeId&&R.has(b.currentModeId)?b.currentModeId:F&&R.has(F)?F:"")},[t]),l.useEffect(()=>{oe(ky(t))},[t]),l.useEffect(()=>{(async()=>{if(e)try{const R=await xe("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:e.path})});if(!R.ok)throw new Error("Failed to fetch commands");const F=await R.json(),X=[...(F.builtIn||[]).map(it=>({...it,type:"built-in"})),...(F.custom||[]).map(it=>({...it,type:"custom"}))];ot(X);const Te=`command_history_${e.name}`,He=bt.getItem(Te);if(He)try{const it=JSON.parse(He),It=[...X].sort((lt,$t)=>{const Qt=it[lt.name]||0;return(it[$t.name]||0)-Qt});ot(It)}catch(it){console.error("Error parsing command history:",it)}}catch(R){console.error("Error fetching slash commands:",R),ot([])}})()},[e]);const Io=l.useMemo(()=>gr.length?new en(gr,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[gr]);l.useEffect(()=>{if(!G){M(gr);return}if(!Io){M([]);return}const b=Io.search(G);M(b.map(R=>R.item))},[G,gr,Io]);const Od=l.useMemo(()=>{if(!e||gr.length===0)return[];const b=`command_history_${e.name}`,R=bt.getItem(b);if(!R)return[];try{const F=JSON.parse(R);return gr.map(X=>({...X,usageCount:F[X.name]||0})).filter(X=>X.usageCount>0).sort((X,Te)=>Te.usageCount-X.usageCount).slice(0,5)}catch(F){return console.error("Error parsing command history:",F),[]}},[gr,e]),fa=l.useCallback(b=>{const{action:R,data:F}=b;switch(R){case"clear":i([]),$([]);break;case"help":i(X=>[...X,{role:"assistant",content:F.content,timestamp:Date.now()}]);break;case"model":{const X=Object.entries(F.available||{}).filter(([,He])=>Array.isArray(He)&&He.length>0).map(([He,it])=>`**${He.charAt(0).toUpperCase()+He.slice(1)}**: ${it.join(", ")}`).join(`
|
|
26
|
+
|
|
27
|
+
`),Te=F.current.provider==="opencode"?F.opencodeDiscovery?"_OpenCode source: runtime provider registry._":"_OpenCode source: local fallback list._":"";i(He=>[...He,{role:"assistant",content:`**Current Model**: ${F.current.model}
|
|
28
|
+
|
|
29
|
+
**Available Models**:
|
|
30
|
+
|
|
31
|
+
${X}${Te?`
|
|
32
|
+
|
|
33
|
+
${Te}`:""}`,timestamp:Date.now()}]);break}case"cost":{const X=`**Token Usage**: ${F.tokenUsage.used.toLocaleString()} / ${F.tokenUsage.total.toLocaleString()} (${F.tokenUsage.percentage}%)
|
|
34
|
+
|
|
35
|
+
**Estimated Cost**:
|
|
36
|
+
- Input: $${F.cost.input}
|
|
37
|
+
- Output: $${F.cost.output}
|
|
38
|
+
- **Total**: $${F.cost.total}
|
|
39
|
+
|
|
40
|
+
**Model**: ${F.model}`;i(Te=>[...Te,{role:"assistant",content:X,timestamp:Date.now()}]);break}case"status":{const X=`**System Status**
|
|
41
|
+
|
|
42
|
+
- Version: ${F.version}
|
|
43
|
+
- Uptime: ${F.uptime}
|
|
44
|
+
- Model: ${F.model}
|
|
45
|
+
- Provider: ${F.provider}
|
|
46
|
+
- Node.js: ${F.nodeVersion}
|
|
47
|
+
- Platform: ${F.platform}`;i(Te=>[...Te,{role:"assistant",content:X,timestamp:Date.now()}]);break}case"memory":F.error?i(X=>[...X,{role:"assistant",content:`⚠️ ${F.message}`,timestamp:Date.now()}]):(i(X=>[...X,{role:"assistant",content:`📝 ${F.message}
|
|
48
|
+
|
|
49
|
+
Path: \`${F.path}\``,timestamp:Date.now()}]),F.exists&&v&&v(F.path));break;case"config":w&&w();break;case"rewind":F.error?i(X=>[...X,{role:"assistant",content:`⚠️ ${F.message}`,timestamp:Date.now()}]):(i(X=>X.slice(0,-F.steps*2)),i(X=>[...X,{role:"assistant",content:`⏪ ${F.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",R)}},[v,w,i,$]),ha=l.useCallback(async b=>{const{content:R,hasBashCommands:F}=b;if(F&&!window.confirm("这条命令包含将要执行的 Bash 命令,是否继续?")){i(Te=>[...Te,{role:"assistant",content:"❌ 已取消命令执行",timestamp:Date.now()}]);return}pe(R),setTimeout(()=>{if(Ft.current){const X={preventDefault:()=>{}};Ft.current(X)}},50)},[i]),Nn=l.useCallback(async b=>{if(!(!b||!e))try{const R=be.match(new RegExp(`${b.name}\\s*(.*)`)),F=R&&R[1]?R[1].trim().split(/\s+/):[],X={projectPath:e.path,projectName:e.name,sessionId:o,provider:ke,...Pt?{model:Pt}:{},tokenUsage:y},Te=await xe("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:b.name,commandPath:b.path,args:F,context:X})});if(!Te.ok)throw new Error("Failed to execute command");const He=await Te.json();He.type==="builtin"?fa(He):He.type==="custom"&&await ha(He,F),pe(""),Ye(!1),Ne(-1),O(""),Fe(-1)}catch(R){console.error("Error executing command:",R),i(F=>[...F,{role:"assistant",content:`Error executing command: ${R.message}`,timestamp:Date.now()}])}},[Pt,o,fa,ha,be,ke,e,i,y]),Fd=l.useCallback(b=>{const R=String(b||"").trim();if(!R||R===Nt)return;dt(R);const F=t?.id||o;if(!F)return;const X=t?.__provider||ke||"claude";f({type:"set-session-mode",provider:X,sessionId:F,modeId:R})},[Nt,o,ke,t?.__provider,t?.id,f]),Cn=l.useCallback(b=>{if(!b||!e?.name)return;const R=`command_history_${e.name}`,F=bt.getItem(R);let X={};try{X=F?JSON.parse(F):{}}catch(Te){console.error("Error parsing command history:",Te)}X[b.name]=(X[b.name]||0)+1,bt.setItem(R,JSON.stringify(X))},[e?.name]),$d=l.useCallback((b,R,F)=>{if(!(!b||!e)){if(F){Fe(R);return}if(Cn(b),b?.source==="acp"){const X=String(b.name||"").trim(),Te=X.startsWith("/")?`${X} `:`/${X} `;pe(Te),Ye(!1),Ne(-1),O(""),Fe(-1);return}Nn(b)}},[Nn,Cn,e]),_o=l.useCallback(b=>{if(!b)return;const R=b?.source==="acp",F=String(b.name||"").trim(),X=R&&F&&!F.startsWith("/")?`/${F}`:F,Te=be.slice(0,ct),He=be.slice(ct),it=He.indexOf(" "),It=it!==-1?He.slice(it):"",lt=`${Te}${X} ${It}`;pe(lt),Ye(!1),Ne(-1),O(""),Fe(-1),ar.current&&clearTimeout(ar.current),Cn(b),R||Nn(b)},[Nn,Cn,be,ct]);l.useEffect(()=>{e&&xt.getFiles(e.name).then(async b=>b.ok?b.json():[]).then(b=>{ye(Ec(b))}).catch(b=>{console.error("Error fetching files:",b)})},[e]),l.useEffect(()=>{const b=be.slice(0,Xe),R=b.lastIndexOf("@");if(R!==-1){const F=b.slice(R+1);if(F.includes(" "))ee(!1),Re(-1);else{Re(R),ee(!0);const X=Ae.filter(Te=>Te.name.toLowerCase().includes(F.toLowerCase())||Te.path.toLowerCase().includes(F.toLowerCase())).slice(0,10);Le(X),rt(-1)}}else ee(!1),Re(-1)},[be,Xe,Ae]);const rn=l.useMemo(()=>!be||st.length===0?[]:st.filter(b=>be.includes(b)),[st,be]),nn=l.useMemo(()=>rn.length===0?[]:Array.from(new Set(rn)).sort((b,R)=>R.length-b.length),[rn]),To=l.useMemo(()=>nn.length===0?null:new RegExp(`(${nn.map(Bg).join("|")})`,"g"),[nn]),ga=l.useMemo(()=>new Set(nn),[nn]),Bd=l.useCallback(b=>b?To?b.split(To).map((F,X)=>ga.has(F)?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:F},`mention-${X}`):r.jsx("span",{children:F},`text-${X}`)):b:"",[To,ga]),En=l.useCallback(b=>{const R=b.filter(F=>{try{if(!F||typeof F!="object"||!F.type||!F.type.startsWith("image/"))return!1;if(!F.size||F.size>5242880){const X=F.name||"Unknown file";return Se(Te=>{const He=new Map(Te);return He.set(X,"File too large (max 5MB)"),He}),!1}return!0}catch(X){return console.error("Error validating file:",X,F),!1}});R.length>0&&j(F=>[...F,...R].slice(0,5))},[]),zd=l.useCallback(b=>{const R=Array.from(b.clipboardData.items);for(const F of R)if(F.type.startsWith("image/")){const X=F.getAsFile();X&&En([X])}if(R.length===0&&b.clipboardData.files.length>0){const X=Array.from(b.clipboardData.files).filter(Te=>Te.type.startsWith("image/"));X.length>0&&En(X)}},[En]),{getRootProps:Ud,getInputProps:Wd,isDragActive:Hd,open:qd}=ed({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:En,noClick:!0,noKeyboard:!0}),Fr=l.useCallback(async(b,R=null)=>{b.preventDefault();const F=typeof R=="string"?R:be,X=t?.__provider||ke||"claude";if((Y[X]?.status||Un)===Ho||!F.trim()||a||!e)return;let He=F;const it=vi(X),It=it.enabled?up.find(Et=>Et.id===pt):null;it.strategy==="prompt-prefix"&&It?.prefix&&(He=`${It.prefix}: ${F}`);const lt=!jt&&Hg(Ue)?Qg(Ue):null;lt&&(He=Zg(lt,He)),d("queued"),u(Zs({phaseText:he("activity.stage.generatingReply"),detailText:he("activity.detail.preparingReply"),canAbort:!0}));let $t=[];if(P.length>0){if(!my(X)){d("idle"),c(!1),u(null),i(Et=>[...Et,{type:"error",content:`${X} 当前不支持图片输入`,timestamp:new Date}]);return}try{$t=await xy(P)}catch(Et){console.error("Image preparation failed:",Et),d("idle"),c(!1),u(null),i(In=>[...In,{type:"error",content:`图片处理失败:${Et.message}`,timestamp:new Date}]);return}}const Qt=vy(rn),xr=[...$t.map(Et=>({type:"image",data:Et.data,mimeType:Et.mimeType,name:Et.name})),...Qt],Br=hy(),ba={type:"user",content:F,provider:X,images:$t,contentBlocks:Qt,timestamp:new Date,clientRequestId:Br};i(Et=>[...Et,ba]),E(!1),setTimeout(()=>B(),100);const Tt=o||t?.id;L(Tt||t?.id||null),Tt&&S(Rt({kind:"user_message",provider:X,sessionId:Tt,timestamp:ba.timestamp,payload:{text:F,contentBlocks:xr},extensions:{clientRequestId:Br,optimistic:!0}}));const iu=Tt||`new-session-${Date.now()}`;!Tt&&!t?.id&&(k.current={sessionId:null,startedAt:Date.now()}),g&&g(iu);const lu=(()=>{try{const Et=ke==="codex"?"codex-settings":"claude-settings",In=bt.getItem(Et);if(In)return JSON.parse(In)}catch(Et){console.error("Error loading tools settings:",Et)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();if(X==="codex"){const Et=it.enabled&&it.strategy==="native-effort"?fy(pt):void 0;f({type:"codex-command",clientRequestId:Br,command:He,sessionId:Tt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Tt,resume:!!Tt,permissionMode:Pe==="plan"?"default":Pe,...Pt?{model:Pt}:{},...Et?{modelReasoningEffort:Et}:{},images:$t,resourceLinks:Qt}})}else f(X==="gemini"?{type:"gemini-command",clientRequestId:Br,command:He,sessionId:Tt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Tt,resume:!!Tt,permissionMode:Pe==="plan"?"default":Pe,...Pt?{model:Pt}:{},images:$t,resourceLinks:Qt}}:X==="opencode"?{type:"opencode-command",clientRequestId:Br,command:He,sessionId:Tt,options:{cwd:e.fullPath||e.path,projectPath:e.fullPath||e.path,sessionId:Tt,resume:!!Tt,permissionMode:Pe==="plan"?"default":Pe,...Pt?{model:Pt}:{},images:$t,resourceLinks:Qt}}:{type:"claude-command",clientRequestId:Br,command:He,options:{projectPath:e.path,cwd:e.fullPath,sessionId:Tt,resume:!!Tt,toolsSettings:lu,permissionMode:Pe,...Pt?{model:Pt}:{},images:$t,resourceLinks:Qt}});lt&&mt(!0),pe(""),j([]),ne(new Map),Se(new Map),Ie(!1),wt("none"),We.current&&(We.current.style.height="auto"),e&&bt.removeItem(`draft_input_${e.name}`)},[rn,S,P,Pt,o,jt,be,a,g,Ue,k,Pe,ke,Y,B,e,t,f,c,i,u,E,d,L,he,pt]);l.useEffect(()=>{Ft.current=Fr},[Fr]);const Kd=l.useCallback(b=>!b||ke!=="claude"?{success:!1}:jx(b.entry),[ke]),Gd=l.useCallback((b,R)=>{const X=(Array.isArray(b)?b:[b]).filter(Boolean);X.length!==0&&(X.forEach(Te=>{f({type:"permission-response",requestId:Te,optionId:R?.optionId,outcome:R?.outcome,cancelled:!!R?.cancelled,allow:!!R?.allow,updatedInput:R?.updatedInput,message:R?.message,rememberEntry:R?.rememberEntry})}),p(Te=>{const He=Te.filter(it=>!X.includes(it.requestId));return He.length===0&&u(null),He}))},[f,u,p]),An=l.useCallback(b=>{const R=be.slice(0,fe),F=be.slice(fe),X=F.indexOf(" "),Te=X!==-1?F.slice(X):"",He=`${R}${b.path} ${Te}`,it=R.length+b.path.length+1;We.current&&!We.current.matches(":focus")&&We.current.focus(),pe(He),Ve(it),Ke(It=>It.includes(b.path)?It:[...It,b.path]),ee(!1),Re(-1),We.current&&requestAnimationFrame(()=>{We.current&&(We.current.setSelectionRange(it,it),We.current.matches(":focus")||We.current.focus())})},[fe,be]),Vd=l.useCallback(b=>{const R=b.target.value,F=b.target.selectionStart;if(pe(R),Ve(F),!R.trim()){b.target.style.height="auto",Ie(!1),Ye(!1),Ne(-1),O("");return}const X=R.slice(0,F);if((X.match(/```/g)||[]).length%2===1){Ye(!1),Ne(-1),O("");return}const He=X.match(/(^|\s)\/(\S*)$/);if(He){const it=He.index+He[1].length,It=He[2];Ne(it),Ye(!0),Fe(-1),ar.current&&clearTimeout(ar.current),ar.current=setTimeout(()=>{O(It)},150)}else Ye(!1),Ne(-1),O(""),ar.current&&clearTimeout(ar.current)},[]),Mo=l.useCallback(b=>{!Ct.current||!b||(Ct.current.scrollTop=b.scrollTop,Ct.current.scrollLeft=b.scrollLeft)},[]),Jd=l.useCallback(b=>{Ve(b.target.selectionStart)},[]),Yd=l.useCallback(b=>{b.target.style.height="auto",b.target.style.height=`${b.target.scrollHeight}px`,Ve(b.target.selectionStart),Mo(b.target);const R=parseInt(window.getComputedStyle(b.target).lineHeight,10),F=b.target.scrollHeight>R*2;Ie(F)},[Mo]),Xd=l.useCallback(b=>{if(et&&x.length>0){if(b.key==="ArrowDown"){b.preventDefault(),Fe(R=>R<x.length-1?R+1:0);return}if(b.key==="ArrowUp"){b.preventDefault(),Fe(R=>R>0?R-1:x.length-1);return}if(b.key==="Tab"||b.key==="Enter"){b.preventDefault(),Oe>=0?_o(x[Oe]):x.length>0&&_o(x[0]);return}if(b.key==="Escape"){b.preventDefault(),Ye(!1),Ne(-1),O(""),Fe(-1),ar.current&&clearTimeout(ar.current);return}}if(A&&we.length>0){if(b.key==="ArrowDown"){b.preventDefault(),rt(R=>R<we.length-1?R+1:0);return}if(b.key==="ArrowUp"){b.preventDefault(),rt(R=>R>0?R-1:we.length-1);return}if(b.key==="Tab"||b.key==="Enter"){b.preventDefault(),ze>=0?An(we[ze]):we.length>0&&An(we[0]);return}if(b.key==="Escape"){b.preventDefault(),ee(!1);return}}if(b.key==="Tab"&&!A&&!et){b.preventDefault();const R=ir.modes,X=(R.indexOf(Pe)+1)%R.length,Te=R[X];at(Te),t?.id&&localStorage.setItem(`permissionMode-${t.id}`,Te);return}if(b.key==="Enter"){if(b.nativeEvent.isComposing)return;(b.ctrlKey||b.metaKey)&&!b.shiftKey?(b.preventDefault(),Fr(b)):!b.shiftKey&&!b.ctrlKey&&!b.metaKey&&(ce||(b.preventDefault(),Fr(b)))}},[x,we,Fr,Pe,ir.modes,_o,An,Oe,ze,t?.id,ce,et,A]),$r=t?.__provider||ke||"claude",Do=Y[$r],xa=Do?.status||Un,ya=xa===Ho,Qd=Do?.reason||z[$r]||null,Zd=Do?.installHint||null,eu=!!Ze[$r],tu=a||ya,va=$r==="opencode"?"OpenCode":he(`messageTypes.${$r}`),ru=he("input.providerNotInstalledWithName",{provider:va}),nu=l.useMemo(()=>Xo(t),[t]);l.useEffect(()=>{e&&be!==""?bt.setItem(`draft_input_${e.name}`,be):e&&be===""&&bt.removeItem(`draft_input_${e.name}`)},[be,e]),l.useEffect(()=>{if(e){if(kr.current){kr.current=!1;return}const b=bt.getItem(`draft_input_${e.name}`)||"";b!==be&&pe(b)}},[be,e?.name]),l.useEffect(()=>{h&&h(K)},[K,h]),l.useEffect(()=>{if(We.current){We.current.style.height="auto",We.current.style.height=`${We.current.scrollHeight}px`;const b=parseInt(window.getComputedStyle(We.current).lineHeight,10);Ie(We.current.scrollHeight>b*2)}},[]),l.useEffect(()=>{We.current&&!be.trim()&&(We.current.style.height="auto",Ie(!1))},[be]);const ou=l.useCallback(b=>{j(R=>R.filter((F,X)=>X!==b))},[]),su=l.useCallback(b=>{ke==="claude"?ae(b):ke==="codex"?ie(b):ke==="gemini"?Z(b):ke==="opencode"&&D(b),fx(ke,b)},[ke]);l.useCallback(()=>{o&&s&&f({type:"abort-session",sessionId:o,provider:ke})},[s,o,ke,f]);const au=l.useCallback(()=>{pe(""),j([]),ne(new Map),Se(new Map),Ie(!1),wt("none"),Ye(!1),ee(!1),O(""),Ne(-1),Fe(-1),rt(-1),e?.name&&bt.removeItem(`draft_input_${e.name}`),typeof _=="function"&&_()},[_,e?.name]);return{input:be,setInput:pe,provider:ke,setProvider:q,handleProviderSelection:Td,permissionMode:Pe,setPermissionMode:at,acpModes:nu.availableModes,acpModeId:Nt,handleAcpModeChange:Fd,selectedPermissionShortLabel:Id,permissionDropdownTitle:_d,providerModeConfig:ir,getPermissionModeLabel:Eo,providerThinkingConfig:jr,thinkingMode:pt,setThinkingMode:wt,currentModel:Pt,modelOptions:Sn,selectedModelLabel:Cd,isModelSelectionLocked:Ed,isOpencodeModelLoading:Ad,setProviderModel:su,textareaRef:We,inputContainerRef:nt,inputHighlightRef:Ct,modelSelectorRef:Mt,permissionSelectorRef:wr,showFileDropdown:A,filteredFiles:we,selectedFileIndex:ze,selectFile:An,showCommandMenu:et,filteredCommands:x,selectedCommandIndex:Oe,handleCommandSelect:$d,commandQuery:G,frequentCommands:Od,slashPosition:ct,setShowCommandMenu:Ye,setSelectedCommandIndex:Fe,setSlashPosition:Ne,setCommandQuery:O,getRootProps:Ud,getInputProps:Wd,isDragActive:Hd,openImagePicker:qd,attachedImages:P,uploadingImages:T,imageErrors:ge,removeAttachedImage:ou,visibleDynamicContext:tn,visibleSelectedElements:Md,hiddenSelectedElements:Dd,handleDismissSystemContext:Pd,handleDismissCurrentFile:Rd,handleDismissSelectedElement:Ld,renderInputWithMentions:Bd,handleInputChange:Vd,handleTextareaClick:Jd,handleKeyDown:Xd,handlePaste:zd,syncInputOverlayScroll:Mo,handleTextareaInput:Yd,activeInputProvider:$r,activeInputProviderLabel:va,activeProviderInstallState:xa,isActiveProviderNotInstalled:ya,unavailablePlaceholder:ru,isInputDisabled:tu,activeProviderInstallReason:Qd,activeProviderInstallHint:Zd,isCheckingProviderInstallation:eu,checkProviderInstallation:Ao,providerCheckLoadingByName:Ze,isInputFocused:K,setIsInputFocused:De,isTextareaExpanded:te,tokenBudget:y,handleSubmit:Fr,handleSubmitRef:Ft,handleGrantToolPermission:Kd,handlePermissionDecision:Gd,dynamicContext:re,pendingDynamicContext:Ue,setPendingDynamicContext:tt,dynamicContextSent:jt,setDynamicContextSent:mt,resetComposerForNewChat:au}}function Ny({selectedProject:e,selectedSession:t,ws:n,sendMessage:o,latestMessage:s,onFileOpen:a,onInputFocusChange:i,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:m,processingSessions:p,onReplaceTemporarySession:f,onNavigateToSession:g,onShowSettings:h,autoExpandTools:w,showRawParameters:v,showThinking:S,autoScrollToBottom:L,sendByCtrlEnter:k,externalMessageUpdate:B,urlContext:E,urlPrompt:y,integrationClientId:I,latestIntegrationMessage:$,sendIntegrationMessage:_,newSessionResetNonce:H=0}){const{t:le}=kt("chat"),se=l.useMemo(()=>typeof window<"u"&&e?.name?wx(e.name,t?.id||null):[],[e?.name,t?.id]),[W,Q]=l.useReducer(Ig,se,Ag),[ce,he]=l.useState(t?.id||null),[be,pe]=l.useState(!1),[K,De]=l.useState(null),[P,j]=l.useState(null),[T,ne]=l.useState([]),ge=l.useRef(e),Se=l.useRef(W.messages),A=l.useRef(W.isLoading),ee=l.useRef({sessionId:null,startedAt:0}),Ae=l.useRef(null),ye=l.useRef(H),st=l.useRef(""),Ke=l.useRef(null),we=W.messages,Le=W.phase,ze=W.isLoading,rt=W.canAbortSession,Xe=W.pendingPermissionRequests;l.useEffect(()=>{ge.current=e},[e]),l.useEffect(()=>{Se.current=we},[we]),l.useEffect(()=>{A.current=ze},[ze]);const Ve=l.useCallback(Ne=>{Q({type:"replace_messages",value:Ne})},[]),fe=l.useCallback(Ne=>{Q({type:"replace_permissions",value:Ne})},[]),Re=l.useCallback(Ne=>{Q({type:"set_loading",value:Ne})},[]),et=l.useCallback(Ne=>{Q({type:"set_can_abort",value:Ne})},[]),Ye=l.useCallback((Ne,Pe)=>{Q({type:"set_phase",phase:Ne,overrides:Pe})},[]),Qe=l.useCallback((Ne,Pe)=>{Q({type:"apply_conversation_event",event:Ne,provider:Pe})},[]),ot=l.useCallback(Ne=>{ee.current={sessionId:Ne||null,startedAt:Date.now()}},[]),J=l.useCallback(Ne=>{!Ne||!ee.current.startedAt||(ee.current={...ee.current,sessionId:Ne})},[]),oe=l.useCallback((Ne=null)=>{const Pe=ee.current;Pe.startedAt&&(Ne&&Pe.sessionId&&Pe.sessionId!==Ne||(ee.current={sessionId:null,startedAt:0}))},[]),x=l.useCallback(()=>{Ke.current&&(clearTimeout(Ke.current),Ke.current=null),st.current=""},[]),M=l.useCallback((Ne,Pe=null)=>{if(Pe&&Pe!=="session-status")return!1;const at=ee.current;return!!(at.startedAt&&Ne&&at.sessionId===Ne&&Date.now()-at.startedAt<15e3&&(Le===ve.CONNECTING||Le===ve.QUEUED||Le===ve.STREAMING||Le===ve.AWAITING_APPROVAL||Le===ve.COMPLETED||Le===ve.ABORTED||Le===ve.ERRORED))},[Le]),G=l.useCallback((Ne=null)=>{const Pe=ge.current?.name||e?.name||"";Pe&&Dc(Pe,Ne,Se.current)},[e?.name]),O=Cx({selectedProject:e,selectedProjectRef:ge,selectedSession:t,currentSessionId:ce,setCurrentSessionId:he,provider:t?.__provider||null,runtimePhase:Le,isLoading:ze,isLoadingRef:A,processingSessions:p,autoScrollToBottom:L,externalMessageUpdate:B,ws:n,sendMessage:o,chatMessages:we,setChatMessages:Ve,setIsLoading:Re,setCanAbortSession:et,setRuntimePhase:Ye,setClaudeStatus:De,setPendingPermissionRequests:fe,resetStreamingState:x,clearLocalRunGuard:oe,localRunGuardRef:ee,pendingViewSessionRef:Ae,isSystemSessionChange:be,setIsSystemSessionChange:pe,onSessionInactive:d,onSessionNotProcessing:m,onSessionProcessing:u}),te=l.useMemo(()=>bg(O.sessionMessages),[O.sessionMessages]);l.useEffect(()=>{j(te.modeState||null),ne(Array.isArray(te.availableCommands)?te.availableCommands:[])},[te.availableCommands,te.modeState]);const Ie=l.useMemo(()=>{if(!t&&!ce)return t;const Ne=t?{...t}:{};return!Ne.id&&ce&&(Ne.id=ce),Ne.acpModes=P,Ne.acpAvailableCommands=T,Ne},[T,P,ce,t]),Oe=Sy({selectedProject:e,selectedSession:Ie,selectedProjectRef:ge,currentSessionId:ce,canAbortSession:rt,isLoading:ze,setChatMessages:Ve,setCanAbortSession:et,setRuntimePhase:Ye,setClaudeStatus:De,pendingPermissionRequests:Xe,setPendingPermissionRequests:fe,sendMessage:o,onSessionActive:c,onInputFocusChange:i,onShowSettings:h,onFileOpen:a,appendSessionConversationEvent:O.appendSessionConversationEvent,startLocalRunGuard:ot,pendingViewSessionRef:Ae,scrollToBottom:O.scrollToBottom,setIsUserScrolledUp:O.setIsUserScrolledUp,tokenBudget:O.tokenBudget,chatMessages:we,setSessionMessages:O.setSessionMessages,resetRuntimeForNewChat:O.resetSessionHistoryForNewChat,urlContext:E,urlPrompt:y,integrationClientId:I,latestIntegrationMessage:$,sendIntegrationMessage:_,sendByCtrlEnter:k});Ax({latestMessage:s,provider:Oe.provider,claudeStatus:K,selectedProject:e,selectedSession:t,currentSessionId:ce,setCurrentSessionId:he,isLoading:ze,runtimePhase:Le,sendMessage:o,persistCurrentChatCache:G,setIsSystemSessionChange:pe,setPendingPermissionRequests:fe,setIsLoading:Re,setCanAbortSession:et,setClaudeStatus:De,setChatMessages:Ve,setTokenBudget:O.setTokenBudget,setAcpSessionModeState:j,setAcpAvailableCommands:ne,applyRealtimeConversationEvent:Qe,streamBufferRef:st,streamTimerRef:Ke,clearLocalRunGuard:oe,syncLocalRunGuardSession:J,shouldIgnoreStaleIdleSignal:M,pendingViewSessionRef:Ae,appendSessionConversationEvent:O.appendSessionConversationEvent,recoverAndSettleSessionRuntime:O.recoverAndSettleSessionRuntime,recoverTerminalSessionPhase:O.recoverTerminalSessionPhase,inferRuntimePhaseFromSessionEvents:O.inferRuntimePhaseFromSessionEvents,inferTerminalPhaseFromSessionEvents:O.inferTerminalPhaseFromSessionEvents,scheduleSessionStatusRecovery:O.scheduleSessionStatusRecovery,sessionMessages:O.sessionMessages,setSessionMessages:O.setSessionMessages,loadSessionMessages:O.loadSessionMessages,onSessionInactive:d,onSessionNotProcessing:m,onSessionProcessing:u,onReplaceTemporarySession:f,onNavigateToSession:g,t:le,setRuntimePhase:Ye}),l.useEffect(()=>{ye.current!==H&&(ye.current=H,!t&&(x(),oe(),Oe.resetComposerForNewChat()))},[oe,Oe.resetComposerForNewChat,H,x,t]);const Fe=dg({status:K,messages:we,pendingPermissionRequests:Xe,t:le}),ct=ze&&!!Fe;return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
50
|
+
details[open] .details-chevron {
|
|
51
|
+
transform: rotate(180deg);
|
|
52
|
+
}
|
|
53
|
+
`}),r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx($g,{selectedProject:e,selectedSession:t,currentSessionId:ce,provider:Oe.provider,chatMessages:we,threadMessages:O.threadMessages,isLoading:ze,isLoadingSessionMessages:O.isLoadingSessionMessages,isLoadingMoreMessages:O.isLoadingMoreMessages,hasMoreMessages:O.hasMoreMessages,totalMessages:O.totalMessages,sessionMessages:O.sessionMessages,visibleMessageCount:O.visibleMessageCount,pendingPermissionRequests:Xe,scrollContainerRef:O.scrollContainerRef,messagesEndRef:O.messagesEndRef,onScroll:O.handleScroll,onLoadEarlierSessionMessages:()=>O.loadOlderMessages(),onLoadEarlierMessages:O.loadEarlierMessages,onProviderSelection:Oe.handleProviderSelection,onFileOpen:a,onShowSettings:h,onGrantToolPermission:Oe.handleGrantToolPermission,onPermissionDecision:Oe.handlePermissionDecision,autoExpandTools:w,showRawParameters:v}),r.jsx(ox,{composer:Oe,statusPresentation:Fe,shouldShowClaudeStatus:ct,isLoading:ze,chatMessages:we,sendByCtrlEnter:k})]})]})}const Cy=gn.memo(Ny);class St{constructor(t,n,o,s){this.fromA=t,this.toA=n,this.fromB=o,this.toB=s}offset(t,n=t){return new St(this.fromA+t,this.toA+t,this.fromB+n,this.toB+n)}}function Dr(e,t,n,o,s,a){if(e==o)return[];let i=oa(e,t,n,o,s,a),c=sa(e,t+i,n,o,s+i,a);t+=i,n-=c,s+=i,a-=c;let d=n-t,u=a-s;if(!d||!u)return[new St(t,n,s,a)];if(d>u){let p=e.slice(t,n).indexOf(o.slice(s,a));if(p>-1)return[new St(t,t+p,s,s),new St(t+p+u,n,a,a)]}else if(u>d){let p=o.slice(s,a).indexOf(e.slice(t,n));if(p>-1)return[new St(t,t,s,s+p),new St(n,n,s+p+d,a)]}if(d==1||u==1)return[new St(t,n,s,a)];let m=nd(e,t,n,o,s,a);if(m){let[p,f,g]=m;return Dr(e,t,p,o,s,f).concat(Dr(e,p+g,n,o,f+g,a))}return Ey(e,t,n,o,s,a)}let ln=1e9,cn=0,na=!1;function Ey(e,t,n,o,s,a){let i=n-t,c=a-s;if(ln<1e9&&Math.min(i,c)>ln*16||cn>0&&Date.now()>cn)return Math.min(i,c)>ln*64?[new St(t,n,s,a)]:ki(e,t,n,o,s,a);let d=Math.ceil((i+c)/2);Qo.reset(d),Zo.reset(d);let u=(g,h)=>e.charCodeAt(t+g)==o.charCodeAt(s+h),m=(g,h)=>e.charCodeAt(n-g-1)==o.charCodeAt(a-h-1),p=(i-c)%2!=0?Zo:null,f=p?null:Qo;for(let g=0;g<d;g++){if(g>ln||cn>0&&!(g&63)&&Date.now()>cn)return ki(e,t,n,o,s,a);let h=Qo.advance(g,i,c,d,p,!1,u)||Zo.advance(g,i,c,d,f,!0,m);if(h)return Ay(e,t,n,t+h[0],o,s,a,s+h[1])}return[new St(t,n,s,a)]}class td{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,o,s,a,i,c){for(let d=-t+this.start;d<=t-this.end;d+=2){let u=s+d,m=d==-t||d!=t&&this.vec[u-1]<this.vec[u+1]?this.vec[u+1]:this.vec[u-1]+1,p=m-d;for(;m<n&&p<o&&c(m,p);)m++,p++;if(this.vec[u]=m,m>n)this.end+=2;else if(p>o)this.start+=2;else if(a){let f=s+(n-o)-d;if(f>=0&&f<this.len&&a.vec[f]!=-1)if(i){let g=a.vec[f];if(g>=n-m)return[g,s+g-f]}else{let g=n-a.vec[f];if(m>=g)return[m,p]}}}return null}}const Qo=new td,Zo=new td;function Ay(e,t,n,o,s,a,i,c){let d=!1;return!Xr(e,o)&&++o==n&&(d=!0),!Xr(s,c)&&++c==i&&(d=!0),d?[new St(t,n,a,i)]:Dr(e,t,o,s,a,c).concat(Dr(e,o,n,s,c,i))}function rd(e,t){let n=1,o=Math.min(e,t);for(;n<o;)n=n<<1;return n}function oa(e,t,n,o,s,a){if(t==n||t==a||e.charCodeAt(t)!=o.charCodeAt(s))return 0;let i=rd(n-t,a-s);for(let c=t,d=s;;){let u=c+i,m=d+i;if(u>n||m>a||e.slice(c,u)!=o.slice(d,m)){if(i==1)return c-t-(Xr(e,c)?0:1);i=i>>1}else{if(u==n||m==a)return u-t;c=u,d=m}}}function sa(e,t,n,o,s,a){if(t==n||s==a||e.charCodeAt(n-1)!=o.charCodeAt(a-1))return 0;let i=rd(n-t,a-s);for(let c=n,d=a;;){let u=c-i,m=d-i;if(u<t||m<s||e.slice(u,c)!=o.slice(m,d)){if(i==1)return n-c-(Xr(e,c)?0:1);i=i>>1}else{if(u==t||m==s)return n-u;c=u,d=m}}}function Is(e,t,n,o,s,a,i,c){let d=o.slice(s,a),u=null;for(;;){if(u||i<c)return u;for(let m=t+i;;){Xr(e,m)||m++;let p=m+i;if(Xr(e,p)||(p+=p==m+1?1:-1),p>=n)break;let f=e.slice(m,p),g=-1;for(;(g=d.indexOf(f,g+1))!=-1;){let h=oa(e,p,n,o,s+g+f.length,a),w=sa(e,t,m,o,s,s+g),v=f.length+h+w;(!u||u[2]<v)&&(u=[m-w,s+g-w,v])}m=p}if(c<0)return u;i=i>>1}}function nd(e,t,n,o,s,a){let i=n-t,c=a-s;if(i<c){let d=nd(o,s,a,e,t,n);return d&&[d[1],d[0],d[2]]}return i<4||c*2<i?null:Is(e,t,n,o,s,a,Math.floor(i/4),-1)}function ki(e,t,n,o,s,a){na=!0;let i=n-t,c=a-s,d;if(i<c){let f=Is(o,s,a,e,t,n,Math.floor(i/6),50);d=f&&[f[1],f[0],f[2]]}else d=Is(e,t,n,o,s,a,Math.floor(c/6),50);if(!d)return[new St(t,n,s,a)];let[u,m,p]=d;return Dr(e,t,u,o,s,m).concat(Dr(e,u+p,n,o,m+p,a))}function od(e,t){for(let n=1;n<e.length;n++){let o=e[n-1],s=e[n];o.toA>s.fromA-t&&o.toB>s.fromB-t&&(e[n-1]=new St(o.fromA,s.toA,o.fromB,s.toB),e.splice(n--,1))}}function Iy(e,t,n){for(;;){od(n,1);let o=!1;for(let s=0;s<n.length;s++){let a=n[s],i,c;(i=oa(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[s]=new St(a.fromA+i,a.toA,a.fromB+i,a.toB)),(c=sa(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[s]=new St(a.fromA,a.toA-c,a.fromB,a.toB-c));let d=a.toA-a.fromA,u=a.toB-a.fromB;if(d&&u)continue;let m=a.fromA-(s?n[s-1].toA:0),p=(s<n.length-1?n[s+1].fromA:e.length)-a.toA;if(!m||!p)continue;let f=d?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);m<=f.length&&e.slice(a.fromA-m,a.fromA)==f.slice(f.length-m)?(n[s]=new St(a.fromA-m,a.toA-m,a.fromB-m,a.toB-m),o=!0):p<=f.length&&e.slice(a.toA,a.toA+p)==f.slice(0,p)&&(n[s]=new St(a.fromA+p,a.toA+p,a.fromB+p,a.toB+p),o=!0)}if(!o)break}return n}function _y(e,t,n){for(let o=0,s=0;s<e.length;s++){let a=e[s],i=a.toA-a.fromA,c=a.toB-a.fromB;if(i&&c||i>3||c>3){let d=s==e.length-1?t.length:e[s+1].fromA,u=a.fromA-o,m=d-a.toA,p=Si(t,a.fromA,u),f=ji(t,a.toA,m),g=a.fromA-p,h=f-a.toA;if((!i||!c)&&g&&h){let w=Math.max(i,c),[v,S,L]=i?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];w>g&&t.slice(p,a.fromA)==v.slice(L-g,L)?(a=e[s]=new St(p,p+i,a.fromB-g,a.toB-g),p=a.fromA,f=ji(t,a.toA,d-a.toA)):w>h&&t.slice(a.toA,f)==v.slice(S,S+h)&&(a=e[s]=new St(f-i,f,a.fromB+h,a.toB+h),f=a.toA,p=Si(t,a.fromA,a.fromA-o)),g=a.fromA-p,h=f-a.toA}if(g||h)a=e[s]=new St(a.fromA-g,a.toA+h,a.fromB-g,a.toB+h);else if(i){if(!c){let w=Ci(t,a.fromA,a.toA),v,S=w<0?-1:Ni(t,a.toA,a.fromA);w>-1&&(v=w-a.fromA)<=m&&t.slice(a.fromA,w)==t.slice(a.toA,a.toA+v)?a=e[s]=a.offset(v):S>-1&&(v=a.toA-S)<=u&&t.slice(a.fromA-v,a.fromA)==t.slice(S,a.toA)&&(a=e[s]=a.offset(-v))}}else{let w=Ci(n,a.fromB,a.toB),v,S=w<0?-1:Ni(n,a.toB,a.fromB);w>-1&&(v=w-a.fromB)<=m&&n.slice(a.fromB,w)==n.slice(a.toB,a.toB+v)?a=e[s]=a.offset(v):S>-1&&(v=a.toB-S)<=u&&n.slice(a.fromB-v,a.fromB)==n.slice(S,a.toB)&&(a=e[s]=a.offset(-v))}}o=a.toA}return od(e,3),e}let Mr;try{Mr=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function sd(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function ad(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?sd(n)?1:0:Mr?!cd(n)||t==e.length-1?Mr.test(String.fromCharCode(n))?1:0:Mr.test(e.slice(t,t+2))?2:0:0}function id(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?sd(n)?1:0:Mr?!dd(n)||t==1?Mr.test(String.fromCharCode(n))?1:0:Mr.test(e.slice(t-2,t))?2:0:0}const ld=8;function ji(e,t,n){if(t==e.length||!id(e,t))return t;for(let o=t,s=t+n,a=0;a<ld;a++){let i=ad(e,o);if(!i||o+i>s)return o;o+=i}return t}function Si(e,t,n){if(!t||!ad(e,t))return t;for(let o=t,s=t-n,a=0;a<ld;a++){let i=id(e,o);if(!i||o-i<s)return o;o-=i}return t}function Ni(e,t,n){for(;t!=n;t--)if(e.charCodeAt(t-1)==10)return t;return-1}function Ci(e,t,n){for(;t!=n;t++)if(e.charCodeAt(t)==10)return t;return-1}const cd=e=>e>=55296&&e<=56319,dd=e=>e>=56320&&e<=57343;function Xr(e,t){return!t||t==e.length||!cd(e.charCodeAt(t-1))||!dd(e.charCodeAt(t))}function Ty(e,t,n){var o;let s=n?.override;return s?s(e,t):(ln=((o=n?.scanLimit)!==null&&o!==void 0?o:1e9)>>1,cn=n?.timeout?Date.now()+n.timeout:0,na=!1,Iy(e,t,Dr(e,0,e.length,t,0,t.length)))}function ud(){return!na}function pd(e,t,n){return _y(Ty(e,t,n),e,t)}const mr=io.define({combine:e=>e[0]}),My=Ms.define(),md=io.define(),Kt=hn.define({create(e){return null},update(e,t){for(let n of t.effects)n.is(My)&&(e=n.value);for(let n of t.state.facet(md))e=n(e,t);return e}});function es(e){let t=e.field(Kt,!1);if(!t)return null;let n=e.facet(mr);return{chunks:t,side:n?n.side:null}}class Hr{constructor(t,n,o,s,a,i=!0){this.changes=t,this.fromA=n,this.toA=o,this.fromB=s,this.toB=a,this.precise=i}offset(t,n){return t||n?new Hr(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,o){let s=pd(t.toString(),n.toString(),o);return fd(s,t,n,0,0,ud())}static updateA(t,n,o,s,a){return Ti(_i(t,s,!0,o.length),t,n,o,a)}static updateB(t,n,o,s,a){return Ti(_i(t,s,!1,n.length),t,n,o,a)}}function Ei(e,t,n,o){let s=n.lineAt(e),a=o.lineAt(t);return s.to==e&&a.to==t&&e<n.length&&t<o.length?[e+1,t+1]:[s.from,a.from]}function Ai(e,t,n,o){let s=n.lineAt(e),a=o.lineAt(t);return s.from==e&&a.from==t?[e,t]:[s.to+1,a.to+1]}function fd(e,t,n,o,s,a){let i=[];for(let c=0;c<e.length;c++){let d=e[c],[u,m]=Ei(d.fromA+o,d.fromB+s,t,n),[p,f]=Ai(d.toA+o,d.toB+s,t,n),g=[d.offset(-u+o,-m+s)];for(;c<e.length-1;){let h=e[c+1],[w,v]=Ei(h.fromA+o,h.fromB+s,t,n);if(w>p+1&&v>f+1)break;g.push(h.offset(-u+o,-m+s)),[p,f]=Ai(h.toA+o,h.toB+s,t,n),c++}i.push(new Hr(g,u,Math.max(u,p),m,Math.max(m,f),a))}return i}const Gn=1e3;function Ii(e,t,n,o){let s=0,a=e.length;for(;;){if(s==a){let m=0,p=0;s&&({toA:m,toB:p}=e[s-1]);let f=t-(n?m:p);return[m+f,p+f]}let i=s+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)s=i+1;else return o?[c.fromA,c.fromB]:[c.toA,c.toB]}}function _i(e,t,n,o){let s=[];return t.iterChangedRanges((a,i,c,d)=>{let u=0,m=n?t.length:o,p=0,f=n?o:t.length;a>Gn&&([u,p]=Ii(e,a-Gn,n,!0)),i<t.length-Gn&&([m,f]=Ii(e,i+Gn,n,!1));let g=d-c-(i-a),h,[w,v]=n?[g,0]:[0,g];s.length&&(h=s[s.length-1]).toA>=u?s[s.length-1]={fromA:h.fromA,fromB:h.fromB,toA:m,toB:f,diffA:h.diffA+w,diffB:h.diffB+v}:s.push({fromA:u,toA:m,fromB:p,toB:f,diffA:w,diffB:v})}),s}function Ti(e,t,n,o,s){if(!e.length)return t;let a=[];for(let i=0,c=0,d=0,u=0;;i++){let m=i==e.length?null:e[i],p=m?m.fromA+c:n.length,f=m?m.fromB+d:o.length;for(;u<t.length;){let v=t[u];if(m&&(v.toA+c>p||v.toB+d>f))break;a.push(v.offset(c,d)),u++}if(!m)break;let g=m.toA+c+m.diffA,h=m.toB+d+m.diffB,w=pd(n.sliceString(p,g),o.sliceString(f,h),s);for(let v of fd(w,n,o,p,f,ud()))a.push(v);for(c+=m.diffA,d+=m.diffB;u<t.length;){let v=t[u];if(v.fromA+c>g&&v.fromB+d>h)break;u++}}return a}const Dy={scanLimit:500},hd=lo.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=Pi(e))}update(e){(e.docChanged||e.viewportChanged||Py(e.startState,e.state)||Ry(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=Pi(e.view))}},{decorations:e=>e.deco});function Py(e,t){return e.field(Kt,!1)!=t.field(Kt,!1)}function Ry(e,t){return e.facet(mr)!=t.facet(mr)}const Mi=fr.line({class:"cm-changedLine"}),gd=fr.mark({class:"cm-changedText"}),Ly=fr.mark({tagName:"ins",class:"cm-insertedLine"}),Oy=fr.mark({tagName:"del",class:"cm-deletedLine"}),Di=new class extends Ds{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Fy(e,t,n,o,s,a){let i=n?e.fromA:e.fromB,c=n?e.toA:e.toB,d=0;if(i!=c){s.add(i,i,Mi),s.add(i,c,n?Oy:Ly),a&&a.add(i,i,Di);for(let u=t.iterRange(i,c-1),m=i;!u.next().done;){if(u.lineBreak){m++,s.add(m,m,Mi),a&&a.add(m,m,Di);continue}let p=m+u.value.length;if(o)for(;d<e.changes.length;){let f=e.changes[d],g=i+(n?f.fromA:f.fromB),h=i+(n?f.toA:f.toB),w=Math.max(m,g),v=Math.min(p,h);if(w<v&&s.add(w,v,gd),h<p)d++;else break}m=p}}}function Pi(e){let t=e.state.field(Kt),{side:n,highlightChanges:o,markGutter:s,overrideChunk:a}=e.state.facet(mr),i=n=="a",c=new Jn,d=s?new Jn:null,{from:u,to:m}=e.viewport;for(let p of t){if((i?p.fromA:p.fromB)>=m)break;(i?p.toA:p.toB)>u&&(!a||!a(e.state,p,c,d))&&Fy(p,e.state.doc,i,o,c,d)}return{deco:c.finish(),gutter:d&&d.finish()}}const _s=Ms.define({map:(e,t)=>t.mapPos(e)});class $y extends Ps{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",o=>{let s=t.posAtDOM(o.target);t.dispatch({effects:_s.of(s)});let{side:a,sibling:i}=t.state.facet(mr);i&&i().dispatch({effects:_s.of(By(s,t.state.field(Kt),a=="a"))})}),n}ignoreEvent(t){return t instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function By(e,t,n){let o=0,s=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(n?i.fromA:i.fromB)>=e)return s+(e-o);[o,s]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const zy=hn.define({create(e){return fr.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(_s)&&(e=e.update({filter:o=>o!=n.value}));return e},provide:e=>Xt.decorations.from(e)});function Uy({margin:e=3,minSize:t=4}){return zy.init(n=>Wy(n,e,t))}function Wy(e,t,n){let o=new Jn,s=e.facet(mr).side=="a",a=e.field(Kt),i=1;for(let c=0;;c++){let d=c<a.length?a[c]:null,u=c?i+t:1,m=d?e.doc.lineAt(s?d.fromA:d.fromB).number-1-t:e.doc.lines,p=m-u+1;if(p>=n&&o.add(e.doc.line(u).from,e.doc.line(m).to,fr.replace({widget:new $y(p),block:!0})),!d)break;i=e.doc.lineAt(Math.min(e.doc.length,s?d.toA:d.toB)).number}return o.finish()}const Hy=Xt.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"}}),qy=new class extends Ds{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Ky=Gi.low(cu({class:"cm-changeGutter",markers:e=>{var t;return((t=e.plugin(hd))===null||t===void 0?void 0:t.gutter)||uu.empty},widgetMarker:(e,t)=>t instanceof xd?qy:null}));function Gy(e){var t;let n=typeof e.original=="string"?Ki.of(e.original.split(/\r?\n/)):e.original,o=e.diffConfig||Dy;return[Gi.low(hd),Xy,Hy,Xt.editorAttributes.of({class:"cm-merge-b"}),md.of((s,a)=>{let i=a.effects.find(c=>c.is(aa));return i&&(s=Hr.updateA(s,i.value.doc,a.startState.doc,i.value.changes,o)),a.docChanged&&(s=Hr.updateB(s,a.state.field(Qr),a.newDoc,a.changes,o)),s}),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?tv:void 0,side:"b"}),Qr.init(()=>n),e.gutter!==!1?Ky:[],e.collapseUnchanged?Uy(e.collapseUnchanged):[],Kt.init(s=>Hr.build(n,s.doc,o))]}const aa=Ms.define(),Qr=hn.define({create:()=>Ki.empty,update(e,t){for(let n of t.effects)n.is(aa)&&(e=n.value.doc);return e}}),Ri=new WeakMap;class xd extends Ps{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 Vy(e,t,n){let o=Ri.get(t.changes);if(o)return o;let s=i=>{let{highlightChanges:c,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:u,mergeControls:m}=e.facet(mr),p=document.createElement("div");if(p.className="cm-deletedChunk",m){let B=p.appendChild(document.createElement("div"));B.className="cm-chunkButtons";let E=I=>{I.preventDefault(),Jy(i,i.posAtDOM(p))},y=I=>{I.preventDefault(),Yy(i,i.posAtDOM(p))};if(typeof m=="function")B.appendChild(m("accept",E)),B.appendChild(m("reject",y));else{let I=B.appendChild(document.createElement("button"));I.name="accept",I.textContent=e.phrase("Accept"),I.onmousedown=E;let $=B.appendChild(document.createElement("button"));$.name="reject",$.textContent=e.phrase("Reject"),$.onmousedown=y}}if(n||t.fromA>=t.toA)return p;let f=i.state.field(Qr).sliceString(t.fromA,t.endA),g=d&&e.facet(Vi),h=L(),w=t.changes,v=0,S=!1;function L(){let B=p.appendChild(document.createElement("div"));return B.className="cm-deletedLine",B.appendChild(document.createElement("del"))}function k(B,E,y){for(let I=B;I<E;){if(f.charAt(I)==`
|
|
54
|
+
`){h.firstChild||h.appendChild(document.createElement("br")),h=L(),I++;continue}let $=E,_=y+(S?" cm-deletedText":""),H=!1,le=f.indexOf(`
|
|
55
|
+
`,I);if(le>-1&&le<E&&($=le),c&&v<w.length){let se=Math.max(0,S?w[v].toA:w[v].fromA);se<=$&&($=se,S&&v++,H=!0)}if($>I){let se=document.createTextNode(f.slice(I,$));if(_){let W=h.appendChild(document.createElement("span"));W.className=_,W.appendChild(se)}else h.appendChild(se);I=$}H&&(S=!S)}}if(g&&t.toA-t.fromA<=u){let B=g.parser.parse(f),E=0;os(B,{style:y=>Ji(e,y)},(y,I,$)=>{y>E&&k(E,y,""),k(y,I,$),E=I}),k(E,f.length,"")}else k(0,f.length,"");return h.firstChild||h.appendChild(document.createElement("br")),p},a=fr.widget({block:!0,side:-1,widget:new xd(s)});return Ri.set(t.changes,a),a}function Jy(e,t){let{state:n}=e,o=t??n.selection.main.head,s=e.state.field(Kt).find(d=>d.fromB<=o&&d.endB>=o);if(!s)return!1;let a=e.state.sliceDoc(s.fromB,Math.max(s.fromB,s.toB-1)),i=e.state.field(Qr);s.fromB!=s.toB&&s.toA<=i.length&&(a+=e.state.lineBreak);let c=du.of({from:s.fromA,to:Math.min(i.length,s.toA),insert:a},i.length);return e.dispatch({effects:aa.of({doc:c.apply(i),changes:c}),userEvent:"accept"}),!0}function Yy(e,t){let{state:n}=e,o=t??n.selection.main.head,s=n.field(Kt).find(c=>c.fromB<=o&&c.endB>=o);if(!s)return!1;let i=n.field(Qr).sliceString(s.fromA,Math.max(s.fromA,s.toA-1));return s.fromA!=s.toA&&s.toB<=n.doc.length&&(i+=n.lineBreak),e.dispatch({changes:{from:s.fromB,to:Math.min(n.doc.length,s.toB),insert:i},userEvent:"revert"}),!0}function Li(e){let t=new Jn;for(let n of e.field(Kt)){let o=e.facet(mr).overrideChunk&&yd(e,n);t.add(n.fromB,n.fromB,Vy(e,n,!!o))}return t.finish()}const Xy=hn.define({create:e=>Li(e),update(e,t){return t.state.field(Kt,!1)!=t.startState.field(Kt,!1)?Li(t.state):e},provide:e=>Xt.decorations.from(e)}),Oi=new WeakMap;function yd(e,t){let n=Oi.get(t);if(n!==void 0)return n;n=null;let o=e.field(Qr),s=e.doc,a=o.lineAt(t.endA).number-o.lineAt(t.fromA).number+1,i=s.lineAt(t.endB).number-s.lineAt(t.fromB).number+1;e:if(a==i&&a<10){let c=[],d=0,u=t.fromA,m=t.fromB;for(let p of t.changes){if(p.fromA<p.toA){d+=p.toA-p.fromA;let f=o.sliceString(u+p.fromA,u+p.toA);if(/\n/.test(f))break e;c.push(fr.widget({widget:new Qy(f),side:-1}).range(m+p.fromB))}p.fromB<p.toB&&c.push(gd.range(m+p.fromB,m+p.toB))}d<t.endA-t.fromA-a*2&&(n=c)}return Oi.set(t,n),n}class Qy extends Ps{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 Zy=new class extends Ds{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},ev=fr.line({class:"cm-inlineChangedLine"});function tv(e,t,n,o){let s=yd(e,t),a=0;if(!s)return!1;for(let i=e.doc.lineAt(t.fromB);;){for(o&&o.add(i.from,i.from,Zy),n.add(i.from,i.from,ev);a<s.length&&s[a].to<=i.to;){let c=s[a++];n.add(c.from,c.to,c.value)}if(i.to>=t.endB)break;i=e.doc.lineAt(i.to+1)}return!0}var rv=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]]);return n};const Lt=io.define({combine:e=>{const t=[];for(let n of e){if(!n)continue;const{create:o,gutters:s}=n,a=rv(n,["create","gutters"]);t.push(Object.assign(Object.assign({},a),{enabled:!0,gutters:s?s.filter(i=>Object.keys(i).length>0):void 0}))}return pu(t,{enabled:t.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),Bt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},nv=Xt.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"}}}}),yr=Bt.PixelMultiplier*Bt.SizeRatio,ov=lo.fromClass(class{constructor(e){this.view=e,this._isDragging=!1,e.state.facet(Lt).enabled&&this.create(e)}create(e){this.container=qr("div",{class:"cm-minimap-overlay-container"}),this.dom=qr("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(Lt).enabled,n=e.state.facet(Lt).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/yr;this.dom.style.height=e+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:e,scrollHeight:t,scrollTop:n}=this.view.scrollDOM,o=t-e,s=n/yr,a=e/yr,i=e-a;let c=n/o;isNaN(c)&&(c=0);const d=i*c,u=Math.min(d,s);this.dom.style.top=u+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:e}=this.view.state.facet(Lt);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:o,scrollHeight:s,scrollTop:a}=this.view.scrollDOM,i=n.getBoundingClientRect().top,c=(t-i)*yr,d=a/(s-o),m=(o*yr-o)*d,p=Math.max(0,a-m);this.view.scrollDOM.scrollTop=p+c-o/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,o=t>0;this._dragStartY=e.clientY;const s=this.dom.getBoundingClientRect().height,a=this.dom.getBoundingClientRect().y,i=a+s,c=parseFloat(this.dom.style.top),d=this.view.scrollDOM.scrollTop,u=this.view.scrollDOM.clientHeight,m=this.view.scrollDOM.scrollHeight,p=d===0,f=Math.round(d)>=Math.round(m-u);if(p&&n||p&&e.clientY<a||f&&o||f&&e.clientY>i)return;const g=this.view.scrollDOM.scrollHeight,h=this.view.scrollDOM.clientHeight,w=(g-h)/yr,v=h-h/yr,S=c+t,L=S/v,k=(g-h)*L,B=S*yr;this.view.scrollDOM.scrollTop=Math.max(k,B);const E=Math.min(Math.max(0,S),Math.min(v,w));this.dom.style.top=E+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),sv=[nv,ov];class ia{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 Fi(e){var t;if(!e.facet(Lt).enabled)return[];const n=[],o=e.doc.iterLines(),s=hu(e).iter();let a=0;for(o.next();!o.done;){const i=o.value;let c=a,d=c+i.length;for(;s.value&&s.to<c;)s.next();const{from:u,to:m}=s,p=c>=u&&c<m,f=d>u&&d<=m;if(p){let g=(t=n.pop())!==null&&t!==void 0?t:[],h=g.pop();h&&h.folded&&(h.to=m),h&&g.push(h),(!h||!h.folded)&&g.push({from:u,to:m,folded:!0}),f||g.push({from:m,to:d,folded:!1}),n.push(g)}else f?n.push([{from:c,to:u,folded:!1},{from:u,to:m,folded:!0}]):n.push([{from:c,to:d,folded:!1}]);a=d+1,o.next()}return n}const Zr=hn.define({create:e=>Fi(e),update:(e,t)=>So([t])||t.docChanged?Fi(t.state):e});function So(e){return e.find(t=>t.effects.find(n=>n.is(mu)||n.is(fu)))}class av extends ia{constructor(t){super(t),this.count=void 0}shouldUpdate(t){if(!t.state.facet(Lt).enabled)return!1;if(t.docChanged)return!0;for(const n of t.transactions)for(const o of n.effects)if(o.is(gu))return!0;return!!(So(t.transactions)||this.count===void 0)}update(t){if(!this.shouldUpdate(t))return;this.map.clear();const n=t.state.field(Zr);this.count=xu(t.state),yu(t.state,(o,s,a)=>{const i=this.findLine(s,n),c=this.findLine(a,n);let d=o.severity;for(let u=i;u<=c;u++){const m=this.get(u);m&&(d=[d,m].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(u,d)}})}drawLine(t,n){const{context:o,lineHeight:s,offsetX:a,offsetY:i}=t,c=this.get(n);c&&(o.globalAlpha=.65,o.beginPath(),o.rect(a,i,o.canvas.width-a,s),o.fillStyle=this.color(c),o.fill())}findLine(t,n){return n.findIndex(s=>{const a=s.slice(0,1)[0],i=s.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 iv(e){return new av(e)}class lv extends ia{constructor(t){super(t),this.getDrawInfo(),this._themeClasses=t.dom.classList.value}shouldUpdate(t){return t.state.facet(Lt).enabled?!!(t.docChanged||t.selectionSet||this._themeClasses!==this.view.dom.classList.value||So(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 o=0;for(const[s,a]of t.state.field(Zr).entries()){const i=[];let c=0;for(const u of a){do{if(o>=n.length||u.to<n[o].from)continue;if(n[o].from===n[o].to){o++;continue}const m=n[o],p={from:c+Math.max(u.from,m.from)-u.from,to:c+Math.min(u.to,m.to)-u.from,extends:m.to>u.to},f=i.slice(-1)[0];if(f&&f.to===p.from){let{to:g}=p;u.folded&&p.extends?g=p.from+1:u.folded&&!p.extends&&(g=f.to),i[i.length-1]=Object.assign(Object.assign({},f),{to:g,extends:p.extends})}else u.folded||i.push(p);if(p.extends)break;o++}while(o<n.length&&u.to>=n[o].from);c+=u.folded?1:u.to-u.from}if(i.length===0)continue;const d=s+1;this.map.set(d,i)}}drawLine(t,n){let{context:o,lineHeight:s,charWidth:a,offsetX:i,offsetY:c}=t;const d=this.get(n);if(d)for(const u of d){const m=i+u.from*a,p=(u.to-u.from)*a,f=o.canvas.width-m;u.extends&&(o.globalAlpha=.65,o.beginPath(),o.rect(m,c,f,s),o.fillStyle=this.getDrawInfo().backgroundColor,o.fill()),o.globalAlpha=1,o.beginPath(),o.rect(m,c,p,s),o.fillStyle=this.getDrawInfo().backgroundColor,o.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const t=document.createElement("span");t.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(t);const o={backgroundColor:window.getComputedStyle(t).backgroundColor};return this._drawInfo=o,this.view.dom.removeChild(t),o}}function cv(e){return new lv(e)}class dv extends ia{constructor(t){super(t),this._fontInfoMap=new Map,this._themeClasses=new Set(t.dom.classList.values()),t.state.facet(Lt).enabled&&this.updateImpl(t.state)}shouldUpdate(t){return!!(t.docChanged||t.state.facet(Lt)!==t.startState.facet(Lt)||this.themeChanged()||So(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 o;this.map.clear(),this._displayText=t.facet(Lt).displayText,this.themeChanged()&&this._fontInfoMap.clear();let s;if(this._previousTree&&n){const p=wa.addTree(this._previousTree),f=[];n.iterChangedRanges((g,h,w,v)=>f.push({fromA:g,toA:h,fromB:w,toB:v})),s=wa.applyChanges(p,f)}const a=t.doc.toString(),i=(o=t.facet(Vi))===null||o===void 0?void 0:o.parser,c=i?i.parse(a,s):void 0;this._previousTree=c;const d={style:p=>Ji(t,p)};let u=[];if(c){const p=t.doc.lineAt(this.view.viewport.from).number,f=t.doc.lineAt(this.view.viewport.to).number,g=f-p,h=p/(t.doc.lines-g),{SizeRatio:w,PixelMultiplier:v}=Bt,S=g*w*v,L=h*S,k=Math.max(1,Math.floor(p-L)),B=Math.min(f+Math.floor(S-L),t.doc.lines);os(c,d,(E,y,I)=>{u.push({from:E,to:y,tags:I})},t.doc.line(k).from,t.doc.line(B).to)}this.updateMapImpl(t,u),u=[];const m=()=>{c&&(os(c,d,(p,f,g)=>{u.push({from:p,to:f,tags:g})}),this.updateMapImpl(t,u),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(m):setTimeout(m)}updateMapImpl(t,n){this.map.clear();const o=t.doc.toString(),s=n.values();let a=s.next();for(const[i,c]of t.field(Zr).entries()){const d=[];for(const m of c){if(m.from===m.to)continue;if(m.folded){d.push({text:"…",tags:""});continue}let p=m.from;for(;!a.done&&a.value.from<m.to;){const{from:f,to:g,tags:h}=a.value;if(g<p){a=s.next();continue}f>p&&d.push({text:o.slice(p,f),tags:""});const w=Math.max(f,m.from),v=Math.min(g,m.to);if(d.push({text:o.slice(w,v),tags:h}),p=v,g>v)break;a=s.next()}p!==m.to&&d.push({text:o.slice(p,m.to),tags:""})}const u=i+1;this.map.set(u,d)}}measure(t){const{color:n,font:o,lineHeight:s}=this.getFontInfo("");return t.textBaseline="ideographic",t.fillStyle=n,t.font=o,{charWidth:t.measureText("_").width,lineHeight:s}}beforeDraw(){this._fontInfoMap.clear()}drawLine(t,n){const o=this.get(n);if(!o)return;let{context:s,charWidth:a,lineHeight:i,offsetX:c,offsetY:d}=t,u;s.textBaseline="ideographic";for(const m of o){const p=this.getFontInfo(m.tags);switch((!u||u.color!==p.color)&&(s.fillStyle=p.color),(!u||u.font!==p.font)&&(s.font=p.font),u=p,i=Math.max(i,p.lineHeight),this._displayText){case"characters":{s.fillText(m.text,c,d+i),c+=m.text.length*a;break}case"blocks":{const f=/\S+/g;let g;for(;(g=f.exec(m.text))!==null;){const h=c+g.index*a;let w=(f.lastIndex-g.index)*a;if(h>s.canvas.width)break;h+w>s.canvas.width&&(w=s.canvas.width-h);const v=2/Bt.SizeRatio,S=i-v;s.fillStyle=p.color,s.globalAlpha=.65,s.beginPath(),s.rect(h,d,w,S),s.fill()}c+=m.text.length*a;break}}}}getFontInfo(t){const n=this._fontInfoMap.get(t);if(n)return n;const o=qr("span",{class:t}),s=qr("div",{class:"cm-line",style:"display: none"},o);this.view.contentDOM.appendChild(s);const a=window.getComputedStyle(o),i=parseFloat(a.lineHeight)/Bt.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(s),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 o=!0;return t.forEach(s=>{n.has(s)||(o=!1)}),!o}}function uv(e){return new dv(e)}const vd=4;function pv(e,t,n){const o=e[n];o&&(t.context.fillStyle=o,t.context.globalAlpha=1,t.context.beginPath(),t.context.rect(t.offsetX,t.offsetY,vd,t.lineHeight),t.context.fill())}const mv=Xt.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"}}),$i=6,fv=lo.fromClass(class{constructor(e){this.view=e,this.text=uv(e),this.selection=cv(e),this.diagnostic=iv(e),e.state.facet(dn)&&this.create(e)}create(e){const t=e.state.facet(dn);if(!t)throw Error("Expected nonnull");this.inner=qr("div",{class:"cm-minimap-inner"}),this.canvas=qr("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(Lt).eventHandlers){const o=this.view.state.facet(Lt).eventHandlers[n];o&&this.dom.addEventListener(n,s=>o(s,this.view))}}remove(){this.dom&&this.dom.remove()}update(e){const t=e.startState.facet(dn),n=e.state.facet(dn);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<=Bt.MaxWidth*$i){const t=e/(Bt.MaxWidth*$i);return Bt.MaxWidth*t}return Bt.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()*Bt.PixelMultiplier;const e=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=e+"px",this.canvas.height=e*Bt.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:o}=this.text.measure(t);let{startIndex:s,endIndex:a,offsetY:i}=this.canvasStartAndEndIndex(t,o);const c=this.view.state.facet(Lt).gutters;for(let d=s;d<a;d++){const u=this.view.state.field(Zr);if(d>=u.length)break;const m={offsetX:0,offsetY:i,context:t,lineHeight:o,charWidth:n};if(c.length){m.offsetX+=2;for(let p of c)pv(p,m,d+1),m.offsetX+=vd;m.offsetX+=2}this.text.drawLine(m,d+1),this.selection.drawLine(m,d+1),this.diagnostic.drawLine(m,d+1),i+=o}t.restore()}canvasStartAndEndIndex(e,t){let{top:n,bottom:o}=this.view.documentPadding;n/=Bt.SizeRatio,o/=Bt.SizeRatio;const s=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(Zr).length,m=n+o+u*t,p=Math.max(0,d*(m-s)),f=Math.max(0,n-p),g=Math.round(Math.max(0,p-n)/t),h=Math.round((s-f)/t);return{startIndex:g,endIndex:g+h,offsetY:f}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:e,scrollWidth:t,scrollLeft:n}=this.view.scrollDOM;e+n<t?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:e=>Xt.scrollMargins.of(t=>{var n;const o=(n=t.plugin(e))===null||n===void 0?void 0:n.getWidth();return o?{right:o}:null})}),dn=io.define({combine:e=>{var t;return(t=e.find(n=>n!==null))!==null&&t!==void 0?t:null},enables:e=>[[Lt.compute([e],t=>t.facet(e)),mv,Zr,fv,sv]]});function Bi({file:e,onClose:t,projectPath:n,isSidebar:o=!1,isExpanded:s=!1,onToggleExpand:a=null}){const{t:i}=kt("codeEditor"),[c,d]=l.useState(""),[u,m]=l.useState(!0),[p,f]=l.useState(!1),[g,h]=l.useState(!1),[w,v]=l.useState(()=>{const P=localStorage.getItem("codeEditorTheme");return P?P==="dark":!0}),[S,L]=l.useState(!1),[k,B]=l.useState(!!e.diffInfo),[E,y]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[I,$]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[_,H]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[le,se]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),W=l.useRef(null),Q=l.useMemo(()=>{if(!e.diffInfo||!k||!I)return[];const P={};return[dn.compute(["doc"],j=>{const ne=es(j)?.chunks||[];return Object.keys(P).forEach(ge=>delete P[ge]),ne.forEach(ge=>{const Se=j.doc.lineAt(ge.fromB).number,A=j.doc.lineAt(Math.min(ge.toB,j.doc.length)).number;for(let ee=Se;ee<=A;ee++)P[ee]=w?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[P]}})]},[e.diffInfo,k,I,w]),ce=l.useMemo(()=>!e.diffInfo||!k?[]:[lo.fromClass(class{constructor(P){setTimeout(()=>{const T=es(P.state)?.chunks||[];if(T.length>0){const ne=T[0];P.dispatch({effects:Xt.scrollIntoView(ne.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[e.diffInfo,k]),he=l.useMemo(()=>{const P=j=>{const T=document.createElement("div");T.className="cm-editor-toolbar-panel";let ne=0;const ge=()=>{const Se=e.diffInfo&&k,ee=(Se?es(j.state):null)?.chunks||[],Ae=ee.length;let ye='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(ye+='<div style="display: flex; align-items: center; gap: 8px;">',Se&&(ye+=`
|
|
56
|
+
<span style="font-weight: 500;">${Ae>0?`${ne+1}/${Ae}`:"0"} ${i("toolbar.changes")}</span>
|
|
57
|
+
<button class="cm-diff-nav-btn cm-diff-nav-prev" title="${i("toolbar.previousChange")}" ${Ae===0?"disabled":""}>
|
|
58
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
59
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
|
|
60
|
+
</svg>
|
|
61
|
+
</button>
|
|
62
|
+
<button class="cm-diff-nav-btn cm-diff-nav-next" title="${i("toolbar.nextChange")}" ${Ae===0?"disabled":""}>
|
|
63
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
64
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
65
|
+
</svg>
|
|
66
|
+
</button>
|
|
67
|
+
`),ye+="</div>",ye+='<div style="display: flex; align-items: center; gap: 4px;">',e.diffInfo&&(ye+=`
|
|
68
|
+
<button class="cm-toolbar-btn cm-toggle-diff-btn" title="${i(k?"toolbar.hideDiff":"toolbar.showDiff")}">
|
|
69
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
70
|
+
${k?'<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" />'}
|
|
71
|
+
</svg>
|
|
72
|
+
</button>
|
|
73
|
+
`),ye+=`
|
|
74
|
+
<button class="cm-toolbar-btn cm-settings-btn" title="${i("toolbar.settings")}">
|
|
75
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
76
|
+
<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" />
|
|
77
|
+
</svg>
|
|
78
|
+
</button>
|
|
79
|
+
`,o&&a&&(ye+=`
|
|
80
|
+
<button class="cm-toolbar-btn cm-expand-btn" title="${i(s?"toolbar.collapse":"toolbar.expand")}">
|
|
81
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
82
|
+
${s?'<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" />'}
|
|
83
|
+
</svg>
|
|
84
|
+
</button>
|
|
85
|
+
`),ye+="</div>",ye+="</div>",T.innerHTML=ye,Se){const Ke=T.querySelector(".cm-diff-nav-prev"),we=T.querySelector(".cm-diff-nav-next");Ke?.addEventListener("click",()=>{if(ee.length===0)return;ne=ne>0?ne-1:ee.length-1;const Le=ee[ne];Le&&j.dispatch({effects:Xt.scrollIntoView(Le.fromB,{y:"center"})}),ge()}),we?.addEventListener("click",()=>{if(ee.length===0)return;ne=ne<ee.length-1?ne+1:0;const Le=ee[ne];Le&&j.dispatch({effects:Xt.scrollIntoView(Le.fromB,{y:"center"})}),ge()})}e.diffInfo&&T.querySelector(".cm-toggle-diff-btn")?.addEventListener("click",()=>{B(!k)}),T.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),o&&a&&T.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{a()})};return ge(),{top:!0,dom:T,update:ge}};return[vu.of(P)]},[e.diffInfo,k,o,s,a]),be=P=>{const j=P.split(".").pop()?.toLowerCase();switch(j){case"js":case"jsx":case"ts":case"tsx":return[Eu({jsx:!0,typescript:j.includes("ts")})];case"py":return[Cu()];case"html":case"htm":return[Nu()];case"css":case"scss":case"less":return[Su()];case"json":return[ju()];case"md":case"markdown":return[ku()];default:return[]}};l.useEffect(()=>{(async()=>{try{if(m(!0),e.diffInfo&&e.diffInfo.new_string!==void 0&&e.diffInfo.old_string!==void 0){d(e.diffInfo.new_string),m(!1);return}const j=await xt.readFile(e.projectName,e.path);if(!j.ok)throw new Error(`Failed to load file: ${j.status} ${j.statusText}`);const T=await j.json();d(T.content)}catch(j){console.error("Error loading file:",j),d(`// Error loading file: ${j.message}
|
|
86
|
+
// File: ${e.name}
|
|
87
|
+
// Path: ${e.path}`)}finally{m(!1)}})()},[e,n]);const pe=async()=>{f(!0);try{console.log("Saving file:",{projectName:e.projectName,path:e.path,contentLength:c?.length});const P=await xt.saveFile(e.projectName,e.path,c);if(console.log("Save response:",{status:P.status,ok:P.ok,contentType:P.headers.get("content-type")}),!P.ok){const T=P.headers.get("content-type");if(T&&T.includes("application/json")){const ne=await P.json();throw new Error(ne.error||`Save failed: ${P.status}`)}else{const ne=await P.text();throw console.error("Non-JSON error response:",ne),new Error(`Save failed: ${P.status} ${P.statusText}`)}}const j=await P.json();console.log("Save successful:",j),L(!0),setTimeout(()=>L(!1),2e3)}catch(P){console.error("Error saving file:",P),alert(`Error saving file: ${P.message}`)}finally{f(!1)}},K=()=>{const P=new Blob([c],{type:"text/plain"}),j=URL.createObjectURL(P),T=document.createElement("a");T.href=j,T.download=e.name,document.body.appendChild(T),T.click(),document.body.removeChild(T),URL.revokeObjectURL(j)},De=()=>{h(!g)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",w?"dark":"light")},[w]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",E.toString())},[E]),l.useEffect(()=>{const P=()=>{const j=localStorage.getItem("codeEditorTheme");j&&v(j==="dark");const T=localStorage.getItem("codeEditorWordWrap");T!==null&&y(T==="true");const ne=localStorage.getItem("codeEditorShowMinimap");ne!==null&&$(ne!=="false");const ge=localStorage.getItem("codeEditorLineNumbers");ge!==null&&H(ge!=="false");const Se=localStorage.getItem("codeEditorFontSize");Se&&se(Se)};return window.addEventListener("storage",P),window.addEventListener("codeEditorSettingsChanged",P),()=>{window.removeEventListener("storage",P),window.removeEventListener("codeEditorSettingsChanged",P)}},[]),l.useEffect(()=>{const P=j=>{(j.ctrlKey||j.metaKey)&&(j.key==="s"?(j.preventDefault(),pe()):j.key==="Escape"&&(j.preventDefault(),t()))};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[c]),u?r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
88
|
+
.code-editor-loading {
|
|
89
|
+
background-color: ${w?"#111827":"#ffffff"} !important;
|
|
90
|
+
}
|
|
91
|
+
.code-editor-loading:hover {
|
|
92
|
+
background-color: ${w?"#111827":"#ffffff"} !important;
|
|
93
|
+
}
|
|
94
|
+
`}),o?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:`
|
|
95
|
+
/* Light background for full line changes */
|
|
96
|
+
.cm-deletedChunk {
|
|
97
|
+
background-color: ${w?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
|
|
98
|
+
border-left: 3px solid ${w?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
|
|
99
|
+
padding-left: 4px !important;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.cm-insertedChunk {
|
|
103
|
+
background-color: ${w?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
|
|
104
|
+
border-left: 3px solid ${w?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
|
|
105
|
+
padding-left: 4px !important;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Override linear-gradient underline and use solid darker background for partial changes */
|
|
109
|
+
.cm-editor.cm-merge-b .cm-changedText {
|
|
110
|
+
background: ${w?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
|
|
111
|
+
padding-top: 2px !important;
|
|
112
|
+
padding-bottom: 2px !important;
|
|
113
|
+
margin-top: -2px !important;
|
|
114
|
+
margin-bottom: -2px !important;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.cm-editor .cm-deletedChunk .cm-changedText {
|
|
118
|
+
background: ${w?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
|
|
119
|
+
padding-top: 2px !important;
|
|
120
|
+
padding-bottom: 2px !important;
|
|
121
|
+
margin-top: -2px !important;
|
|
122
|
+
margin-bottom: -2px !important;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Minimap gutter styling */
|
|
126
|
+
.cm-gutter.cm-gutter-minimap {
|
|
127
|
+
background-color: ${w?"#1e1e1e":"#f5f5f5"};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Editor toolbar panel styling */
|
|
131
|
+
.cm-editor-toolbar-panel {
|
|
132
|
+
padding: 8px 12px;
|
|
133
|
+
background-color: ${w?"#1f2937":"#ffffff"};
|
|
134
|
+
border-bottom: 1px solid ${w?"#374151":"#e5e7eb"};
|
|
135
|
+
color: ${w?"#d1d5db":"#374151"};
|
|
136
|
+
font-size: 14px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.cm-diff-nav-btn,
|
|
140
|
+
.cm-toolbar-btn {
|
|
141
|
+
padding: 4px;
|
|
142
|
+
background: transparent;
|
|
143
|
+
border: none;
|
|
144
|
+
cursor: pointer;
|
|
145
|
+
border-radius: 4px;
|
|
146
|
+
display: inline-flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
justify-content: center;
|
|
149
|
+
color: inherit;
|
|
150
|
+
transition: background-color 0.2s;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.cm-diff-nav-btn:hover,
|
|
154
|
+
.cm-toolbar-btn:hover {
|
|
155
|
+
background-color: ${w?"#374151":"#f3f4f6"};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.cm-diff-nav-btn:disabled {
|
|
159
|
+
opacity: 0.5;
|
|
160
|
+
cursor: not-allowed;
|
|
161
|
+
}
|
|
162
|
+
`}),r.jsx("div",{className:o?"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:o?"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:K,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(as,{className:"w-5 h-5 md:w-4 md:h-4"})}),r.jsx("button",{onClick:pe,disabled:p,className:`px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors min-h-[44px] md:min-h-0 ${S?"bg-green-600 hover:bg-green-700":"bg-primary hover:bg-primary/90"}`,children:S?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(dm,{className:"w-5 h-5 md:w-4 md:h-4"}),r.jsx("span",{className:"hidden sm:inline",children:i(p?"actions.saving":"actions.save")})]})}),!o&&r.jsx("button",{onClick:De,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(nm,{className:"w-4 h-4"}):r.jsx(sl,{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(Wt,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(bu,{ref:W,value:c,onChange:d,extensions:[...be(e.name),...he,...e.diffInfo&&k&&e.diffInfo.old_string!==void 0?[Gy({original:e.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...Q,...ce]:[],...E?[Xt.lineWrapping]:[]],theme:w?wu:void 0,height:"100%",style:{fontSize:`${le}px`,height:"100%"},basicSetup:{lineNumbers:_,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(`
|
|
163
|
+
`).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 hv=xp(),gv=yp(),xv=vp(),ts={exports:{}},zi;function yv(){return zi||(zi=1,(function(e,t){(function(n,o){e.exports=o()})(self,(()=>(()=>{var n={6:(i,c)=>{function d(m){try{const p=new URL(m),f=p.password&&p.username?`${p.protocol}//${p.username}:${p.password}@${p.host}`:p.username?`${p.protocol}//${p.username}@${p.host}`:`${p.protocol}//${p.host}`;return m.toLocaleLowerCase().startsWith(f.toLocaleLowerCase())}catch{return!1}}Object.defineProperty(c,"__esModule",{value:!0}),c.LinkComputer=c.WebLinkProvider=void 0,c.WebLinkProvider=class{constructor(m,p,f,g={}){this._terminal=m,this._regex=p,this._handler=f,this._options=g}provideLinks(m,p){const f=u.computeLink(m,this._regex,this._terminal,this._handler);p(this._addCallbacks(f))}_addCallbacks(m){return m.map((p=>(p.leave=this._options.leave,p.hover=(f,g)=>{if(this._options.hover){const{range:h}=p;this._options.hover(f,g,h)}},p)))}};class u{static computeLink(p,f,g,h){const w=new RegExp(f.source,(f.flags||"")+"g"),[v,S]=u._getWindowedLineStrings(p-1,g),L=v.join("");let k;const B=[];for(;k=w.exec(L);){const E=k[0];if(!d(E))continue;const[y,I]=u._mapStrIdx(g,S,0,k.index),[$,_]=u._mapStrIdx(g,y,I,E.length);if(y===-1||I===-1||$===-1||_===-1)continue;const H={start:{x:I+1,y:y+1},end:{x:_,y:$+1}};B.push({range:H,text:E,activate:h})}return B}static _getWindowedLineStrings(p,f){let g,h=p,w=p,v=0,S="";const L=[];if(g=f.buffer.active.getLine(p)){const k=g.translateToString(!0);if(g.isWrapped&&k[0]!==" "){for(v=0;(g=f.buffer.active.getLine(--h))&&v<2048&&(S=g.translateToString(!0),v+=S.length,L.push(S),g.isWrapped&&S.indexOf(" ")===-1););L.reverse()}for(L.push(k),v=0;(g=f.buffer.active.getLine(++w))&&g.isWrapped&&v<2048&&(S=g.translateToString(!0),v+=S.length,L.push(S),S.indexOf(" ")===-1););}return[L,h]}static _mapStrIdx(p,f,g,h){const w=p.buffer.active,v=w.getNullCell();let S=g;for(;h;){const L=w.getLine(f);if(!L)return[-1,-1];for(let k=S;k<L.length;++k){L.getCell(k,v);const B=v.getChars();if(v.getWidth()&&(h-=B.length||1,k===L.length-1&&B==="")){const E=w.getLine(f+1);E&&E.isWrapped&&(E.getCell(0,v),v.getWidth()===2&&(h+=1))}if(h<0)return[f,k]}f++,S=0}return[f,S]}}c.LinkComputer=u}},o={};function s(i){var c=o[i];if(c!==void 0)return c.exports;var d=o[i]={exports:{}};return n[i](d,d.exports,s),d.exports}var a={};return(()=>{var i=a;Object.defineProperty(i,"__esModule",{value:!0}),i.WebLinksAddon=void 0;const c=s(6),d=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function u(m,p){const f=window.open();if(f){try{f.opener=null}catch{}f.location.href=p}else console.warn("Opening link blocked as opener could not be cleared")}i.WebLinksAddon=class{constructor(m=u,p={}){this._handler=m,this._options=p}activate(m){this._terminal=m;const p=this._options,f=p.urlRegex||d;this._linkProvider=this._terminal.registerLinkProvider(new c.WebLinkProvider(this._terminal,f,this._handler,p))}dispose(){this._linkProvider?.dispose()}}})(),a})()))})(ts)),ts.exports}var vv=yv();const bv=`
|
|
164
|
+
.xterm .xterm-screen {
|
|
165
|
+
outline: none !important;
|
|
166
|
+
}
|
|
167
|
+
.xterm:focus .xterm-screen {
|
|
168
|
+
outline: none !important;
|
|
169
|
+
}
|
|
170
|
+
.xterm-screen:focus {
|
|
171
|
+
outline: none !important;
|
|
172
|
+
}
|
|
173
|
+
`;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=bv,document.head.appendChild(e)}function wv({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:o=!1,onProcessComplete:s,minimal:a=!1,autoConnect:i=!1}){const{t:c}=kt("chat"),d=l.useRef(null),u=l.useRef(null),m=l.useRef(null),p=l.useRef(null),[f,g]=l.useState(!1),[h,w]=l.useState(!1),[v,S]=l.useState(!1),[L,k]=l.useState(null),[B,E]=l.useState(!1),y=l.useRef(e),I=l.useRef(t),$=l.useRef(n),_=l.useRef(o),H=l.useRef(s);l.useEffect(()=>{y.current=e,I.current=t,$.current=n,_.current=o,H.current=s});const le=l.useCallback(async()=>{if(!(B||f))try{let pe;if(!rg){const K=localStorage.getItem("auth-token");if(!K){console.error("No authentication token found for Shell WebSocket connection");return}pe=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(K)}`}p.current=new WebSocket(pe),p.current.onopen=()=>{g(!0),E(!1),setTimeout(()=>{m.current&&u.current&&(m.current.fit(),p.current.send(JSON.stringify({type:"init",projectPath:y.current.fullPath||y.current.path,sessionId:_.current?null:I.current?.id,hasSession:_.current?!1:!!I.current,provider:_.current?"plain-shell":I.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:$.current,isPlainShell:_.current})))},100)},p.current.onmessage=K=>{try{const De=JSON.parse(K.data);if(De.type==="output"){let P=De.data;if(_.current&&H.current){const j=P.replace(/\x1b\[[0-9;]*m/g,"");if(j.includes("Process exited with code 0"))H.current(0);else if(j.match(/Process exited with code (\d+)/)){const T=parseInt(j.match(/Process exited with code (\d+)/)[1]);T!==0&&H.current(T)}}u.current&&u.current.write(P)}else De.type==="url_open"&&window.open(De.url,"_blank")}catch(De){console.error("[Shell] Error handling WebSocket message:",De,K.data)}},p.current.onclose=K=>{g(!1),E(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},p.current.onerror=K=>{g(!1),E(!1)}}catch{g(!1),E(!1)}},[B,f]),se=l.useCallback(()=>{!h||f||B||(E(!0),le())},[h,f,B,le]),W=l.useCallback(()=>{p.current&&(p.current.close(),p.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),g(!1),E(!1)},[]),Q=l.useMemo(()=>t?t.summary||t.name||"New Session":null,[t]),ce=l.useMemo(()=>Q?Q.slice(0,30):null,[Q]),he=l.useMemo(()=>Q?Q.slice(0,50):null,[Q]),be=()=>{S(!0),p.current&&(p.current.close(),p.current=null),u.current&&(u.current.dispose(),u.current=null,m.current=null),g(!1),w(!1),setTimeout(()=>{S(!1)},200)};return l.useEffect(()=>{const pe=t?.id||null;L!==null&&L!==pe&&h&&W(),k(pe)},[t?.id,h,W]),l.useEffect(()=>{if(!d.current||!e||v||u.current)return;u.current=new hv.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),m.current=new gv.FitAddon;const pe=new xv.WebglAddon,K=new vv.WebLinksAddon;u.current.loadAddon(m.current),u.current.loadAddon(K);try{u.current.loadAddon(pe)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(d.current),u.current.attachCustomKeyEventHandler(P=>(P.ctrlKey||P.metaKey)&&P.key==="c"&&u.current.hasSelection()?(document.execCommand("copy"),!1):(P.ctrlKey||P.metaKey)&&P.key==="v"?(navigator.clipboard.readText().then(j=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:j}))}).catch(()=>{}),!1):!0),setTimeout(()=>{m.current&&(m.current.fit(),u.current&&p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),w(!0),u.current.onData(P=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:P}))});const De=new ResizeObserver(()=>{m.current&&u.current&&setTimeout(()=>{m.current.fit(),p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return d.current&&De.observe(d.current),()=>{De.disconnect(),p.current&&(p.current.readyState===WebSocket.OPEN||p.current.readyState===WebSocket.CONNECTING)&&p.current.close(),p.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,v]),l.useEffect(()=>{!i||!h||B||f||se()},[i,h,B,f,se]),e?a?r.jsx("div",{className:"h-full w-full bg-gray-900",children:r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):r.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${f?"bg-green-500":"bg-red-500"}`}),t&&r.jsxs("span",{className:"text-xs text-primary/80",children:["(",ce,"...)"]}),!t&&r.jsx("span",{className:"text-xs text-gray-400",children:c("shell.status.newSession")}),!h&&r.jsx("span",{className:"text-xs text-yellow-400",children:c("shell.status.initializing")}),v&&r.jsx("span",{className:"text-xs text-primary",children:c("shell.status.restarting")})]}),r.jsxs("div",{className:"flex items-center space-x-3",children:[f&&r.jsxs("button",{onClick:W,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:be,disabled:v||f,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:c("shell.actions.restartTitle"),children:[r.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),r.jsx("span",{children:c("shell.actions.restart")})]})]})]})}),r.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[r.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!h&&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")})}),h&&!f&&!B&&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:se,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:c("shell.actions.connectTitle"),children:[r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),r.jsx("span",{children:c("shell.actions.connect")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:he}):c("shell.startSession")})]})}),B&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:r.jsxs("div",{className:"text-center max-w-sm w-full",children:[r.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[r.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),r.jsx("span",{className:"text-base font-medium",children:c("shell.connecting")})]}),r.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName})})]})})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:c("shell.selectProject.title")}),r.jsx("p",{children:c("shell.selectProject.description")})]})})}function bd({project:e,session:t=null,command:n=null,isPlainShell:o=null,autoConnect:s=!0,onComplete:a=null,onClose:i=null,title:c=null,className:d="",showHeader:u=!0,compact:m=!1,minimal:p=!1}){const[f,g]=l.useState(!1),h=o!==null?o:n!==null,w=l.useCallback(v=>{g(!0),a&&a(v)},[a]);return e?r.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!p&&u&&c&&r.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-200",children:c}),f&&r.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),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(wv,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:h,onProcessComplete:w,minimal:p,autoConnect:p?!0:s})})]}):r.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:r.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:r.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),r.jsx("p",{children:"A project is required to open a shell"})]})})}async function kv(e,t){const n=new FormData,o=`recording_${Date.now()}.webm`,s=new File([e],o,{type:e.type});n.append("audio",s);const a=window.localStorage.getItem("whisperMode")||"default";n.append("mode",a);try{const i=await xt.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 jv({onTranscript:e,className:t=""}){const[n,o]=l.useState("idle"),[s,a]=l.useState(null),[i,c]=l.useState(!0),d=l.useRef(null),u=l.useRef(null),m=l.useRef([]),p=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),a("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),a("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),a(null)})()},[]);const f=async()=>{try{if(console.log("Starting recording..."),a(null),m.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const k=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=k;const B=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",E=new MediaRecorder(k,{mimeType:B});d.current=E,E.ondataavailable=y=>{y.data.size>0&&m.current.push(y.data)},E.onstop=async()=>{console.log("Recording stopped, creating blob...");const y=new Blob(m.current,{type:B});u.current&&(u.current.getTracks().forEach(H=>H.stop()),u.current=null),o("transcribing");const I=window.localStorage.getItem("whisperMode")||"default",$=I==="prompt"||I==="vibe"||I==="instructions"||I==="architect";let _;$&&(_=setTimeout(()=>{o("processing")},2e3));try{const H=await kv(y);H&&e&&e(H)}catch(H){console.error("Transcription error:",H),a(H.message)}finally{_&&clearTimeout(_),o("idle")}},E.start(),o("recording"),console.log("Recording started successfully")}catch(k){console.error("Failed to start recording:",k);let B="Microphone access failed";k.name==="NotAllowedError"?B="Microphone access denied. Please allow microphone permissions.":k.name==="NotFoundError"?B="No microphone found. Please check your audio devices.":k.name==="NotSupportedError"?B="Microphone not supported by this browser.":k.name==="NotReadableError"?B="Microphone is being used by another application.":k.message.includes("HTTPS")&&(B=k.message),a(B),o("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(k=>k.stop()),u.current=null),o("idle"))},h=k=>{if(k&&(k.preventDefault(),k.stopPropagation()),!i)return;const B=Date.now();if(B-p.current<300){console.log("Ignoring rapid tap");return}p.current=B,console.log("Button clicked, current state:",n),n==="idle"?f():n==="recording"&&g()};l.useEffect(()=>()=>{u.current&&u.current.getTracks().forEach(k=>k.stop())},[]);const w=()=>{if(!i)return{icon:r.jsx(Vn,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(n){case"recording":return{icon:r.jsx(Vn,{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(un,{className:"w-5 h-5 animate-spin"}),className:"bg-primary hover:bg-primary/90",disabled:!0};case"processing":return{icon:r.jsx(el,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:r.jsx(Vn,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:v,className:S,disabled:L}=w();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:`
|
|
174
|
+
flex items-center justify-center
|
|
175
|
+
w-12 h-12 rounded-full
|
|
176
|
+
text-white transition-all duration-200
|
|
177
|
+
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ring
|
|
178
|
+
dark:ring-offset-gray-800
|
|
179
|
+
touch-action-manipulation
|
|
180
|
+
${L?"cursor-not-allowed opacity-75":"cursor-pointer"}
|
|
181
|
+
${n==="recording"?"animate-pulse":""}
|
|
182
|
+
hover:opacity-90
|
|
183
|
+
${t}
|
|
184
|
+
`,onClick:h,disabled:L,children:v}),s&&r.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
|
|
185
|
+
bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
|
|
186
|
+
animate-fade-in`,children:s}),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 Ui({diff:e,fileName:t,isMobile:n,wrapText:o}){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 s=(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&&o?"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(`
|
|
187
|
+
`).map((a,i)=>s(a,i))]})}function Sv({selectedProject:e,isMobile:t,onFileOpen:n}){const[o,s]=l.useState(null),[a,i]=l.useState({}),[c,d]=l.useState(!1),[u,m]=l.useState(""),[p,f]=l.useState(new Set),[g,h]=l.useState(new Set),[w,v]=l.useState(!1),[S,L]=l.useState(""),[k,B]=l.useState([]),[E,y]=l.useState(!0),[I,$]=l.useState(!1),[_,H]=l.useState(!1),[le,se]=l.useState(!1),[W,Q]=l.useState(""),[ce,he]=l.useState(!1),[be,pe]=l.useState("changes"),[K,De]=l.useState([]),[P,j]=l.useState(new Set),[T,ne]=l.useState({}),[ge,Se]=l.useState(!1),[A,ee]=l.useState(null),[Ae,ye]=l.useState(!1),[st,Ke]=l.useState(!1),[we,Le]=l.useState(!1),[ze,rt]=l.useState(!1),[Xe,Ve]=l.useState(t),[fe,Re]=l.useState(null),[et,Ye]=l.useState(!1),Qe=l.useRef(null),ot=l.useRef(null),[J,oe]=l.useState(()=>localStorage.getItem("selected-provider")||"claude");l.useEffect(()=>{const C=()=>{const D=localStorage.getItem("selected-provider")||"claude";oe(D)};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[]),l.useEffect(()=>{e&&(x(),M(),G(),be==="history"&&dt())},[e,be]),l.useEffect(()=>{const C=D=>{ot.current&&!ot.current.contains(D.target)&&H(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]);const x=async()=>{if(e){d(!0);try{const D=await(await xe(`/api/git/status?project=${encodeURIComponent(e.name)}`)).json();if(D.error)console.error("Git status error:",D.error),s({error:D.error,details:D.details});else{s(D),L(D.branch||"main");const Ce=new Set([...D.modified||[],...D.added||[],...D.deleted||[],...D.untracked||[]]);h(Ce);for(const _e of D.modified||[])yt(_e);for(const _e of D.added||[])yt(_e);for(const _e of D.deleted||[])yt(_e);for(const _e of D.untracked||[])yt(_e)}}catch(C){console.error("Error fetching git status:",C)}finally{d(!1)}}},M=async()=>{try{const D=await(await xe(`/api/git/branches?project=${encodeURIComponent(e.name)}`)).json();!D.error&&D.branches&&B(D.branches)}catch(C){console.error("Error fetching branches:",C)}},G=async()=>{if(e)try{const D=await(await xe(`/api/git/remote-status?project=${encodeURIComponent(e.name)}`)).json();D.error?ee(null):ee(D)}catch(C){console.error("Error fetching remote status:",C),ee(null)}},O=async C=>{try{const Ce=await(await xe("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:C})})).json();Ce.success?(L(C),H(!1),x()):console.error("Failed to switch branch:",Ce.error)}catch(D){console.error("Error switching branch:",D)}},te=async()=>{if(W.trim()){he(!0);try{const D=await(await xe("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:W.trim()})})).json();D.success?(L(W.trim()),se(!1),H(!1),Q(""),M(),x()):console.error("Failed to create branch:",D.error)}catch(C){console.error("Error creating branch:",C)}finally{he(!1)}}},Ie=async()=>{ye(!0);try{const D=await(await xe("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();D.success?(x(),G()):console.error("Fetch failed:",D.error)}catch(C){console.error("Error fetching from remote:",C)}finally{ye(!1)}},Oe=async()=>{Ke(!0);try{const D=await(await xe("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();D.success?(x(),G()):console.error("Pull failed:",D.error)}catch(C){console.error("Error pulling from remote:",C)}finally{Ke(!1)}},Fe=async()=>{Le(!0);try{const D=await(await xe("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();D.success?(x(),G()):console.error("Push failed:",D.error)}catch(C){console.error("Error pushing to remote:",C)}finally{Le(!1)}},ct=async()=>{rt(!0);try{const D=await(await xe("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,branch:S})})).json();D.success?(x(),G()):console.error("Publish failed:",D.error)}catch(C){console.error("Error publishing branch:",C)}finally{rt(!1)}},Ne=async C=>{try{const Ce=await(await xe("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();Ce.success?(h(_e=>{const vt=new Set(_e);return vt.delete(C),vt}),x()):console.error("Discard failed:",Ce.error)}catch(D){console.error("Error discarding changes:",D)}},Pe=async C=>{try{const Ce=await(await xe("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,file:C})})).json();Ce.success?(h(_e=>{const vt=new Set(_e);return vt.delete(C),vt}),x()):console.error("Delete failed:",Ce.error)}catch(D){console.error("Error deleting untracked file:",D)}},at=async()=>{if(!fe)return;const{type:C,file:D,message:Ce}=fe;Re(null);try{switch(C){case"discard":await Ne(D);break;case"delete":await Pe(D);break;case"commit":await ae();break;case"pull":await Oe();break;case"push":await Fe();break;case"publish":await ct();break}}catch(_e){console.error(`Error executing ${C}:`,_e)}},yt=async C=>{try{const Ce=await(await xe(`/api/git/diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();!Ce.error&&Ce.diff&&i(_e=>({..._e,[C]:Ce.diff}))}catch(D){console.error("Error fetching file diff:",D)}},Nt=async C=>{if(n)try{const Ce=await(await xe(`/api/git/file-with-diff?project=${encodeURIComponent(e.name)}&file=${encodeURIComponent(C)}`)).json();if(Ce.error){console.error("Error fetching file with diff:",Ce.error),n(C);return}const _e={old_string:Ce.oldContent||"",new_string:Ce.currentContent||""};n(C,_e)}catch(D){console.error("Error opening file:",D),n(C)}},dt=async()=>{try{const D=await(await xe(`/api/git/commits?project=${encodeURIComponent(e.name)}&limit=10`)).json();!D.error&&D.commits&&De(D.commits)}catch(C){console.error("Error fetching commits:",C)}},pt=async C=>{try{const Ce=await(await xe(`/api/git/commit-diff?project=${encodeURIComponent(e.name)}&commit=${C}`)).json();!Ce.error&&Ce.diff&&ne(_e=>({..._e,[C]:Ce.diff}))}catch(D){console.error("Error fetching commit diff:",D)}},wt=async()=>{Se(!0);try{const D=await(await xe("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,files:Array.from(g),provider:J})})).json();D.message?m(D.message):console.error("Failed to generate commit message:",D.error)}catch(C){console.error("Error generating commit message:",C)}finally{Se(!1)}},ke=C=>{f(D=>{const Ce=new Set(D);return Ce.has(C)?Ce.delete(C):Ce.add(C),Ce})},q=C=>{j(D=>{const Ce=new Set(D);return Ce.has(C)?Ce.delete(C):(Ce.add(C),T[C]||pt(C)),Ce})},de=C=>{h(D=>{const Ce=new Set(D);return Ce.has(C)?Ce.delete(C):Ce.add(C),Ce})},ae=async()=>{if(!(!u.trim()||g.size===0)){v(!0);try{const D=await(await xe("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name,message:u,files:Array.from(g)})})).json();D.success?(m(""),h(new Set),x(),G()):console.error("Commit failed:",D.error)}catch(C){console.error("Error committing changes:",C)}finally{v(!1)}}},N=async()=>{Ye(!0);try{const D=await(await xe("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:e.name})})).json();D.success?(x(),G()):(console.error("Initial commit failed:",D.error),alert(D.error||"Failed to create initial commit"))}catch(C){console.error("Error creating initial commit:",C),alert("Failed to create initial commit")}finally{Ye(!1)}},ie=C=>{switch(C){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return C}},Me=C=>{const D=P.has(C.hash),Ce=T[C.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:()=>q(C.hash),children:[r.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:D?r.jsx(vr,{className:"w-3 h-3"}):r.jsx(Wr,{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:C.message}),r.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:[C.author," • ",C.date]})]}),r.jsx("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:C.hash.substring(0,7)})]})})]}),D&&Ce&&r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900",children:r.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[r.jsx("div",{className:"text-xs font-mono text-gray-600 dark:text-gray-400 mb-2",children:C.stats}),r.jsx(Ui,{diff:Ce,fileName:"commit",isMobile:t,wrapText:E})]})})]},C.hash)},Z=(C,D)=>{const Ce=p.has(C),_e=g.has(C),vt=a[C];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:_e,onChange:()=>de(C),onClick:V=>V.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:V=>{V.stopPropagation(),ke(C)},children:r.jsx(Wr,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${Ce?"rotate-90":"rotate-0"}`})}),r.jsx("span",{className:`flex-1 truncate ${t?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:V=>{V.stopPropagation(),Nt(C)},title:"Click to open file",children:C}),r.jsxs("div",{className:"flex items-center gap-1",children:[(D==="M"||D==="D")&&r.jsxs("button",{onClick:V=>{V.stopPropagation(),Re({type:"discard",file:C,message:`Discard all changes to "${C}"? 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(Yt,{className:"w-3 h-3"}),t&&r.jsx("span",{children:"Discard"})]}),D==="U"&&r.jsxs("button",{onClick:V=>{V.stopPropagation(),Re({type:"delete",file:C,message:`Delete untracked file "${C}"? 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(Yt,{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 ${D==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":D==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":D==="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:ie(D),children:D})]})]})]}),r.jsxs("div",{className:`bg-gray-50 dark:bg-gray-900 transition-all duration-400 ease-in-out overflow-hidden ${Ce&&vt?"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 ${D==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800":D==="A"?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 border-green-200 dark:border-green-800":D==="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:D}),r.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:ie(D)})]}),t&&r.jsx("button",{onClick:V=>{V.stopPropagation(),y(!E)},className:"text-xs text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white",title:E?"Switch to horizontal scroll":"Switch to text wrap",children:E?"↔️ Scroll":"↩️ Wrap"})]}),r.jsx("div",{className:"max-h-96 overflow-y-auto",children:vt&&r.jsx(Ui,{diff:vt,fileName:C,isMobile:t,wrapText:E})})]})]},C)};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:ot,children:[r.jsxs("button",{onClick:()=>H(!_),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(Fo,{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:S}),A?.hasRemote&&r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[A.ahead>0&&r.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${A.ahead} commit${A.ahead!==1?"s":""} ahead`,children:["↑",A.ahead]}),A.behind>0&&r.jsxs("span",{className:"text-primary",title:`${A.behind} commit${A.behind!==1?"s":""} behind`,children:["↓",A.behind]}),A.isUpToDate&&r.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"Up to date with remote",children:"✓"})]})]}),r.jsx(vr,{className:`w-3 h-3 text-gray-500 transition-transform ${_?"rotate-180":""}`})]}),_&&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:k.map(C=>r.jsx("button",{onClick:()=>O(C),className:`w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 ${C===S?"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:[C===S&&r.jsx(rr,{className:"w-3 h-3 text-green-600 dark:text-green-400"}),r.jsx("span",{className:C===S?"font-medium":"",children:C})]})},C))}),r.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 py-1",children:r.jsxs("button",{onClick:()=>{se(!0),H(!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(Kr,{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:[A?.hasRemote&&r.jsxs(r.Fragment,{children:[!A?.hasUpstream&&r.jsxs("button",{onClick:()=>Re({type:"publish",message:`Publish branch "${S}" to ${A.remoteName}?`}),disabled:ze,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 "${S}" to ${A.remoteName}`,children:[r.jsx(Tn,{className:`w-3 h-3 ${ze?"animate-pulse":""}`}),r.jsx("span",{children:ze?"Publishing...":"Publish"})]}),A?.hasUpstream&&!A?.isUpToDate&&r.jsxs(r.Fragment,{children:[A.behind>0&&r.jsxs("button",{onClick:()=>Re({type:"pull",message:`Pull ${A.behind} commit${A.behind!==1?"s":""} from ${A.remoteName}?`}),disabled:st,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 ${A.behind} commit${A.behind!==1?"s":""} from ${A.remoteName}`,children:[r.jsx(as,{className:`w-3 h-3 ${st?"animate-pulse":""}`}),r.jsx("span",{children:st?"Pulling...":`Pull ${A.behind}`})]}),A.ahead>0&&r.jsxs("button",{onClick:()=>Re({type:"push",message:`Push ${A.ahead} commit${A.ahead!==1?"s":""} to ${A.remoteName}?`}),disabled:we,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 ${A.ahead} commit${A.ahead!==1?"s":""} to ${A.remoteName}`,children:[r.jsx(Tn,{className:`w-3 h-3 ${we?"animate-pulse":""}`}),r.jsx("span",{children:we?"Pushing...":`Push ${A.ahead}`})]}),(A.ahead>0||A.behind>0&&A.ahead>0)&&r.jsxs("button",{onClick:Ie,disabled:Ae,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 ${A.remoteName}`,children:[r.jsx(cr,{className:`w-3 h-3 ${Ae?"animate-spin":""}`}),r.jsx("span",{children:Ae?"Fetching...":"Fetch"})]})]})]}),r.jsx("button",{onClick:()=>{x(),M(),G()},disabled:c,className:`hover:bg-gray-100 dark:hover:bg-gray-800 rounded ${t?"p-1":"p-1.5"}`,children:r.jsx(cr,{className:`${c?"animate-spin":""} ${t?"w-3 h-3":"w-4 h-4"}`})})]})]}),o?.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(Fo,{className:"w-20 h-20 mb-6 opacity-30"}),r.jsx("h3",{className:"text-xl font-medium mb-3 text-center",children:o.error}),o.details&&r.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:o.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 ${p.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:()=>pe("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${be==="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(Os,{className:"w-4 h-4"}),r.jsx("span",{children:"Changes"})]})}),r.jsx("button",{onClick:()=>pe("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${be==="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(Ea,{className:"w-4 h-4"}),r.jsx("span",{children:"History"})]})})]}),be==="changes"&&r.jsx(r.Fragment,{children:r.jsx("div",{className:`transition-all duration-300 ease-in-out ${p.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:t&&Xe?r.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700",children:r.jsxs("button",{onClick:()=>Ve(!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($o,{className:"w-4 h-4"}),r.jsxs("span",{children:["Commit ",g.size," file",g.size!==1?"s":""]}),r.jsx(vr,{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:()=>Ve(!0),className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-800 rounded",children:r.jsx(vr,{className:"w-4 h-4 rotate-180"})})]}),r.jsxs("div",{className:"relative",children:[r.jsx("textarea",{ref:Qe,value:u,onChange:C=>m(C.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 resize-none pr-20",rows:"3",onKeyDown:C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)&&ae()}}),r.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[r.jsx("button",{onClick:wt,disabled:g.size===0||ge,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:ge?r.jsx(cr,{className:"w-4 h-4 animate-spin"}):r.jsx(Fs,{className:"w-4 h-4"})}),r.jsx("div",{style:{display:"none"},children:r.jsx(jv,{onTranscript:C=>m(C),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:()=>Re({type:"commit",message:`Commit ${g.size} file${g.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||g.size===0||w,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(rr,{className:"w-3 h-3"}),r.jsx("span",{children:w?"Committing...":"Commit"})]})]})]})})})}),be==="changes"&&o&&!o.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"} ${p.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 ",(o?.modified?.length||0)+(o?.added?.length||0)+(o?.deleted?.length||0)+(o?.untracked?.length||0)," ",t?"":"files"," selected"]}),r.jsxs("div",{className:`flex ${t?"gap-1":"gap-2"}`,children:[r.jsx("button",{onClick:()=>{const C=new Set([...o?.modified||[],...o?.added||[],...o?.deleted||[],...o?.untracked||[]]);h(C)},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:()=>h(new Set),className:"text-primary hover:text-primary text-xs",children:t?"None":"Deselect All"})]})]}),!o?.error&&!t&&r.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-700",children:[r.jsxs("button",{onClick:()=>$(!I),className:"w-full px-4 py-2 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-750 text-xs text-gray-600 dark:text-gray-400 flex items-center justify-center gap-1",children:[r.jsx(Kp,{className:"w-3 h-3"}),r.jsx("span",{children:"File Status Guide"}),I?r.jsx(vr,{className:"w-3 h-3"}):r.jsx(Wr,{className:"w-3 h-3"})]}),I&&r.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-800 text-xs",children:r.jsxs("div",{className:`${t?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300 rounded border border-yellow-200 dark:border-yellow-800 font-bold text-xs",children:"M"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Modified"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300 rounded border border-green-200 dark:border-green-800 font-bold text-xs",children:"A"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Added"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300 rounded border border-red-200 dark:border-red-800 font-bold text-xs",children:"D"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Deleted"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300 rounded border border-gray-300 dark:border-gray-600 font-bold text-xs",children:"U"}),r.jsx("span",{className:"text-gray-600 dark:text-gray-400 italic",children:"Untracked"})]})]})})]})]}),be==="changes"&&!o?.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(cr,{className:"w-6 h-6 animate-spin text-gray-400"})}):o?.hasCommits===!1?r.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[r.jsx(Fo,{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:N,disabled:et,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:et?r.jsxs(r.Fragment,{children:[r.jsx(cr,{className:"w-4 h-4 animate-spin"}),r.jsx("span",{children:"Creating Initial Commit..."})]}):r.jsxs(r.Fragment,{children:[r.jsx($o,{className:"w-4 h-4"}),r.jsx("span",{children:"Create Initial Commit"})]})})]}):!o||!o.modified?.length&&!o.added?.length&&!o.deleted?.length&&!o.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($o,{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:[o.modified?.map(C=>Z(C,"M")),o.added?.map(C=>Z(C,"A")),o.deleted?.map(C=>Z(C,"D")),o.untracked?.map(C=>Z(C,"U"))]})}),be==="history"&&!o?.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(cr,{className:"w-6 h-6 animate-spin text-gray-400"})}):K.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(Ea,{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:K.map(C=>Me(C))})}),le&&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:()=>se(!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:W,onChange:C=>Q(C.target.value),onKeyDown:C=>{C.key==="Enter"&&!ce&&te()},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 (",S,")"]}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>{se(!1),Q("")},className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md",children:"Cancel"}),r.jsx("button",{onClick:te,disabled:!W.trim()||ce,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:ce?r.jsxs(r.Fragment,{children:[r.jsx(cr,{className:"w-3 h-3 animate-spin"}),r.jsx("span",{children:"Creating..."})]}):r.jsxs(r.Fragment,{children:[r.jsx(Kr,{className:"w-3 h-3"}),r.jsx("span",{children:"Create Branch"})]})})]})]})})]}),fe&&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:()=>Re(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 ${fe.type==="discard"||fe.type==="delete"?"bg-red-100 dark:bg-red-900":"bg-yellow-100 dark:bg-yellow-900"}`,children:r.jsx(ds,{className:`w-5 h-5 ${fe.type==="discard"||fe.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:fe.type==="discard"?"Discard Changes":fe.type==="delete"?"Delete File":fe.type==="commit"?"Confirm Commit":fe.type==="pull"?"Confirm Pull":fe.type==="publish"?"Publish Branch":"Confirm Push"})]}),r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:fe.message}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[r.jsx("button",{onClick:()=>Re(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:at,className:`px-4 py-2 text-sm text-white rounded-md ${fe.type==="discard"||fe.type==="delete"?"bg-red-600 hover:bg-red-700":fe.type==="commit"?"bg-primary hover:bg-primary/90":fe.type==="pull"?"bg-green-600 hover:bg-green-700":fe.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:fe.type==="discard"?r.jsxs(r.Fragment,{children:[r.jsx(Yt,{className:"w-4 h-4"}),r.jsx("span",{children:"Discard"})]}):fe.type==="delete"?r.jsxs(r.Fragment,{children:[r.jsx(Yt,{className:"w-4 h-4"}),r.jsx("span",{children:"Delete"})]}):fe.type==="commit"?r.jsxs(r.Fragment,{children:[r.jsx(rr,{className:"w-4 h-4"}),r.jsx("span",{children:"Commit"})]}):fe.type==="pull"?r.jsxs(r.Fragment,{children:[r.jsx(as,{className:"w-4 h-4"}),r.jsx("span",{children:"Pull"})]}):fe.type==="publish"?r.jsxs(r.Fragment,{children:[r.jsx(Tn,{className:"w-4 h-4"}),r.jsx("span",{children:"Publish"})]}):r.jsxs(r.Fragment,{children:[r.jsx(Tn,{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 Nv extends gn.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 Cv=l.forwardRef(({className:e,...t},n)=>r.jsx(yc,{ref:n,className:ht("inline-flex h-10 items-center justify-center rounded-xl bg-muted/60 p-1 text-muted-foreground",e),...t}));Cv.displayName=yc.displayName;const Ev=l.forwardRef(({className:e,...t},n)=>r.jsx(vc,{ref:n,className:ht("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}));Ev.displayName=vc.displayName;const Av=l.forwardRef(({className:e,...t},n)=>r.jsx(bc,{ref:n,className:ht("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",e),...t}));Av.displayName=bc.displayName;function Iv({selectedProject:e,selectedSession:t,activeTab:n,setActiveTab:o,ws:s,sendMessage:a,latestMessage:i,isMobile:c,isPWA:d,onMenuClick:u,isLoading:m,onInputFocusChange:p,onSessionActive:f,onSessionInactive:g,onSessionProcessing:h,onSessionNotProcessing:w,processingSessions:v,onReplaceTemporarySession:S,onNavigateToSession:L,onShowSettings:k,autoExpandTools:B,showRawParameters:E,showThinking:y,autoScrollToBottom:I,sendByCtrlEnter:$,externalMessageUpdate:_,urlContext:H,urlPrompt:le,integrationClientId:se,latestIntegrationMessage:W,sendIntegrationMessage:Q,onShowNewProject:ce,onNewSession:he,newSessionResetNonce:be}){const{t:pe}=kt(),[K,De]=l.useState(null),[P,j]=l.useState(600),[T,ne]=l.useState(!1),[ge,Se]=l.useState(!1),A=l.useRef(null),ee=(Xe,Ve=null)=>{const fe={name:Xe.split("/").pop(),path:Xe,projectName:e?.name,diffInfo:Ve};De(fe)},Ae=()=>{De(null),Se(!1)},ye=()=>{Se(!ge)},st=Xe=>{c||(ne(!0),Xe.preventDefault())};if(l.useEffect(()=>{n==="files"&&o("chat")},[n,o]),l.useEffect(()=>{const Xe=fe=>{if(!T)return;const Re=A.current?.parentElement;if(!Re)return;const et=Re.getBoundingClientRect(),Ye=et.right-fe.clientX,Qe=300,ot=et.width*.8;Ye>=Qe&&Ye<=ot&&j(Ye)},Ve=()=>{ne(!1)};return T&&(document.addEventListener("mousemove",Xe),document.addEventListener("mouseup",Ve),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",Xe),document.removeEventListener("mouseup",Ve),document.body.style.cursor="",document.body.style.userSelect=""}},[T]),m)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:pe("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:pe("mainContent.chooseProject")}),r.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:pe("mainContent.selectProjectDescription")}),r.jsx("div",{className:"mx-auto flex w-fit items-center",children:r.jsxs("button",{onClick:ce,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:pe("sidebar:projects.newProject"),children:[r.jsx(Ar,{className:"w-5 h-5"}),r.jsx("span",{children:pe("sidebar:projects.newProject")})]})})]})})]});const Ke=t?.__provider||t?.provider||"claude",we=Ke==="openai"?"codex":Ke,Le=we==="codex"&&typeof t?.id=="string"?t.id.trim():"",ze=Le?`codex://threads/${encodeURIComponent(Le)}`:"",rt=()=>{ze&&(window.location.href=ze)};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:we==="codex"?r.jsx(vo,{className:"w-4 h-4"}):we==="gemini"?r.jsx(bo,{className:"w-4 h-4"}):we==="opencode"?r.jsx(wo,{className:"h-4 w-auto max-w-full"}):r.jsx(kn,{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:we==="codex"?t.summary||t.name||"Codex Session":we==="gemini"?t.summary||t.name||"Gemini Session":we==="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:pe("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"?pe("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"&&we==="codex"&&ze&&!c&&r.jsx("button",{onClick:rt,className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:pe("mainContent.openInCodexClient"),"aria-label":pe("mainContent.openInCodexClient"),children:r.jsx(is,{className:"w-5 h-5"})}),r.jsx("button",{onClick:()=>he&&he(e),className:"rounded-xl bg-muted/60 p-2 text-muted-foreground transition hover:bg-muted hover:text-foreground",title:pe("tooltips.newChat","New Chat"),children:r.jsx(Qp,{className:"w-5 h-5"})})]})]})}),r.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[r.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${K?"mr-0":""} ${ge?"hidden":""}`,children:[r.jsx("div",{className:`h-full ${n==="chat"?"block":"hidden"}`,children:r.jsx(Nv,{showDetails:!0,children:r.jsx(Cy,{selectedProject:e,selectedSession:t,ws:s,sendMessage:a,latestMessage:i,onFileOpen:ee,onInputFocusChange:p,onSessionActive:f,onSessionInactive:g,onSessionProcessing:h,onSessionNotProcessing:w,processingSessions:v,onReplaceTemporarySession:S,onNavigateToSession:L,onShowSettings:k,autoExpandTools:B,showRawParameters:E,showThinking:y,autoScrollToBottom:I,sendByCtrlEnter:$,externalMessageUpdate:_,urlContext:H,urlPrompt:le,integrationClientId:se,latestIntegrationMessage:W,sendIntegrationMessage:Q,newSessionResetNonce:be},`${e?.name||"no-project"}:${t?.id||`new-${be}`}`)})}),n==="shell"&&r.jsx("div",{className:"h-full w-full overflow-hidden",children:r.jsx(bd,{project:e,session:t,showHeader:!1})}),n==="git"&&r.jsx("div",{className:"chat-surface h-full overflow-hidden",children:r.jsx(Sv,{selectedProject:e,isMobile:c,onFileOpen:ee})}),r.jsx("div",{className:`h-full overflow-hidden ${n==="preview"?"block":"hidden"}`})]}),K&&!c&&r.jsxs(r.Fragment,{children:[!ge&&r.jsx("div",{ref:A,onMouseDown:st,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 ${ge?"flex-1":""}`,style:ge?{}:{width:`${P}px`},children:r.jsx(Bi,{file:K,onClose:Ae,projectPath:e?.path,isSidebar:!0,isExpanded:ge,onToggleExpand:ye})})]})]}),K&&c&&r.jsx(Bi,{file:K,onClose:Ae,projectPath:e?.path,isSidebar:!1})]})}const _v=gn.memo(Iv),wd="0.2.7",kd=()=>{const[e,t]=l.useState(!1),[n,o]=l.useState(null),[s,a]=l.useState(null);return l.useEffect(()=>{(async()=>{try{const c=await xe("/api/system/version");if(!c.ok)throw new Error(`Version API failed: ${c.status}`);const d=await c.json();if(!d?.success)throw new Error(d?.error||"Version API returned unsuccessful result");if(d.latestVersion){const u=String(d.latestVersion).replace(/^v/,"");o(u),t(!!d.updateAvailable),a({title:d.releaseInfo?.title||`v${u}`,body:d.releaseInfo?.body||"",htmlUrl:d.releaseInfo?.htmlUrl||`https://www.npmjs.com/package/${d.packageName||"@axhub/genie"}`,publishedAt:d.releaseInfo?.publishedAt||null})}else t(!1),o(null),a(null)}catch(c){console.error("Version check failed:",c.message||c),t(!1),o(null),a(null)}})()},[]),{updateAvailable:e,latestVersion:n,currentVersion:wd,releaseInfo:s}};function Tv(){const{t:e}=kt("settings"),[t,n]=l.useState([]),[o,s]=l.useState(!0),[a,i]=l.useState(!1),[c,d]=l.useState(""),[u,m]=l.useState(null),[p,f]=l.useState(null),{updateAvailable:g,latestVersion:h,releaseInfo:w}=kd();l.useEffect(()=>{v()},[]);const v=async()=>{try{s(!0);const y=await(await xe("/api/settings/api-keys")).json();n(y.apiKeys||[])}catch(E){console.error("Error fetching settings:",E)}finally{s(!1)}},S=async()=>{if(c.trim())try{const y=await(await xe("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:c})})).json();y.success&&(f(y.apiKey),d(""),i(!1),v())}catch(E){console.error("Error creating API key:",E)}},L=async E=>{if(confirm(e("apiKeys.confirmDelete")))try{await xe(`/api/settings/api-keys/${E}`,{method:"DELETE"}),v()}catch(y){console.error("Error deleting API key:",y)}},k=async(E,y)=>{try{await xe(`/api/settings/api-keys/${E}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!y})}),v()}catch(I){console.error("Error toggling API key:",I)}},B=(E,y)=>{navigator.clipboard.writeText(E),m(y),setTimeout(()=>m(null),2e3)};return o?r.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):r.jsxs("div",{className:"space-y-8",children:[p&&r.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[r.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:p.apiKey}),r.jsx(Ge,{size:"sm",variant:"outline",onClick:()=>B(p.apiKey,"new"),children:u==="new"?r.jsx(rr,{className:"h-4 w-4"}):r.jsx(pp,{className:"h-4 w-4"})})]}),r.jsx(Ge,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>f(null),children:e("apiKeys.newKey.iveSavedIt")})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(nl,{className:"h-5 w-5"}),r.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),r.jsxs(Ge,{size:"sm",onClick:()=>i(!a),children:[r.jsx(Kr,{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(is,{className:"h-3 w-3"})]})]}),a&&r.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[r.jsx(_t,{placeholder:e("apiKeys.form.placeholder"),value:c,onChange:E=>d(E.target.value),className:"mb-2"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ge,{onClick:S,children:e("apiKeys.form.createButton")}),r.jsx(Ge,{variant:"outline",onClick:()=>i(!1),children:e("apiKeys.form.cancelButton")})]})]}),r.jsx("div",{className:"space-y-2",children:t.length===0?r.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(E=>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:E.key_name}),r.jsx("code",{className:"text-xs text-muted-foreground",children:E.api_key}),r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(E.created_at).toLocaleDateString(),E.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(E.last_used).toLocaleDateString()}`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{size:"sm",variant:E.is_active?"outline":"secondary",onClick:()=>k(E.id,E.is_active),children:E.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),r.jsx(Ge,{size:"sm",variant:"ghost",onClick:()=>L(E.id),children:r.jsx(Yt,{className:"h-4 w-4"})})]})]},E.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:w?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",wd]}),g&&h&&r.jsxs("a",{href:w?.htmlUrl||"https://github.com/lintendo/AI-Web-UI/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[r.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:h})}),r.jsx(is,{className:"h-2.5 w-2.5"})]})]})})]})}const Mv=["claude","cursor","codex","gemini","opencode"],Wi=["lark","dingtalk"],Hi={lark:{appId:"",appSecret:"",hasAppSecret:!1,encryptKey:"",verificationToken:"",hasEncryptKey:!1,hasVerificationToken:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""},dingtalk:{clientId:"",clientSecret:"",hasClientSecret:!1,defaultBackend:"codex",defaultModel:"",defaultProjectPath:""}},rs={running:!1,status:"stopped",error:null};function Dv({projects:e=[]}){const{t}=kt("settings"),[n,o]=l.useState("lark"),[s,a]=l.useState(Hi),[i,c]=l.useState({lark:{...rs},dingtalk:{...rs}}),[d,u]=l.useState({lark:[],dingtalk:[]}),[m,p]=l.useState(!1),[f,g]=l.useState(!1),[h,w]=l.useState(!1),[v,S]=l.useState(!1),[L,k]=l.useState(null),[B,E]=l.useState(null),[y,I]=l.useState({userId:"",displayName:"",note:""}),$=l.useMemo(()=>e.map(j=>({label:j.displayName||j.name||j.path||j.fullPath,value:j.path||j.fullPath||""})).filter(j=>j.value),[e]),_=s[n]||Hi[n],H=i[n]||rs,le=d[n]||[],se=async(j,T=!1)=>{T||E(null);const[ne,ge,Se]=await Promise.all([xe(`/api/channels/${j}/config`),xe(`/api/channels/${j}/status`),xe(`/api/channels/${j}/allowed-users`)]),A=await ne.json(),ee=await ge.json(),Ae=await Se.json();A?.success&&A?.config&&a(ye=>({...ye,[j]:{...ye[j],...A.config}})),ee?.success&&ee?.status&&c(ye=>({...ye,[j]:ee.status})),Ae?.success&&u(ye=>({...ye,[j]:Ae.users||[]}))},W=async(j=!1)=>{p(!0);try{await Promise.all(Wi.map(T=>se(T,j)))}catch(T){E(T.message||t("channels.errors.loadFailed","加载渠道设置失败"))}finally{p(!1)}};l.useEffect(()=>{W()},[]);const Q=j=>{a(T=>({...T,[n]:{...T[n],...j}}))},ce=async()=>{p(!0),k(null),E(null);try{const j=n==="dingtalk"?{clientId:_.clientId,clientSecret:_.clientSecret,defaultBackend:_.defaultBackend,defaultModel:_.defaultModel,defaultProjectPath:_.defaultProjectPath}:{appId:_.appId,appSecret:_.appSecret,encryptKey:_.encryptKey,verificationToken:_.verificationToken,defaultBackend:_.defaultBackend,defaultModel:_.defaultModel,defaultProjectPath:_.defaultProjectPath},T=await xe(`/api/channels/${n}/config`,{method:"PUT",body:JSON.stringify(j)}),ne=await T.json();if(!T.ok||!ne.success)throw new Error(ne.error||t("channels.errors.saveFailed","保存失败"));Q(n==="dingtalk"?{...ne.config,clientSecret:""}:{...ne.config,appSecret:"",encryptKey:"",verificationToken:""}),k(t(`channels.messages.${n}.configSaved`,n==="dingtalk"?"DingTalk 配置已保存":"Lark 配置已保存")),await se(n,!0)}catch(j){E(j.message||t("channels.errors.saveFailed","保存失败"))}finally{p(!1)}},he=async()=>{if(n==="dingtalk"){const j=String(_.clientId||"").trim(),T=String(_.clientSecret||"").trim();if(!j||!T&&!_.hasClientSecret){E(t("channels.errors.testNeedCredentialsDingTalk","测试连接需要填写 Client ID 和 Client Secret"));return}}else{const j=String(_.appId||"").trim(),T=String(_.appSecret||"").trim();if(!j||!T&&!_.hasAppSecret){E(t("channels.errors.testNeedCredentials","测试连接需要填写 App ID 和 App Secret"));return}}g(!0),E(null),k(null);try{const j=await xe(`/api/channels/${n}/test`,{method:"POST",body:JSON.stringify(n==="dingtalk"?{clientId:_.clientId,clientSecret:_.clientSecret}:{appId:_.appId,appSecret:_.appSecret})}),T=await j.json();if(!j.ok||!T.success)throw new Error(T.error||t("channels.errors.testFailed","连接测试失败"));k(t(`channels.messages.${n}.testSuccess`,n==="dingtalk"?"DingTalk 连接测试成功":"Lark 连接测试成功"))}catch(j){E(j.message||t("channels.errors.testFailed","连接测试失败"))}finally{g(!1)}},be=async()=>{w(!0),E(null),k(null);try{const j=await xe(`/api/channels/${n}/start`,{method:"POST"}),T=await j.json();if(!j.ok||!T.success)throw new Error(T.error||t("channels.errors.startFailed","启动失败"));c(ne=>({...ne,[n]:T.status||ne[n]})),k(t(`channels.messages.${n}.started`,n==="dingtalk"?"DingTalk 已启动":"Lark 已启动")),await se(n,!0)}catch(j){E(j.message||t("channels.errors.startFailed","启动失败"))}finally{w(!1)}},pe=async()=>{S(!0),E(null),k(null);try{const j=await xe(`/api/channels/${n}/stop`,{method:"POST"}),T=await j.json();if(!j.ok||!T.success)throw new Error(T.error||t("channels.errors.stopFailed","停止失败"));c(ne=>({...ne,[n]:T.status||ne[n]})),k(t(`channels.messages.${n}.stopped`,n==="dingtalk"?"DingTalk 已停止":"Lark 已停止")),await se(n,!0)}catch(j){E(j.message||t("channels.errors.stopFailed","停止失败"))}finally{S(!1)}},K=async()=>{if(!y.userId.trim()){E(t("channels.errors.userIdRequired","请输入用户ID"));return}p(!0),E(null),k(null);try{const T=await xe(`/api/channels/${n}/allowed-users`,{method:"POST",body:JSON.stringify(y)}),ne=await T.json();if(!T.ok||!ne.success)throw new Error(ne.error||t("channels.errors.addUserFailed","新增用户失败"));I({userId:"",displayName:"",note:""}),k(t("channels.messages.userAdded","用户已添加")),await se(n,!0)}catch(T){E(T.message||t("channels.errors.addUserFailed","新增用户失败"))}finally{p(!1)}},De=async j=>{p(!0),E(null);try{const T=await xe(`/api/channels/${n}/allowed-users/${j.id}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!j.isActive})}),ne=await T.json();if(!T.ok||!ne.success)throw new Error(ne.error||t("channels.errors.toggleUserFailed","更新用户状态失败"));await se(n,!0)}catch(T){E(T.message||t("channels.errors.toggleUserFailed","更新用户状态失败"))}finally{p(!1)}},P=async j=>{if(window.confirm(t("channels.confirmDeleteUser","确定要删除这个用户ID吗?"))){p(!0),E(null);try{const T=await xe(`/api/channels/${n}/allowed-users/${j}`,{method:"DELETE"}),ne=await T.json();if(!T.ok||!ne.success)throw new Error(ne.error||t("channels.errors.deleteUserFailed","删除用户失败"));await se(n,!0)}catch(T){E(T.message||t("channels.errors.deleteUserFailed","删除用户失败"))}finally{p(!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:Wi.map(j=>{const T=j===n;return r.jsx("button",{type:"button",role:"tab","aria-selected":T,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 ${T?"border-primary text-primary bg-primary/5":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,onClick:()=>{o(j),k(null),E(null)},children:t(`channels.platforms.${j}`,j==="dingtalk"?"DingTalk / 钉钉":"Lark / 飞书")},j)})})}),(L||B)&&r.jsx("div",{className:`rounded-lg border p-3 text-sm ${B?"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:B||L}),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(_t,{value:_.clientId,onChange:j=>Q({clientId:j.target.value}),placeholder:"dingxxxxxxxx"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:"Client Secret"}),r.jsx(_t,{type:"password",value:_.clientSecret,onChange:j=>Q({clientSecret:j.target.value}),placeholder:_.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(_t,{value:_.appId,onChange:j=>Q({appId:j.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(_t,{type:"password",value:_.appSecret,onChange:j=>Q({appSecret:j.target.value}),placeholder:_.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:_.defaultBackend,onChange:j=>Q({defaultBackend:j.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:Mv.map(j=>r.jsx("option",{value:j,children:j},j))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-sm mb-1 text-foreground",children:t("channels.defaults.project","默认项目")}),r.jsxs("select",{value:_.defaultProjectPath,onChange:j=>Q({defaultProjectPath:j.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","请选择项目")}),$.map(j=>r.jsx("option",{value:j.value,children:j.label},j.value))]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{onClick:ce,disabled:m,children:t("channels.actions.saveConfig","保存配置")}),r.jsx(Ge,{variant:"outline",onClick:he,disabled:f,children:f?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:H.status||"stopped"}),H.error?r.jsx("span",{className:"text-red-500 ml-2",children:H.error}):null]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ge,{onClick:be,disabled:h||H.running,children:h?t("channels.actions.starting","启动中..."):t("channels.actions.start","启动")}),r.jsx(Ge,{variant:"outline",onClick:pe,disabled:v||!H.running,children:v?t("channels.actions.stopping","停止中..."):t("channels.actions.stop","停止")}),r.jsx(Ge,{variant:"ghost",onClick:()=>{se(n)},disabled:m,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(_t,{placeholder:t("channels.allowedUsers.userId","用户ID"),value:y.userId,onChange:j=>I(T=>({...T,userId:j.target.value}))}),r.jsx(_t,{placeholder:t("channels.allowedUsers.displayName","显示名(可选)"),value:y.displayName,onChange:j=>I(T=>({...T,displayName:j.target.value}))}),r.jsx(_t,{placeholder:t("channels.allowedUsers.note","备注(可选)"),value:y.note,onChange:j=>I(T=>({...T,note:j.target.value}))}),r.jsx(Ge,{onClick:K,disabled:m,children:t("channels.allowedUsers.add","新增")})]}),r.jsx("div",{className:"space-y-2",children:le.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:t("channels.allowedUsers.empty","暂无白名单用户")}):le.map(j=>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:j.userId}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[j.displayName||"-",j.note?` · ${j.note}`:""]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:`text-xs px-2 py-1 rounded ${j.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:j.isActive?t("channels.allowedUsers.active","启用"):t("channels.allowedUsers.inactive","停用")}),r.jsx(Ge,{size:"sm",variant:"outline",onClick:()=>{De(j)},children:j.isActive?t("channels.allowedUsers.disable","停用"):t("channels.allowedUsers.enable","启用")}),r.jsx(Ge,{size:"sm",variant:"ghost",onClick:()=>{P(j.id)},children:t("channels.allowedUsers.delete","删除")})]})]},j.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 Pv({isOpen:e,onClose:t,provider:n="claude",project:o,onComplete:s,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=m=>{s?.(m),m===0&&t()};return r.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:r.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[r.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d()}),r.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:r.jsx(Wt,{className:"w-6 h-6"})})]}),r.jsx("div",{className:"flex-1 overflow-hidden",children:r.jsx(bd,{project:o,command:c(),onComplete:u,minimal:!0})})]})})}function jd({compact:e=!1}){const{i18n:t,t:n}=kt("settings"),o=s=>{const a=s.target.value;t.changeLanguage(a)};return e?r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[r.jsx(ol,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),n("account.language")]}),r.jsx("select",{value:t.language,onChange:o,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 focus:outline-none focus:ring-2",children:Ca.map(s=>r.jsx("option",{value:s.value,children:s.nativeName},s.value))})]}):r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:n("account.languageLabel")}),r.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n("account.languageDescription")})]}),r.jsx("select",{value:t.language,onChange:o,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-ring focus:border-primary p-2 w-36",children:Ca.map(s=>r.jsx("option",{value:s.value,children:s.nativeName},s.value))})]})})}function Rv({isOpen:e,onClose:t,projects:n=[],initialTab:o="appearance"}){const{isDarkMode:s,toggleDarkMode:a}=Ls(),{t:i}=kt("settings"),[c,d]=l.useState([]),[u,m]=l.useState([]),[p,f]=l.useState(""),[g,h]=l.useState(""),[w,v]=l.useState(!1),[S,L]=l.useState(!1),[k,B]=l.useState(null),[E,y]=l.useState("name"),[I,$]=l.useState([]),[_,H]=l.useState(!1),[le,se]=l.useState(null),[W,Q]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[ce,he]=l.useState(!1),[be,pe]=l.useState({}),[K,De]=l.useState({}),[P,j]=l.useState({}),[T,ne]=l.useState(o),[ge,Se]=l.useState(""),A=["appearance","api","channels"],[ee,Ae]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[ye,st]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ke,we]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[Le,ze]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[rt,Xe]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[Ve,fe]=l.useState([]),[Re,et]=l.useState("default"),[Ye,Qe]=l.useState(!1),[ot,J]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[oe,x]=l.useState(null),[M,G]=l.useState(!1),[O,te]=l.useState(!1),[Ie,Oe]=l.useState(""),[Fe,ct]=l.useState(null),[Ne,Pe]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[at,yt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Nt,dt]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),pt=async()=>{try{const U=await xe("/api/codex/mcp/config/read");if(U.ok){const je=await U.json();if(je.success&&je.servers){fe(je.servers);return}}const Y=await xe("/api/codex/mcp/cli/list");if(Y.ok){const je=await Y.json();if(je.success&&je.servers){const Ze=je.servers.map(ft=>({id:ft.name,name:ft.name,type:ft.type||"stdio",scope:"user",config:{command:ft.command||"",args:ft.args||[],env:ft.env||{}}}));fe(Ze)}}}catch(U){console.error("Error fetching Codex MCP servers:",U)}},wt=async()=>{try{const U=await xe("/api/mcp/config/read");if(U.ok){const Ze=await U.json();if(Ze.success&&Ze.servers){$(Ze.servers);return}}const Y=await xe("/api/mcp/cli/list");if(Y.ok){const Ze=await Y.json();if(Ze.success&&Ze.servers){const ft=Ze.servers.map(z=>({id:z.name,name:z.name,type:z.type,scope:"user",config:{command:z.command||"",args:z.args||[],env:z.env||{},url:z.url||"",headers:z.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));$(ft);return}}const je=await xe("/api/mcp/servers?scope=user");if(je.ok){const Ze=await je.json();$(Ze.servers||[])}else console.error("Failed to fetch MCP servers")}catch(U){console.error("Error fetching MCP servers:",U)}},ke=async U=>{try{le&&await q(le.id,"user");const Y=await xe("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:U.name,type:U.type,scope:U.scope,projectPath:U.projectPath,command:U.config?.command,args:U.config?.args||[],url:U.config?.url,headers:U.config?.headers||{},env:U.config?.env||{}})});if(Y.ok){const je=await Y.json();if(je.success)return await wt(),!0;throw new Error(je.error||"Failed to save server via Claude CLI")}else{const je=await Y.json();throw new Error(je.error||"Failed to save server")}}catch(Y){throw console.error("Error saving MCP server:",Y),Y}},q=async(U,Y="user")=>{try{const je=await xe(`/api/mcp/cli/remove/${U}?scope=${Y}`,{method:"DELETE"});if(je.ok){const Ze=await je.json();if(Ze.success)return await wt(),!0;throw new Error(Ze.error||"Failed to delete server via Claude CLI")}else{const Ze=await je.json();throw new Error(Ze.error||"Failed to delete server")}}catch(je){throw console.error("Error deleting MCP server:",je),je}},de=async U=>{try{oe&&await ae(oe.id);const Y=await xe("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:U.name,command:U.config?.command,args:U.config?.args||[],env:U.config?.env||{}})});if(Y.ok){const je=await Y.json();if(je.success)return await pt(),!0;throw new Error(je.error||"Failed to save Codex MCP server")}else{const je=await Y.json();throw new Error(je.error||"Failed to save server")}}catch(Y){throw console.error("Error saving Codex MCP server:",Y),Y}},ae=async U=>{try{const Y=await xe(`/api/codex/mcp/cli/remove/${U}`,{method:"DELETE"});if(Y.ok){const je=await Y.json();if(je.success)return await pt(),!0;throw new Error(je.error||"Failed to delete Codex MCP server")}else{const je=await Y.json();throw new Error(je.error||"Failed to delete server")}}catch(Y){throw console.error("Error deleting Codex MCP server:",Y),Y}},N=()=>{J({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),x(null),Qe(!1)},ie=async U=>{U.preventDefault(),G(!0);try{oe&&await ae(oe.name),await de(ot),N(),B("success")}catch(Y){alert(`Error: ${Y.message}`),B("error")}finally{G(!1)}};l.useEffect(()=>{e&&(Me(),Z(),C(),D(),ne(A.includes(o)?o:"appearance"))},[e,o]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",ee),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ee]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",ye.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ye]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ke.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ke]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",Le.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Le]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",rt),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[rt]);const Me=async()=>{try{const U=localStorage.getItem("claude-settings");if(U){const je=JSON.parse(U);d(je.allowedTools||[]),m(je.disallowedTools||[]),v(je.skipPermissions||!1),y(je.projectSortOrder||"name")}else d([]),m([]),v(!1),y("name");const Y=localStorage.getItem("codex-settings");if(Y){const je=JSON.parse(Y);et(je.permissionMode||"default")}else et("default");await wt(),await pt()}catch(U){console.error("Error loading tool settings:",U),d([]),m([]),v(!1),y("name")}},Z=async()=>{try{const U=await xe("/api/cli/claude/status");if(U.ok){const Y=await U.json();Pe({authenticated:Y.authenticated,email:Y.email,loading:!1,error:Y.error||null})}else Pe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(U){console.error("Error checking Claude auth status:",U),Pe({authenticated:!1,email:null,loading:!1,error:U.message})}},C=async()=>{try{const U=await xe("/api/cli/codex/status");if(U.ok){const Y=await U.json();yt({authenticated:Y.authenticated,email:Y.email,loading:!1,error:Y.error||null})}else yt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(U){console.error("Error checking Codex auth status:",U),yt({authenticated:!1,email:null,loading:!1,error:U.message})}},D=async()=>{try{const U=await xe("/api/cli/gemini/status");if(U.ok){const Y=await U.json();dt({authenticated:Y.authenticated,email:Y.email,loading:!1,error:Y.error||null})}else dt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(U){console.error("Error checking Gemini auth status:",U),dt({authenticated:!1,email:null,loading:!1,error:U.message})}},Ce=U=>{U===0&&(B("success"),Ie==="claude"?Z():Ie==="codex"?C():Ie==="gemini"&&D())},_e=()=>{L(!0),B(null);try{const U={allowedTools:c,disallowedTools:u,skipPermissions:w,projectSortOrder:E,lastUpdated:new Date().toISOString()},Y={permissionMode:Re,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(U)),localStorage.setItem("codex-settings",JSON.stringify(Y)),B("success"),setTimeout(()=>{t()},1e3)}catch(U){console.error("Error saving tool settings:",U),B("error")}finally{L(!1)}},vt=()=>{Q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),se(null),H(!1),Se("")},V=async U=>{U.preventDefault(),he(!0);try{if(W.importMode==="json"){const Y=await xe("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:W.name,jsonConfig:W.jsonInput,scope:W.scope,projectPath:W.projectPath})});if(Y.ok){const je=await Y.json();if(je.success)await wt(),vt(),B("success");else throw new Error(je.error||"Failed to add server via JSON")}else{const je=await Y.json();throw new Error(je.error||"Failed to add server")}}else await ke(W),vt(),B("success")}catch(Y){alert(`Error: ${Y.message}`),B("error")}finally{he(!1)}},At=(U,Y)=>{Q(je=>({...je,config:{...je.config,[U]:Y}}))};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(al,{className:"w-5 h-5 md:w-6 md:h-6 text-primary"}),r.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:r.jsx(Wt,{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 ${T==="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 ${T==="api"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(nl,{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 ${T==="channels"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[r.jsx(pm,{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:[T==="appearance"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:T==="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":s,"aria-label":"Toggle dark mode",children:[r.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),r.jsx("span",{className:`${s?"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:s?r.jsx(ls,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(cs,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),r.jsx("div",{className:"space-y-4",children:r.jsx(jd,{})}),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:E,onChange:U=>y(U.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:()=>Ae(ee==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ee==="dark","aria-label":"Toggle editor theme",children:[r.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),r.jsx("span",{className:`${ee==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:ee==="dark"?r.jsx(ls,{className:"w-3.5 h-3.5 text-gray-700"}):r.jsx(cs,{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:()=>st(!ye),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":ye,"aria-label":"Toggle word wrap",children:[r.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),r.jsx("span",{className:`${ye?"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:()=>we(!Ke),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":Ke,"aria-label":"Toggle minimap",children:[r.jsx("span",{className:"sr-only",children:"Toggle minimap"}),r.jsx("span",{className:`${Ke?"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:()=>ze(!Le),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Le,"aria-label":"Toggle line numbers",children:[r.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),r.jsx("span",{className:`${Le?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),r.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),r.jsxs("select",{value:rt,onChange:U=>Xe(U.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"})]})]})})]})]})}),_&&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(le?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:vt,children:r.jsx(Wt,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:V,className:"p-4 space-y-4",children:[!le&&r.jsxs("div",{className:"flex gap-2 mb-4",children:[r.jsx("button",{type:"button",onClick:()=>Q(U=>({...U,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${W.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:()=>Q(U=>({...U,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${W.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")})]}),W.importMode==="form"&&le&&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:[W.scope==="user"?r.jsx(Na,{className:"w-4 h-4"}):r.jsx(_r,{className:"w-4 h-4"}),r.jsx("span",{className:"text-sm",children:W.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),W.scope==="local"&&W.projectPath&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",W.projectPath]})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),W.importMode==="form"&&!le&&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:()=>Q(U=>({...U,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${W.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(Na,{className:"w-4 h-4"}),r.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),r.jsx("button",{type:"button",onClick:()=>Q(U=>({...U,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${W.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(_r,{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:W.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),W.scope==="local"&&!le&&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:W.projectPath,onChange:U=>Q(Y=>({...Y,projectPath:U.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:W.scope==="local",children:[r.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),n.map(U=>r.jsx("option",{value:U.path||U.fullPath,children:U.displayName||U.name},U.name))]}),W.projectPath&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:W.projectPath})})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[r.jsxs("div",{className:W.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(_t,{value:W.name,onChange:U=>{Q(Y=>({...Y,name:U.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),W.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:W.type,onChange:U=>{Q(Y=>({...Y,type:U.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"})]})]})]}),le&&W.raw&&W.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:le.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(W.raw,null,2)})]}),W.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:W.jsonInput,onChange:U=>{Q(Y=>({...Y,jsonInput:U.target.value}));try{if(U.target.value.trim()){const Y=JSON.parse(U.target.value);Y.type?Y.type==="stdio"&&!Y.command?Se(i("mcpForm.validation.stdioRequiresCommand")):(Y.type==="http"||Y.type==="sse")&&!Y.url?Se(i("mcpForm.validation.httpRequiresUrl",{type:Y.type})):Se(""):Se(i("mcpForm.validation.missingType"))}}catch{U.target.value.trim()?Se(i("mcpForm.validation.invalidJson")):Se("")}},className:`w-full px-3 py-2 border ${ge?"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:`{
|
|
188
|
+
"type": "stdio",
|
|
189
|
+
"command": "/path/to/server",
|
|
190
|
+
"args": ["--api-key", "abc123"],
|
|
191
|
+
"env": {
|
|
192
|
+
"CACHE_DIR": "/tmp"
|
|
193
|
+
}
|
|
194
|
+
}`,required:!0}),ge&&r.jsx("p",{className:"text-xs text-red-500 mt-1",children:ge}),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"}']})]})}),W.importMode==="form"&&W.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(_t,{value:W.config.command,onChange:U=>At("command",U.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(W.config.args)?W.config.args.join(`
|
|
195
|
+
`):"",onChange:U=>At("args",U.target.value.split(`
|
|
196
|
+
`).filter(Y=>Y.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
|
|
197
|
+
abc123`})]})]}),W.importMode==="form"&&(W.type==="sse"||W.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(_t,{value:W.config.url,onChange:U=>At("url",U.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),W.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(W.config.env||{}).map(([U,Y])=>`${U}=${Y}`).join(`
|
|
198
|
+
`),onChange:U=>{const Y={};U.target.value.split(`
|
|
199
|
+
`).forEach(je=>{const[Ze,...ft]=je.split("=");Ze&&Ze.trim()&&(Y[Ze.trim()]=ft.join("=").trim())}),At("env",Y)},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
|
|
200
|
+
DEBUG=true`})]}),W.importMode==="form"&&(W.type==="sse"||W.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(W.config.headers||{}).map(([U,Y])=>`${U}=${Y}`).join(`
|
|
201
|
+
`),onChange:U=>{const Y={};U.target.value.split(`
|
|
202
|
+
`).forEach(je=>{const[Ze,...ft]=je.split("=");Ze&&Ze.trim()&&(Y[Ze.trim()]=ft.join("=").trim())}),At("headers",Y)},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
|
|
203
|
+
X-API-Key=your-key`})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(Ge,{type:"button",variant:"outline",onClick:vt,children:i("mcpForm.actions.cancel")}),r.jsx(Ge,{type:"submit",disabled:ce,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(ce?"mcpForm.actions.saving":le?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),Ye&&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(oe?"mcpForm.title.edit":"mcpForm.title.add")}),r.jsx(Ge,{variant:"ghost",size:"sm",onClick:N,children:r.jsx(Wt,{className:"w-4 h-4"})})]}),r.jsxs("form",{onSubmit:ie,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(_t,{value:ot.name,onChange:U=>J(Y=>({...Y,name:U.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(_t,{value:ot.config?.command||"",onChange:U=>J(Y=>({...Y,config:{...Y.config,command:U.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:(ot.config?.args||[]).join(`
|
|
204
|
+
`),onChange:U=>J(Y=>({...Y,config:{...Y.config,args:U.target.value.split(`
|
|
205
|
+
`).filter(je=>je.trim())}})),placeholder:`--port
|
|
206
|
+
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(ot.config?.env||{}).map(([U,Y])=>`${U}=${Y}`).join(`
|
|
207
|
+
`),onChange:U=>{const Y={};U.target.value.split(`
|
|
208
|
+
`).forEach(je=>{const[Ze,...ft]=je.split("=");Ze&&ft.length>0&&(Y[Ze.trim()]=ft.join("=").trim())}),J(je=>({...je,config:{...je.config,env:Y}}))},placeholder:`API_KEY=xxx
|
|
209
|
+
DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[r.jsx(Ge,{type:"button",variant:"outline",onClick:N,children:i("mcpForm.actions.cancel")}),r.jsx(Ge,{type:"submit",disabled:M||!ot.name||!ot.config?.command,className:"bg-green-600 hover:bg-green-700 text-white",children:i(M?"mcpForm.actions.saving":oe?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),T==="api"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(Tv,{})}),T==="channels"&&r.jsx("div",{className:"space-y-6 md:space-y-8",children:r.jsx(Dv,{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:[k==="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")]}),k==="error"&&r.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[r.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),r.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[r.jsx(Ge,{variant:"outline",onClick:t,disabled:S,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),T!=="channels"&&r.jsx(Ge,{onClick:_e,disabled:S,className:"flex-1 sm:flex-none h-10 bg-primary hover:bg-primary/90 disabled:opacity-50 touch-manipulation",children:S?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(Pv,{isOpen:O,onClose:()=>te(!1),provider:Ie,project:Fe,onComplete:Ce,isAuthenticated:Ie==="claude"?Ne.authenticated:Ie==="codex"?at.authenticated:!1},Ie)]}):null}const Lv=({isOpen:e,onToggle:t,autoExpandTools:n,onAutoExpandChange:o,showRawParameters:s,onShowRawParametersChange:a,showThinking:i,onShowThinkingChange:c,autoScrollToBottom:d,onAutoScrollChange:u,sendByCtrlEnter:m,onSendByCtrlEnterChange:p,isMobile:f})=>{const{t:g}=kt("settings"),[h,w]=l.useState(e),[v,S]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:L}=Ls(),[k,B]=l.useState(()=>{const P=localStorage.getItem("quickSettingsHandlePosition");if(P)try{return JSON.parse(P).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[E,y]=l.useState(!1),[I,$]=l.useState(0),[_,H]=l.useState(0),[le,se]=l.useState(!1),W=l.useRef(null),Q=l.useRef({min:10,max:90}),ce=5;l.useEffect(()=>{w(e)},[e]),l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:k}))},[k]);const he=l.useCallback(()=>f?{bottom:`${window.innerHeight*k/100}px`}:{top:`${k}%`,transform:"translateY(-50%)"},[k,f]),be=l.useCallback(P=>{P.stopPropagation();const j=P.type.includes("touch")?P.touches[0].clientY:P.clientY;$(j),H(k),se(!1),y(!1)},[k]),pe=l.useCallback(P=>{if(I===0)return;const j=P.type.includes("touch")?P.touches[0].clientY:P.clientY,T=Math.abs(j-I);if(!E&&T>ce&&(y(!0),se(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",P.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!E)return;P.type.includes("touch")&&P.preventDefault();const ne=j-I;let ge;f?ge=-(ne/window.innerHeight)*100:ge=ne/window.innerHeight*100;let Se=_+ge;Se=Math.max(Q.current.min,Math.min(Q.current.max,Se)),B(Se)},[E,I,_,f,ce]),K=l.useCallback(()=>{y(!1),$(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);l.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),l.useEffect(()=>{if(I!==0){const P=ge=>pe(ge),j=()=>K(),T=ge=>pe(ge),ne=()=>K();return document.addEventListener("mousemove",P),document.addEventListener("mouseup",j),document.addEventListener("touchmove",T,{passive:!1}),document.addEventListener("touchend",ne),()=>{document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",j),document.removeEventListener("touchmove",T),document.removeEventListener("touchend",ne)}}},[I,pe,K]);const De=P=>{if(le){P.preventDefault(),se(!1);return}const j=!h;w(j),t(j)};return r.jsxs(r.Fragment,{children:[r.jsx("button",{ref:W,onClick:De,onMouseDown:P=>{be(P)},onTouchStart:P=>{be(P)},className:`fixed ${h?"right-64":"right-0"} z-50 ${E?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${E?"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 ${E?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...he(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":g(E?"quickSettings.dragHandle.dragging":h?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:g(E?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:E?r.jsx(Wp,{className:"h-5 w-5 text-primary"}):h?r.jsx(Wr,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):r.jsx(tl,{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 ${h?"translate-x-0":"translate-x-full"} ${f?"h-screen":""}`,children:r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:r.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[r.jsx(hm,{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 ${f?"pb-mobile-nav":""}`,children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children: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:[L?r.jsx(ls,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):r.jsx(cs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.darkMode")]}),r.jsx(mp,{})]}),r.jsx("div",{children:r.jsx(jd,{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(sl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoExpandTools")]}),r.jsx("input",{type:"checkbox",checked:n,onChange:P=>o(P.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),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(rl,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showRawParameters")]}),r.jsx("input",{type:"checkbox",checked:s,onChange:P=>a(P.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),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(el,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.showThinking")]}),r.jsx("input",{type:"checkbox",checked:i,onChange:P=>c(P.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),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(kp,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.autoScrollToBottom")]}),r.jsx("input",{type:"checkbox",checked:d,onChange:P=>u(P.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]})]}),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(ol,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),g("quickSettings.sendByCtrlEnter")]}),r.jsx("input",{type:"checkbox",checked:m,onChange:P=>p(P.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-ring focus:ring-2 bg-gray-100 dark:bg-gray-800 checked:bg-primary"})]}),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:v==="default",onChange:()=>{S("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(Vn,{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:v==="prompt",onChange:()=>{S("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(Fs,{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:v==="vibe"||v==="instructions"||v==="architect",onChange:()=>{S("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(Os,{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")})]})]})]})]})]})]})}),h&&r.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:De})]})},Sd=l.createContext({user:null,token:null,login:()=>{},register:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,error:null}),No=()=>{const e=l.useContext(Sd);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e},Ov=({children:e})=>{const[t,n]=l.useState(null),[o,s]=l.useState(localStorage.getItem("auth-token")),[a,i]=l.useState(!0),[c,d]=l.useState(!1),[u,m]=l.useState(null);l.useEffect(()=>{p()},[]);const p=async()=>{try{if(i(!0),m(null),(await(await xt.auth.status()).json()).needsSetup){d(!0),i(!1);return}if(o)try{const L=await xt.auth.user();if(L.ok){const k=await L.json();n(k.user),d(!1)}else localStorage.removeItem("auth-token"),s(null),n(null)}catch(L){console.error("Token verification failed:",L),localStorage.removeItem("auth-token"),s(null),n(null)}}catch(v){console.error("[AuthContext] Auth status check failed:",v),m("Failed to check authentication status")}finally{i(!1)}},w={user:t,token:o,login:async(v,S)=>{try{m(null);const L=await xt.auth.login(v,S),k=await L.json();return L.ok?(s(k.token),n(k.user),localStorage.setItem("auth-token",k.token),{success:!0}):(m(k.error||"Login failed"),{success:!1,error:k.error||"Login failed"})}catch(L){console.error("Login error:",L);const k="Network error. Please try again.";return m(k),{success:!1,error:k}}},register:async(v,S)=>{try{m(null);const L=await xt.auth.register(v,S),k=await L.json();return L.ok?(s(k.token),n(k.user),d(!1),localStorage.setItem("auth-token",k.token),{success:!0}):(m(k.error||"Registration failed"),{success:!1,error:k.error||"Registration failed"})}catch(L){console.error("Registration error:",L);const k="Network error. Please try again.";return m(k),{success:!1,error:k}}},logout:()=>{s(null),n(null),localStorage.removeItem("auth-token"),o&&xt.auth.logout().catch(v=>{console.error("Logout endpoint error:",v)})},isLoading:a,needsSetup:c,error:u};return r.jsx(Sd.Provider,{value:w,children:e})},Nd=l.createContext(null),Fv=()=>{const e=l.useContext(Nd);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},$v=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},Bv=()=>{const e=l.useRef(null),t=l.useRef(!1),[n,o]=l.useState(null),[s,a]=l.useState(!1),i=l.useRef(null),c=l.useRef(!1),d=l.useRef([]),u=l.useRef([]),m=l.useRef(null),p=l.useRef(0),{token:f}=No(),g=l.useCallback(()=>{if(m.current||t.current)return;const y=()=>{if(m.current=null,t.current){u.current=[];return}const I=u.current.shift();I&&(p.current+=1,o({...I,__messageSeq:p.current}),u.current.length>0&&(m.current=setTimeout(y,0)))};m.current=setTimeout(y,0)},[]),h=l.useCallback(y=>{u.current.push(y),g()},[g]),w=l.useCallback((y,I)=>{h({type:"connection-error",error:I,provider:y?.provider||(typeof y?.type=="string"?y.type.replace(/-command$/,""):"claude"),sessionId:y?.sessionId||y?.options?.sessionId||null,clientRequestId:y?.clientRequestId||null})},[h]),v=l.useCallback(y=>{y.timeoutId&&(clearTimeout(y.timeoutId),y.timeoutId=null)},[]),S=l.useCallback(y=>{if(y.readyState!==WebSocket.OPEN)return;d.current.splice(0,d.current.length).forEach($=>{v($),y.send(JSON.stringify($.payload))})},[v]),L=l.useCallback(y=>{if(!y||typeof y!="object"||y.clientRequestId)return y;const I=typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2,10)}`;return{...y,clientRequestId:I}},[]),k=l.useCallback(()=>{if(t.current||c.current)return;const y=e.current;if(!(y&&(y.readyState===WebSocket.OPEN||y.readyState===WebSocket.CONNECTING)))try{const I=$v(f);if(!I){d.current.splice(0,d.current.length).forEach(H=>{v(H),w(H.payload,"No authentication token found for WebSocket connection")});return}c.current=!0;const $=new WebSocket(I);e.current=$,$.onopen=()=>{c.current=!1,a(!0),e.current=$,h({type:"ws-connection-state",state:"connected"}),S($)},$.onmessage=_=>{try{const H=JSON.parse(_.data);h(H)}catch(H){console.error("Error parsing WebSocket message:",H)}},$.onclose=()=>{c.current=!1,a(!1),e.current===$&&(e.current=null),h({type:"ws-connection-state",state:"disconnected"}),i.current=setTimeout(()=>{t.current||k()},3e3)},$.onerror=_=>{console.error("WebSocket error:",_)}}catch(I){c.current=!1,console.error("Error creating WebSocket connection:",I)}},[v,w,S,f]);l.useEffect(()=>(t.current=!1,k(),()=>{c.current=!1,i.current&&clearTimeout(i.current),m.current&&(clearTimeout(m.current),m.current=null),u.current=[],e.current&&(e.current.close(),e.current=null)}),[k,f]),l.useEffect(()=>()=>{t.current=!0,c.current=!1,i.current&&clearTimeout(i.current),m.current&&(clearTimeout(m.current),m.current=null),u.current=[],d.current.splice(0,d.current.length).forEach(I=>v(I)),e.current&&(e.current.close(),e.current=null)},[v]);const B=l.useCallback(y=>{const I=L(y),$=e.current;if($&&$.readyState===WebSocket.OPEN){try{$.send(JSON.stringify(I))}catch(H){throw H}return}h({type:"ws-connection-state",state:"connecting",sessionId:I?.sessionId||I?.options?.sessionId||null,clientRequestId:I?.clientRequestId||null});const _={payload:I,timeoutId:setTimeout(()=>{d.current=d.current.filter(H=>H!==_),w(I,"Unable to reach the chat server. Message was not sent.")},1e4)};d.current.push(_),k()},[k,w,h,L]);return l.useMemo(()=>({ws:e.current,sendMessage:B,latestMessage:n,isConnected:s}),[B,n,s])},zv=({children:e})=>{const t=Bv();return r.jsx(Nd.Provider,{value:t,children:e})},Uv=()=>{const{t:e}=kt("auth"),[t,n]=l.useState(""),[o,s]=l.useState(""),[a,i]=l.useState(""),[c,d]=l.useState(!1),[u,m]=l.useState(""),{register:p}=No(),f=async g=>{if(g.preventDefault(),m(""),o!==a){m(e("register.errors.passwordMismatch"));return}if(t.length<3){m(e("register.errors.usernameTooShort"));return}if(o.length<6){m(e("register.errors.passwordTooShort"));return}d(!0);const h=await p(t,o);h.success||m(h.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(kn,{size:64})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e("register.welcomeTitle")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:e("register.description")})]}),r.jsxs("form",{onSubmit:f,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:e("register.username")}),r.jsx("input",{type:"text",id:"username",value:t,onChange: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:o,onChange:g=>s(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")})})]})})})},Wv=()=>{const{t:e}=kt("auth"),[t,n]=l.useState(""),[o,s]=l.useState(""),[a,i]=l.useState(!1),[c,d]=l.useState(""),{login:u}=No(),m=async p=>{if(p.preventDefault(),d(""),!t||!o){d(e("login.errors.requiredFields"));return}i(!0);const f=await u(t,o);f.success||d(f.error),i(!1)};return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx("div",{className:"w-full max-w-md",children:r.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("img",{src:"/logo-128.png",alt:"Logo",className:"w-16 h-16 rounded-lg shadow-sm"})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e("login.title")}),r.jsx("p",{className:"text-muted-foreground mt-2",children:e("login.description")})]}),r.jsxs("form",{onSubmit:m,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:p=>n(p.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.username"),required:!0,disabled:a})]}),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:o,onChange:p=>s(p.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",placeholder:e("login.placeholders.password"),required:!0,disabled:a})]}),c&&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")})})]})})})},Hv=()=>r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("img",{src:"/logo-128.png",alt:"Logo",className:"w-16 h-16 rounded-lg shadow-sm"})}),r.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Axhub Genie"}),r.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),r.jsx("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),r.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),qv=({children:e})=>{const{user:t,isLoading:n,needsSetup:o}=No();return n?r.jsx(Hv,{}):o?r.jsx(Uv,{}):t?e:r.jsx(Wv,{})};function Ur(e,t){const[n,o]=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)),o(i)}catch(i){console.log(i)}}]}const Kv=3e3;function sn(e){return typeof e=="string"&&e.trim().length>0}function Gv(e="integration"){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}_${crypto.randomUUID()}`:`${e}_${Date.now()}_${Math.random().toString(36).slice(2,10)}`}function Vv(){return typeof window>"u"?null:`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/agent/ws`}function Jv({enabled:e,channel:t,clientId:n,sessionId:o}){const s=l.useRef(null),a=l.useRef(null),i=l.useRef(!1),c=l.useRef(!1),d=l.useRef(0),u=l.useRef(sn(o)?o.trim():null),[m,p]=l.useState(null),[f,g]=l.useState(!1),h=l.useMemo(()=>e===!0&&sn(t)&&sn(n),[e,t,n]);l.useEffect(()=>{u.current=sn(o)?o.trim():null},[o]);const w=l.useCallback(E=>{d.current+=1,p({...E,__messageSeq:d.current})},[]),v=l.useCallback(()=>{const E=s.current;E&&(E.close(),s.current=null),g(!1),i.current=!1},[]),S=l.useCallback((E,y=s.current)=>!E||!y||y.readyState!==WebSocket.OPEN?!1:(y.send(JSON.stringify({type:"integration.ack",requestId:E,payload:{accepted:!0,available:!0,pageUrl:typeof window<"u"?window.location.href:null,sessionId:u.current}})),!0),[]),L=l.useCallback((E=s.current)=>{!h||!E||E.readyState!==WebSocket.OPEN||E.send(JSON.stringify({type:"integration.connect",requestId:Gv("integration_connect"),payload:{role:"frontend-page",channel:t.trim(),clientId:n.trim(),pageUrl:typeof window<"u"?window.location.href:null,sessionId:sn(o)?o.trim():null,capabilities:["context.update","prompt.update","presence.report"]}}))},[t,n,h,o]),k=l.useCallback(()=>{if(!h||c.current||i.current)return;const E=s.current;if(E&&(E.readyState===WebSocket.OPEN||E.readyState===WebSocket.CONNECTING))return;const y=Vv();if(!y)return;i.current=!0;const I=new WebSocket(y);s.current=I,I.onopen=()=>{i.current=!1,s.current=I,g(!0),L(I)},I.onmessage=$=>{try{const _=JSON.parse($.data);_&&typeof _.type=="string"&&_.type.startsWith("integration.")&&(_.type==="integration.ping"&&S(_.requestId||null,I),w(_))}catch(_){console.error("Error parsing integration WebSocket message:",_)}},I.onclose=()=>{s.current===I&&(s.current=null),i.current=!1,g(!1),!c.current&&h&&(a.current=setTimeout(()=>{a.current=null,k()},Kv))},I.onerror=$=>{console.error("Integration WebSocket error:",$)}},[L,w,h,S]);l.useEffect(()=>{if(c.current=!1,!h){a.current&&(clearTimeout(a.current),a.current=null),v();return}return k(),()=>{a.current&&(clearTimeout(a.current),a.current=null),v()}},[v,k,h]),l.useEffect(()=>()=>{c.current=!0,a.current&&(clearTimeout(a.current),a.current=null),v()},[v]),l.useEffect(()=>{h&&L()},[L,h,o]);const B=l.useCallback(E=>{const y=s.current;return!y||y.readyState!==WebSocket.OPEN?!1:(y.send(JSON.stringify(E)),!0)},[]);return{integrationWs:s.current,latestIntegrationMessage:m,sendIntegrationMessage:B,isIntegrationConnected:f,isIntegrationEnabled:h}}function Ts(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.replace(/\\/g,"/");return n==="/"?"/":/^[A-Za-z]:\/?$/.test(n)?`${n[0]}:/`:n.replace(/\/+$/,"")}function ns(e,t){const n=Ts(t);return n?[e?.fullPath,e?.path].some(o=>Ts(o)===n):!1}function qi(){const e=Tu(),{sessionId:t}=Mu(),[n]=Du(),{t:o}=kt("common");l.useRef(0);const{updateAvailable:s,latestVersion:a,currentVersion:i,releaseInfo:c}=kd(),[d,u]=l.useState(!1),[m,p]=l.useState([]),[f,g]=l.useState(null),[h,w]=l.useState(null),[v,S]=l.useState(0),[L,k]=l.useState("chat"),[B,E]=l.useState(!1),y=B&&!1,[I,$]=l.useState(!1),[_,H]=l.useState(!0),[le,se]=l.useState(null),[W,Q]=l.useState(!1),[ce,he]=l.useState(!1),[be,pe]=l.useState("appearance"),[K,De]=l.useState(!1),[P,j]=Ur("autoExpandTools",!1),[T,ne]=Ur("showRawParameters",!1),[ge,Se]=Ur("showThinking",!0),[A,ee]=Ur("autoScrollToBottom",!0),[Ae,ye]=Ur("sendByCtrlEnter",!1),[st,Ke]=Ur("sidebarVisible",!0),[we,Le]=l.useState(!1),[ze,rt]=l.useState(new Set),[Xe,Ve]=l.useState(new Set),fe=l.useRef({sessionId:null,status:"idle"}),Re=l.useCallback((z,me="claude")=>{if(!z)return me;try{const ue=localStorage.getItem("session-provider-map");if(!ue)return me;const Ee=JSON.parse(ue)?.[z];return typeof Ee=="string"&&Ee?Ee:me}catch{return me}},[]),[et,Ye]=l.useState(0),Qe=l.useRef({selectionKey:null}),ot=l.useRef({attemptedKeys:new Set}),J=l.useRef(m),oe=n.get("cwd")||n.get("workdir"),x=l.useMemo(()=>Ts(oe),[oe]),M=n.get("project")||n.get("projectName"),G=n.get("provider")||n.get("tool")||n.get("cli");n.get("model");const O=n.get("context"),te=n.get("prompt"),Ie=n.get("integrationWs"),Oe=n.get("integrationClientId"),Fe=n.get("integrationChannel"),ct=n.toString(),Pe=m.find(z=>!!(ns(z,x)||M&&(z.fullPath===M||z.path===M)))?.name||null,at=l.useCallback((z,me)=>{const ue=n.toString(),re=ue?`${z}?${ue}`:z;e(re,me)},[e,n]),{ws:yt,sendMessage:Nt,latestMessage:dt}=Fv(),{latestIntegrationMessage:pt,sendIntegrationMessage:wt}=Jv({enabled:Ie==="1",clientId:Oe,channel:Fe,sessionId:h?.id||t||null}),ke=l.useCallback(z=>typeof z!="string"?!1:/^new-session-\d+$/i.test(z)||/^codex-\d+$/i.test(z),[]),q=l.useRef(null),[de,ae]=l.useState(!1);l.useEffect(()=>{L==="files"&&k("chat")},[L]),l.useEffect(()=>{const z=()=>{const me=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");ae(me),document.addEventListener("touchstart",{}),me?(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 z(),window.matchMedia("(display-mode: standalone)").addEventListener("change",z),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",z)}},[]),l.useEffect(()=>{const z=()=>{E(window.innerWidth<768)};return z(),window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[]),l.useEffect(()=>{Z()},[]),l.useEffect(()=>{J.current=m},[m]),l.useEffect(()=>{if(!x&&!M||m.length===0)return;const z=`${x||""}::${M||""}`;if(Qe.current.selectionKey===z)return;if(h){Qe.current.selectionKey=z;return}let me=null;if(x&&(me=m.find(ue=>ns(ue,x))),!me&&M){const ue=M.trim().toLowerCase();me=m.find(re=>[re.name,re.displayName,re.path,re.fullPath].some(Ue=>typeof Ue=="string"&&Ue.toLowerCase()===ue))}me&&g(me),Qe.current.selectionKey=z},[x,M,m,h]),l.useEffect(()=>{if(!x||_||h||J.current.some(Ee=>ns(Ee,x)))return;const me=`cwd:${x}`;if(ot.current.attemptedKeys.has(me))return;ot.current.attemptedKeys.add(me);let ue=!1;return(async()=>{try{const Ee=await xt.createProject(x),Ue=await Ee.json().catch(()=>({}));if(!Ee.ok){const tt=Ue?.error||"Unknown error";if(tt.includes("Project already configured")){await Z();return}console.warn(`[URL] Failed to auto-create project for cwd "${x}": ${tt}`);return}if(ue)return;Ue?.project&&g(Ue.project),await Z()}catch(Ee){console.error(`[URL] Error auto-creating project for cwd "${x}":`,Ee)}})(),()=>{ue=!0}},[x,_,h]);const N=(z,me,ue,re)=>{if(!ue||!re)return!0;const Ee=z?.find(nt=>nt.name===ue.name),Ue=me?.find(nt=>nt.name===ue.name);if(!Ee||!Ue)return!1;const tt=nt=>[...nt.sessions||[],...nt.codexSessions||[],...nt.geminiSessions||[],...nt.opencodeSessions||[]].find(Mt=>Mt.id===re.id),jt=tt(Ee),mt=tt(Ue);return!jt||!mt?!1:jt.id===mt.id&&jt.title===mt.title&&jt.created_at===mt.created_at&&jt.updated_at===mt.updated_at},ie=(z,me)=>!z||!me?z!==me:z.name!==me.name||z.displayName!==me.displayName||z.fullPath!==me.fullPath||z.path!==me.path,Me=z=>{if(!z)return!1;if(t===z)return!0;const me=fe.current;return me?.sessionId===z&&me?.status!=="missing"&&me?.status!=="error"?!0:ze.has(z)||Xe.has(z)};l.useEffect(()=>{if(dt){if(dt.type==="loading_progress"){q.current&&(clearTimeout(q.current),q.current=null),se(dt),dt.phase==="complete"&&(q.current=setTimeout(()=>{se(null),q.current=null},500));return}if(dt.type==="projects_updated"){if(dt.changedFile&&h&&f){const re=dt.changedFile.replace(/\\/g,"/").split("/"),Ee=re[re.length-1]||"",Ue=Ee.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]||Ee.replace(".jsonl","");(dt.changedSessionId||Ue)===h.id&&(ze.has(h.id)||Ye(mt=>mt+1))}if(h&&ze.has(h.id)||ze.size>0&&Array.from(ze).some(ue=>ue.startsWith("new-session-"))){const ue=dt.projects;if(!N(m,ue,f,h))return}const me=dt.projects;if(p(me),f){const ue=me.find(re=>re.name===f.name);if(ue&&(ie(f,ue)&&g(ue),h)){const Ee=[...ue.sessions||[],...ue.codexSessions||[],...ue.geminiSessions||[],...ue.opencodeSessions||[]].find(Ue=>Ue.id===h.id);if(!Ee)Me(h.id)||w(null);else{const Ue={...Ee,__provider:h.__provider||Re(Ee.id,"claude"),__projectName:h.__projectName||ue.name};(Ue.title!==h.title||Ue.updated_at!==h.updated_at||Ue.__provider!==h.__provider||Ue.__projectName!==h.__projectName)&&w(Ue)}}}}}return()=>{q.current&&(clearTimeout(q.current),q.current=null)}},[ze,dt,Xe,Re,f,h,t]);const Z=async(z={})=>{const{background:me=!1}=z;try{me||H(!0);const re=await(await xt.projects()).json();p(Ee=>Ee.length===0||re.some((tt,jt)=>{const mt=Ee[jt];return mt?tt.name!==mt.name||tt.displayName!==mt.displayName||tt.fullPath!==mt.fullPath||JSON.stringify(tt.sessionMeta)!==JSON.stringify(mt.sessionMeta)||JSON.stringify(tt.sessions)!==JSON.stringify(mt.sessions)||JSON.stringify(tt.codexSessions)!==JSON.stringify(mt.codexSessions)||JSON.stringify(tt.geminiSessions)!==JSON.stringify(mt.geminiSessions)||JSON.stringify(tt.opencodeSessions)!==JSON.stringify(mt.opencodeSessions):!0})||re.length!==Ee.length?re:Ee)}catch(ue){console.error("Error fetching projects:",ue)}finally{me||H(!1)}};window.refreshProjects=(z={})=>Z({background:!0,...z}),window.openSettings=l.useCallback((z="appearance")=>{pe(z),he(!0)},[]),l.useEffect(()=>{if(!t||m.length===0)return;const z=h?.id||null;f?.name;const me=z!==t,ue=G||h?.__provider||localStorage.getItem("selected-provider")||"claude",re=Re(t,ue),Ee=`${t}::${ct}`,Ue=ke(t),tt=(We,nt,Ct)=>{if(!We||!nt)return!1;const Mt=m.find(Dt=>Dt.name===We.name)||We,Ft={...nt,__provider:Ct||re,__projectName:Mt.name};return g(Dt=>Dt?.name===Mt.name?Dt:Mt),w(Dt=>Dt?.id===Ft.id&&Dt?.__provider===Ft.__provider&&Dt?.__projectName===Ft.__projectName?Dt:Ft),me&&k("chat"),fe.current={sessionId:t,status:"resolved",resolutionKey:Ee},!0};for(const We of m){const nt=[{items:We.sessions,provider:Re(t,ue)},{items:We.codexSessions,provider:"codex"},{items:We.geminiSessions,provider:"gemini"},{items:We.opencodeSessions,provider:"opencode"}];for(const Ct of nt){const Mt=Ct.items?.find(wr=>wr.id===t);if(Mt){tt(We,Mt,Ct.provider);return}}}if(f&&(w({id:t,title:"New Session",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),__provider:re,__projectName:f.name}),me&&k("chat"),fe.current={sessionId:t,status:"placeholder",resolutionKey:Ee}),Ue||fe.current.sessionId===t&&fe.current.status==="resolving"&&fe.current.resolutionKey===Ee)return;fe.current={sessionId:t,status:"resolving",resolutionKey:Ee};let jt=!1;return(async()=>{try{const We=await xt.resolveSession(t,re),nt=await We.json().catch(()=>({}));if(jt)return;if(!We.ok||!nt?.found||!nt?.project||!nt?.session){fe.current={sessionId:t,status:"missing",resolutionKey:Ee};return}if(nt?.provider)try{const Dt=localStorage.getItem("session-provider-map"),kr=Dt?JSON.parse(Dt):{};kr[t]=nt.provider,localStorage.setItem("session-provider-map",JSON.stringify(kr))}catch{}if(!tt(nt.project,nt.session,nt.provider||re))return;const Mt=new URLSearchParams(ct);(nt.project.fullPath||nt.project.path)&&Mt.set("project",nt.project.fullPath||nt.project.path),nt.provider&&Mt.set("provider",nt.provider);const wr=`/session/${t}${Mt.toString()?`?${Mt.toString()}`:""}`,Ft=`${window.location.pathname}${window.location.search}`;wr!==Ft&&e(wr,{replace:!0})}catch(We){jt||(console.error("Error resolving session route:",We),fe.current={sessionId:t,status:"error",resolutionKey:Ee})}})(),()=>{jt=!0}},[ke,e,m,Re,ct,f?.name,h?.id,t]);const C=z=>{g(z),w(null),at("/"),B&&$(!1)},D=z=>{if(w(z),L!=="git"&&L!=="preview"&&k("chat"),B){const me=z.__projectName,ue=f?.name;me!==ue&&$(!1)}at(`/session/${z.id}`)},Ce=z=>{if(z?.name&&typeof window<"u")try{localStorage.removeItem(`chat_messages_${z.name}`),localStorage.removeItem(`draft_input_${z.name}`)}catch(me){console.warn("Failed to clear local chat cache for new session:",me)}g(z),w(null),S(me=>me+1),k("chat"),at("/"),B&&$(!1)},_e=z=>{h?.id===z&&(w(null),at("/")),p(me=>me.map(ue=>({...ue,sessions:ue.sessions?.filter(re=>re.id!==z)||[],sessionMeta:{...ue.sessionMeta,total:Math.max(0,(ue.sessionMeta?.total||0)-1)}})))},vt=async()=>{try{const me=await(await xt.projects()).json();if(p(ue=>me.some((Ee,Ue)=>{const tt=ue[Ue];return tt?Ee.name!==tt.name||Ee.displayName!==tt.displayName||Ee.fullPath!==tt.fullPath||JSON.stringify(Ee.sessionMeta)!==JSON.stringify(tt.sessionMeta)||JSON.stringify(Ee.sessions)!==JSON.stringify(tt.sessions):!0})||me.length!==ue.length?me:ue),f){const ue=me.find(re=>re.name===f.name);if(ue&&(ie(f,ue)&&g(ue),h)){const Ee=[...ue.sessions||[],...ue.codexSessions||[],...ue.geminiSessions||[],...ue.opencodeSessions||[]].find(Ue=>Ue.id===h.id);if(!Ee)Me(h.id)||w(null);else{const Ue={...Ee,__provider:h.__provider||Re(Ee.id,"claude"),__projectName:h.__projectName||ue.name};(Ue.title!==h.title||Ue.updated_at!==h.updated_at||Ue.__provider!==h.__provider||Ue.__projectName!==h.__projectName)&&w(Ue)}}}}catch(z){console.error("Error refreshing sidebar:",z)}},V=z=>{f?.name===z&&(g(null),w(null),at("/")),p(me=>me.filter(ue=>ue.name!==z))},At=l.useCallback(z=>{z&&rt(me=>new Set([...me,z]))},[]),U=l.useCallback(z=>{z&&rt(me=>{const ue=new Set(me);return ue.delete(z),ue})},[]),Y=l.useCallback(z=>{z&&Ve(me=>new Set([...me,z]))},[]),je=l.useCallback(z=>{z&&Ve(me=>{const ue=new Set(me);return ue.delete(z),ue})},[]),Ze=l.useCallback((z,me=null)=>{z&&(rt(ue=>{const re=new Set;for(const Ee of ue)me&&Ee===me||Ee.startsWith("new-session-")||re.add(Ee);return re.add(z),re}),Ve(ue=>{const re=new Set;for(const Ee of ue)me&&Ee===me||Ee.startsWith("new-session-")||re.add(Ee);return re.add(z),re}))},[]),ft=()=>{const{t:z}=kt("common"),[me,ue]=l.useState(!1),[re,Ee]=l.useState(""),[Ue,tt]=l.useState("");if(!d)return null;const jt=We=>We?We.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,`
|
|
210
|
+
|
|
211
|
+
`).trim():"",mt=async()=>{ue(!0),Ee(`Starting update...
|
|
212
|
+
`),tt("");try{const We=await xe("/api/system/update",{method:"POST"}),nt=await We.json();We.ok?(Ee(Ct=>Ct+nt.output+`
|
|
213
|
+
`),Ee(Ct=>Ct+`
|
|
214
|
+
✅ Update completed successfully!
|
|
215
|
+
`),Ee(Ct=>Ct+`Please restart the server to apply changes.
|
|
216
|
+
`)):(tt(nt.error||"Update failed"),Ee(Ct=>Ct+`
|
|
217
|
+
❌ Update failed: `+(nt.error||"Unknown error")+`
|
|
218
|
+
`))}catch(We){tt(We.message),Ee(nt=>nt+`
|
|
219
|
+
❌ Update failed: `+We.message+`
|
|
220
|
+
`)}finally{ue(!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":z("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:z("versionUpdate.title")}),r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:c?.title||z("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:z("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:z("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:z("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:[z("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:jt(c.body)})})]}),re&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z("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:re})})]}),!me&&!re&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z("versionUpdate.manualUpgrade")}),r.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:r.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"npm install -g @axhub/genie@latest"})}),r.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:z("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:z(re?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!re&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>{navigator.clipboard.writeText("npm install -g @axhub/genie@latest")},className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:z("versionUpdate.buttons.copyCommand")}),r.jsx("button",{onClick:mt,disabled:me,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:me?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),z("versionUpdate.buttons.updating")]}):z("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:[!B&&r.jsx("div",{className:`chat-sidebar h-full flex-shrink-0 overflow-hidden transition-all duration-300 ${st?"w-[22rem]":"w-[4.25rem]"}`,children:r.jsx("div",{className:"h-full overflow-hidden",children:st?r.jsx(La,{projects:m,selectedProject:f,selectedSession:h,onProjectSelect:C,onSessionSelect:D,onNewSession:Ce,onSessionDelete:_e,onProjectDelete:V,isLoading:_,loadingProgress:le,onRefresh:vt,onShowSettings:()=>he(!0),updateAvailable:s,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:de,isMobile:B,onToggleSidebar:()=>Ke(!1),lockedProjectName:Pe,showNewProject:we,setShowNewProject:Le}):r.jsxs("div",{className:"h-full flex flex-col items-center gap-3 py-4",children:[r.jsx("button",{onClick:()=>Ke(!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":o("versionUpdate.ariaLabels.showSidebar"),title:o("versionUpdate.ariaLabels.showSidebar"),children:r.jsx(Wr,{className:"w-4 h-4 text-foreground"})}),r.jsx("button",{onClick:()=>he(!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":o("versionUpdate.ariaLabels.settings"),title:o("versionUpdate.ariaLabels.settings"),children:r.jsx(al,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})}),s&&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":o("versionUpdate.ariaLabels.updateAvailable"),title:o("versionUpdate.ariaLabels.updateAvailable"),children:[r.jsx(Fs,{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"})]})]})})}),B&&r.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${I?"opacity-100 visible":"opacity-0 invisible"}`,children:[r.jsx("button",{className:"fixed inset-0 bg-black/40 transition-opacity duration-150 ease-out",onClick:z=>{z.stopPropagation(),$(!1)},onTouchStart:z=>{z.preventDefault(),z.stopPropagation(),$(!1)},"aria-label":o("versionUpdate.ariaLabels.closeSidebar")}),r.jsx("div",{className:`chat-sidebar relative h-full w-[85vw] max-w-sm bg-white shadow-xl transform dark:bg-background sm:w-80 ${I?"translate-x-0":"-translate-x-full"}`,onClick:z=>z.stopPropagation(),onTouchStart:z=>z.stopPropagation(),children:r.jsx(La,{projects:m,selectedProject:f,selectedSession:h,onProjectSelect:C,onSessionSelect:D,onNewSession:Ce,onSessionDelete:_e,onProjectDelete:V,isLoading:_,loadingProgress:le,onRefresh:vt,onShowSettings:()=>he(!0),updateAvailable:s,latestVersion:a,currentVersion:i,releaseInfo:c,onShowVersionModal:()=>u(!0),isPWA:de,isMobile:B,onToggleSidebar:()=>Ke(!1),lockedProjectName:Pe,showNewProject:we,setShowNewProject:Le})})]}),r.jsx("div",{className:"chat-shell flex-1 flex min-w-0 flex-col overflow-hidden ",children:r.jsx(_v,{selectedProject:f,selectedSession:h,activeTab:L,setActiveTab:k,ws:yt,sendMessage:Nt,latestMessage:dt,isMobile:B,isPWA:de,onMenuClick:()=>$(!0),isLoading:_,onInputFocusChange:Q,onSessionActive:At,onSessionInactive:U,onSessionProcessing:Y,onSessionNotProcessing:je,processingSessions:Xe,onReplaceTemporarySession:Ze,onNavigateToSession:z=>at(`/session/${z}`),onShowSettings:()=>he(!0),autoExpandTools:P,showRawParameters:T,showThinking:ge,autoScrollToBottom:A,sendByCtrlEnter:Ae,externalMessageUpdate:et,urlContext:O,urlPrompt:te,integrationClientId:Oe,latestIntegrationMessage:pt,sendIntegrationMessage:wt,onShowNewProject:()=>Le(!0),onNewSession:Ce,newSessionResetNonce:v})}),y,L==="chat"&&r.jsx(Lv,{isOpen:K,onToggle:De,autoExpandTools:P,onAutoExpandChange:j,showRawParameters:T,onShowRawParametersChange:ne,showThinking:ge,onShowThinkingChange:Se,autoScrollToBottom:A,onAutoScrollChange:ee,sendByCtrlEnter:Ae,onSendByCtrlEnterChange:ye,isMobile:B}),r.jsx(Rv,{isOpen:ce,onClose:()=>he(!1),projects:m,initialTab:be}),r.jsx(ft,{})]})}function nb(){return r.jsx(fp,{i18n:bp,children:r.jsx(hp,{children:r.jsx(Ov,{children:r.jsx(zv,{children:r.jsx(qv,{children:r.jsx(Iu,{basename:window.__ROUTER_BASENAME__||"",children:r.jsxs(_u,{children:[r.jsx(Ro,{path:"/",element:r.jsx(qi,{})}),r.jsx(Ro,{path:"/session/:sessionId",element:r.jsx(qi,{})}),r.jsx(Ro,{path:"/review",element:r.jsx(gp,{})})]})})})})})})})}export{nb as default};
|