loki-mode 9.22.4 → 9.22.6
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/README.md +18 -4
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/autonomy/issue-parser.sh +112 -0
- package/autonomy/lib/proof-generator.py +88 -0
- package/autonomy/lib/proof-pr.sh +52 -0
- package/autonomy/loki +147 -3
- package/autonomy/quickstart.sh +342 -5
- package/autonomy/run.sh +26 -0
- package/dashboard/__init__.py +1 -1
- package/docs/EXECUTION-COCKPIT-PLAN.md +289 -0
- package/docs/HARNESS-INTELLIGENCE-PLAN.md +194 -0
- package/docs/ISSUE-TO-PR-GOLDEN-PATH-PLAN.md +257 -0
- package/loki-ts/dist/loki.js +299 -297
- package/mcp/__init__.py +1 -1
- package/package.json +1 -1
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
- package/web-app/dist/assets/{AdminPage-DNGNuAge.js → AdminPage-DLhWX6si.js} +1 -1
- package/web-app/dist/assets/{Avatar-CqAveJaT.js → Avatar-CqyDcUxl.js} +1 -1
- package/web-app/dist/assets/{Badge-BtMejA0Z.js → Badge-BKGSt1n2.js} +1 -1
- package/web-app/dist/assets/{Button-CikxmqSs.js → Button-DuuKHXre.js} +1 -1
- package/web-app/dist/assets/CockpitPage-DdClYERC.js +47 -0
- package/web-app/dist/assets/{ComparePage-BB8DJBWR.js → ComparePage-CUWlqBxv.js} +1 -1
- package/web-app/dist/assets/ErrorBoundary-RwfGKyRJ.js +16 -0
- package/web-app/dist/assets/{EvidenceReceiptPanel-6oquKEjd.js → EvidenceReceiptPanel-CzIgk9sg.js} +1 -1
- package/web-app/dist/assets/{GitHubIssuesPanel-5XLYWzWH.js → GitHubIssuesPanel-CsXVKuyJ.js} +3 -3
- package/web-app/dist/assets/{GitHubPRsPanel-DUfmFYeu.js → GitHubPRsPanel-CYRp1eKS.js} +3 -3
- package/web-app/dist/assets/{HomePage-DZ4MmOdH.js → HomePage-CVJcI5pQ.js} +3 -3
- package/web-app/dist/assets/LoginPage-BBJNV9Qb.js +1 -0
- package/web-app/dist/assets/{MagicPage-CFbX5gWg.js → MagicPage-CIi9P8jK.js} +1 -1
- package/web-app/dist/assets/{MetricsPage-DbL6xmRQ.js → MetricsPage-Bm34ipiy.js} +2 -2
- package/web-app/dist/assets/{NotFoundPage-BUrjXPAR.js → NotFoundPage-DpTbcC2P.js} +1 -1
- package/web-app/dist/assets/{ProjectPage-iP6dJihg.js → ProjectPage-CY2SMGx9.js} +65 -90
- package/web-app/dist/assets/{ProjectsPage-BibN9bHl.js → ProjectsPage-DSrXUUKJ.js} +2 -2
- package/web-app/dist/assets/{SettingsPage-C0WJp1hW.js → SettingsPage-jvDyOqYi.js} +3 -3
- package/web-app/dist/assets/{ShowcasePage-DUv0Njp8.js → ShowcasePage-C8tFWKau.js} +1 -1
- package/web-app/dist/assets/{SystemSettingsPage-BIaCB0Vn.js → SystemSettingsPage-DH4FTH3K.js} +2 -2
- package/web-app/dist/assets/{TeamsPage-BE0szv9r.js → TeamsPage-C1fQYauF.js} +2 -2
- package/web-app/dist/assets/{TemplatesPage-BzkA9kat.js → TemplatesPage-CSTFt-4P.js} +1 -1
- package/web-app/dist/assets/TerminalOutput-Cu4NsyN6.js +16 -0
- package/web-app/dist/assets/{activity-AbfFz38r.js → activity-CtjsDzmh.js} +1 -1
- package/web-app/dist/assets/{bell-DF6Z6y5U.js → bell-C5es1xAs.js} +1 -1
- package/web-app/dist/assets/{bot-DQ4np_3n.js → bot-DE04U5Lc.js} +1 -1
- package/web-app/dist/assets/{check-RWuguCwE.js → check-DSKKA9EU.js} +1 -1
- package/web-app/dist/assets/{chevron-left-VpbQPOkC.js → chevron-left-DJ13W5AR.js} +1 -1
- package/web-app/dist/assets/{circle-alert-DwT82lJx.js → circle-alert-CS0BfqAd.js} +1 -1
- package/web-app/dist/assets/{clock-BBlUa93G.js → clock-D1Y5nruk.js} +1 -1
- package/web-app/dist/assets/{cloud-Dgbz3VCA.js → cloud-nU6LBoZL.js} +1 -1
- package/web-app/dist/assets/{code-xml-r6qqION5.js → code-xml-BZfvIdFo.js} +1 -1
- package/web-app/dist/assets/{copy-DMHj52B8.js → copy-CK_2O1Xv.js} +1 -1
- package/web-app/dist/assets/{database-uJqHSHR1.js → database-DJiwznAm.js} +1 -1
- package/web-app/dist/assets/{dollar-sign-BZagljek.js → dollar-sign-pO20A3QY.js} +1 -1
- package/web-app/dist/assets/{file-code-corner-DMopmhu0.js → file-code-corner-Besy6vek.js} +1 -1
- package/web-app/dist/assets/{file-plus-DU_hT_3w.js → file-plus-DeaswxYY.js} +1 -1
- package/web-app/dist/assets/{folder-open-BP5TtQAW.js → folder-open-cr1UvQLI.js} +1 -1
- package/web-app/dist/assets/{git-commit-horizontal-zFk_IobS.js → git-commit-horizontal-BLxnfbSn.js} +1 -1
- package/web-app/dist/assets/{globe-mthCRtfp.js → globe-DrhG1NfX.js} +1 -1
- package/web-app/dist/assets/{hammer-BWaLBvSA.js → hammer-CeZtPBfE.js} +1 -1
- package/web-app/dist/assets/index-84JUN_aA.css +1 -0
- package/web-app/dist/assets/{index-BXA3UT6P.js → index-CLvjO22Z.js} +24 -24
- package/web-app/dist/assets/{layers-Q1LXV5fy.js → layers-fldADzyE.js} +1 -1
- package/web-app/dist/assets/{lightbulb-vRRNJ3dB.js → lightbulb-CznOfsPb.js} +1 -1
- package/web-app/dist/assets/{loader-circle-KgjeHEcV.js → loader-circle---lPB1Fs.js} +1 -1
- package/web-app/dist/assets/{lock-BerKqno7.js → lock-D5jVF-tO.js} +1 -1
- package/web-app/dist/assets/{mail-XAxTbprX.js → mail-D7HkLnlW.js} +1 -1
- package/web-app/dist/assets/minus-C-dT19Ct.js +6 -0
- package/web-app/dist/assets/{package-DLPKWAvW.js → package-Cm9B-cKE.js} +1 -1
- package/web-app/dist/assets/{plus-NMxxwHMn.js → plus-CQwOffLD.js} +1 -1
- package/web-app/dist/assets/{refresh-cw-Dt42kYtM.js → refresh-cw-CvWJZLbN.js} +1 -1
- package/web-app/dist/assets/{rotate-ccw-BCR4Tp9u.js → rotate-ccw-C2Q1LYgM.js} +1 -1
- package/web-app/dist/assets/{save-sR4MJd42.js → save-BP0MvpoQ.js} +1 -1
- package/web-app/dist/assets/{server-SXkchokx.js → server-4i4VZXix.js} +1 -1
- package/web-app/dist/assets/{shield-alert-Bvgp6_Dz.js → shield-alert-D2_bgb7j.js} +1 -1
- package/web-app/dist/assets/thumbs-up-vACbzeXj.js +26 -0
- package/web-app/dist/assets/{trash-2-D0IGudH7.js → trash-2-EYjdESLs.js} +1 -1
- package/web-app/dist/assets/trending-down-BWBdcvE3.js +6 -0
- package/web-app/dist/assets/{trending-up-DDrJKL5i.js → trending-up-Bix6V_-Y.js} +1 -1
- package/web-app/dist/assets/{upload-C54rjN8K.js → upload-B7hh6ERF.js} +1 -1
- package/web-app/dist/assets/{usePolling-D7fw4YSM.js → usePolling-b_e-k-IN.js} +1 -1
- package/web-app/dist/assets/{user-Cg7fbzdh.js → user-pmjZKWEg.js} +1 -1
- package/web-app/dist/index.html +2 -2
- package/web-app/dist/assets/LoginPage-VMzI6ROD.js +0 -1
- package/web-app/dist/assets/TerminalOutput-DBrdT_Fp.js +0 -31
- package/web-app/dist/assets/index-DgpUuqwR.css +0 -1
- package/web-app/dist/assets/trending-down-BbFFBq-v.js +0 -11
|
@@ -1,191 +1,166 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-
|
|
2
|
-
var ta=e=>{throw TypeError(e)};var sa=(e,t,s)=>t.has(e)||ta("Cannot "+s);var Fs=(e,t,s)=>(sa(e,t,"read from private field"),s?s.call(e):t.get(e)),ia=(e,t,s)=>t.has(e)?ta("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ra=(e,t,s,i)=>(sa(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-CsXVKuyJ.js","assets/index-CLvjO22Z.js","assets/index-84JUN_aA.css","assets/Button-DuuKHXre.js","assets/thumbs-up-vACbzeXj.js","assets/refresh-cw-CvWJZLbN.js","assets/circle-alert-CS0BfqAd.js","assets/user-pmjZKWEg.js","assets/rotate-ccw-C2Q1LYgM.js","assets/loader-circle---lPB1Fs.js","assets/GitHubPRsPanel-CYRp1eKS.js","assets/chevron-left-DJ13W5AR.js","assets/shield-alert-D2_bgb7j.js","assets/file-code-corner-Besy6vek.js","assets/clock-D1Y5nruk.js","assets/check-DSKKA9EU.js","assets/ErrorBoundary-RwfGKyRJ.js","assets/TerminalOutput-Cu4NsyN6.js","assets/lock-D5jVF-tO.js","assets/package-Cm9B-cKE.js","assets/file-plus-DeaswxYY.js","assets/activity-CtjsDzmh.js","assets/bot-DE04U5Lc.js","assets/hammer-CeZtPBfE.js","assets/dollar-sign-pO20A3QY.js","assets/globe-DrhG1NfX.js","assets/copy-CK_2O1Xv.js","assets/git-commit-horizontal-BLxnfbSn.js","assets/upload-B7hh6ERF.js","assets/plus-CQwOffLD.js","assets/trash-2-EYjdESLs.js","assets/minus-C-dT19Ct.js","assets/save-BP0MvpoQ.js","assets/code-xml-BZfvIdFo.js","assets/trending-up-Bix6V_-Y.js","assets/layers-fldADzyE.js","assets/trending-down-BWBdcvE3.js","assets/folder-open-cr1UvQLI.js","assets/server-4i4VZXix.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var ta=e=>{throw TypeError(e)};var sa=(e,t,s)=>t.has(e)||ta("Cannot "+s);var Fs=(e,t,s)=>(sa(e,t,"read from private field"),s?s.call(e):t.get(e)),ia=(e,t,s)=>t.has(e)?ta("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ra=(e,t,s,i)=>(sa(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as ce,r as d,W as ks,j as r,f as Zr,g as Ul,h as dr,i as ls,I as Kl,T as Ot,R as $t,k as es,M as ql,l as er,m as kt,S as Vl,U as _d,X as ft,n as ts,Z as Zt,a as W,E as ss,G as ze,K as xd,o as vd,p as bd,F as fi,P as It,_ as Jn,b as ur,q as Gl,s as Yl,t as yd,v as Sd,A as Zn,L as wd,B as Gs,w as Qr,x as Cd,e as kd,y as ys,z as na,D as oa,H as jd,J as Xl,N as ii,O as Nd,u as Ed}from"./index-CLvjO22Z.js";import{R as Dd,S as tr,P as Jl,E as Hi}from"./ErrorBoundary-RwfGKyRJ.js";import{B as he}from"./Button-DuuKHXre.js";import{T as Rd,F as Pd}from"./TerminalOutput-Cu4NsyN6.js";import{P as Zl}from"./package-Cm9B-cKE.js";import{F as Z}from"./file-code-corner-Besy6vek.js";import{F as fr}from"./file-plus-DeaswxYY.js";import{C as nt}from"./clock-D1Y5nruk.js";import{A as Md}from"./activity-CtjsDzmh.js";import{B as Ld}from"./bot-DE04U5Lc.js";import{C as Ut}from"./check-DSKKA9EU.js";import{L as mi}from"./loader-circle---lPB1Fs.js";import{H as Bd}from"./hammer-CeZtPBfE.js";import{D as Ql}from"./dollar-sign-pO20A3QY.js";import{R as gt}from"./refresh-cw-CvWJZLbN.js";import{C as Rs}from"./circle-alert-CS0BfqAd.js";import{G as en}from"./globe-DrhG1NfX.js";import{C as Qn}from"./copy-CK_2O1Xv.js";import{C as Td,G as tn,F as ec,H as sn,T as zd}from"./thumbs-up-vACbzeXj.js";import{G as tc}from"./git-commit-horizontal-BLxnfbSn.js";import{U as sc}from"./upload-B7hh6ERF.js";import{P as mr}from"./plus-CQwOffLD.js";import{T as eo}from"./trash-2-EYjdESLs.js";import{R as ic,E as Ad}from"./rotate-ccw-C2Q1LYgM.js";import{M as rc}from"./minus-C-dT19Ct.js";import{S as Od}from"./save-BP0MvpoQ.js";import{C as rn}from"./code-xml-BZfvIdFo.js";import{T as $d}from"./trending-up-Bix6V_-Y.js";import{L as Id}from"./layers-fldADzyE.js";import{T as Fd}from"./trending-down-BWBdcvE3.js";import{F as nn}from"./folder-open-cr1UvQLI.js";import{S as Hd}from"./server-4i4VZXix.js";/**
|
|
3
3
|
* @license lucide-react v0.577.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const
|
|
7
|
+
*/const Wd=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],Ud=ce("at-sign",Wd);/**
|
|
8
8
|
* @license lucide-react v0.577.0 - ISC
|
|
9
9
|
*
|
|
10
10
|
* This source code is licensed under the ISC license.
|
|
11
11
|
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const
|
|
12
|
+
*/const Kd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],nc=ce("ban",Kd);/**
|
|
13
13
|
* @license lucide-react v0.577.0 - ISC
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the ISC license.
|
|
16
16
|
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const
|
|
17
|
+
*/const qd=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Vd=ce("camera",qd);/**
|
|
18
18
|
* @license lucide-react v0.577.0 - ISC
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the ISC license.
|
|
21
21
|
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const
|
|
22
|
+
*/const Gd=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],Yd=ce("check-check",Gd);/**
|
|
23
23
|
* @license lucide-react v0.577.0 - ISC
|
|
24
24
|
*
|
|
25
25
|
* This source code is licensed under the ISC license.
|
|
26
26
|
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const
|
|
27
|
+
*/const Xd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],Jd=ce("compass",Xd);/**
|
|
28
28
|
* @license lucide-react v0.577.0 - ISC
|
|
29
29
|
*
|
|
30
30
|
* This source code is licensed under the ISC license.
|
|
31
31
|
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const
|
|
32
|
+
*/const Zd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],to=ce("file-braces",Zd);/**
|
|
33
33
|
* @license lucide-react v0.577.0 - ISC
|
|
34
34
|
*
|
|
35
35
|
* This source code is licensed under the ISC license.
|
|
36
36
|
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const
|
|
37
|
+
*/const Qd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],oc=ce("file-code",Qd);/**
|
|
38
38
|
* @license lucide-react v0.577.0 - ISC
|
|
39
39
|
*
|
|
40
40
|
* This source code is licensed under the ISC license.
|
|
41
41
|
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const
|
|
42
|
+
*/const eu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11 18h2",key:"12mj7e"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5",key:"qbrxap"}]],so=ce("file-type",eu);/**
|
|
43
43
|
* @license lucide-react v0.577.0 - ISC
|
|
44
44
|
*
|
|
45
45
|
* This source code is licensed under the ISC license.
|
|
46
46
|
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/const
|
|
47
|
+
*/const tu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]],su=ce("file-x",tu);/**
|
|
48
48
|
* @license lucide-react v0.577.0 - ISC
|
|
49
49
|
*
|
|
50
50
|
* This source code is licensed under the ISC license.
|
|
51
51
|
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
-
*/const
|
|
52
|
+
*/const iu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],io=ce("file",iu);/**
|
|
53
53
|
* @license lucide-react v0.577.0 - ISC
|
|
54
54
|
*
|
|
55
55
|
* This source code is licensed under the ISC license.
|
|
56
56
|
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/const
|
|
57
|
+
*/const ru=[["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"}]],ro=ce("folder",ru);/**
|
|
58
58
|
* @license lucide-react v0.577.0 - ISC
|
|
59
59
|
*
|
|
60
60
|
* This source code is licensed under the ISC license.
|
|
61
61
|
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
-
*/const
|
|
62
|
+
*/const nu=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],ou=ce("github",nu);/**
|
|
63
63
|
* @license lucide-react v0.577.0 - ISC
|
|
64
64
|
*
|
|
65
65
|
* This source code is licensed under the ISC license.
|
|
66
66
|
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const
|
|
67
|
+
*/const au=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],lu=ce("hash",au);/**
|
|
68
68
|
* @license lucide-react v0.577.0 - ISC
|
|
69
69
|
*
|
|
70
70
|
* This source code is licensed under the ISC license.
|
|
71
71
|
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
-
*/const
|
|
72
|
+
*/const cu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],aa=ce("image",cu);/**
|
|
73
73
|
* @license lucide-react v0.577.0 - ISC
|
|
74
74
|
*
|
|
75
75
|
* This source code is licensed under the ISC license.
|
|
76
76
|
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
-
*/const
|
|
77
|
+
*/const hu=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],du=ce("key-round",hu);/**
|
|
78
78
|
* @license lucide-react v0.577.0 - ISC
|
|
79
79
|
*
|
|
80
80
|
* This source code is licensed under the ISC license.
|
|
81
81
|
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
-
*/const
|
|
82
|
+
*/const uu=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Er=ce("layout-dashboard",uu);/**
|
|
83
83
|
* @license lucide-react v0.577.0 - ISC
|
|
84
84
|
*
|
|
85
85
|
* This source code is licensed under the ISC license.
|
|
86
86
|
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
-
*/const
|
|
87
|
+
*/const fu=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],ac=ce("link",fu);/**
|
|
88
88
|
* @license lucide-react v0.577.0 - ISC
|
|
89
89
|
*
|
|
90
90
|
* This source code is licensed under the ISC license.
|
|
91
91
|
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/const
|
|
92
|
+
*/const mu=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],pr=ce("loader",mu);/**
|
|
93
93
|
* @license lucide-react v0.577.0 - ISC
|
|
94
94
|
*
|
|
95
95
|
* This source code is licensed under the ISC license.
|
|
96
96
|
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
-
*/const
|
|
97
|
+
*/const pu=[["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"}]],on=ce("maximize-2",pu);/**
|
|
98
98
|
* @license lucide-react v0.577.0 - ISC
|
|
99
99
|
*
|
|
100
100
|
* This source code is licensed under the ISC license.
|
|
101
101
|
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
-
*/const
|
|
102
|
+
*/const gu=[["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"}]],lc=ce("minimize-2",gu);/**
|
|
103
103
|
* @license lucide-react v0.577.0 - ISC
|
|
104
104
|
*
|
|
105
105
|
* This source code is licensed under the ISC license.
|
|
106
106
|
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
-
*/const
|
|
107
|
+
*/const _u=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]],xu=ce("panel-bottom-close",_u);/**
|
|
108
108
|
* @license lucide-react v0.577.0 - ISC
|
|
109
109
|
*
|
|
110
110
|
* This source code is licensed under the ISC license.
|
|
111
111
|
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
-
*/const
|
|
112
|
+
*/const vu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]],bu=ce("panel-bottom-open",vu);/**
|
|
113
113
|
* @license lucide-react v0.577.0 - ISC
|
|
114
114
|
*
|
|
115
115
|
* This source code is licensed under the ISC license.
|
|
116
116
|
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
-
*/const
|
|
117
|
+
*/const yu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Su=ce("panel-left-open",yu);/**
|
|
118
118
|
* @license lucide-react v0.577.0 - ISC
|
|
119
119
|
*
|
|
120
120
|
* This source code is licensed under the ISC license.
|
|
121
121
|
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
-
*/const
|
|
122
|
+
*/const wu=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Cu=ce("scroll-text",wu);/**
|
|
123
123
|
* @license lucide-react v0.577.0 - ISC
|
|
124
124
|
*
|
|
125
125
|
* This source code is licensed under the ISC license.
|
|
126
126
|
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
-
*/const
|
|
127
|
+
*/const ku=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ju=ce("send",ku);/**
|
|
128
128
|
* @license lucide-react v0.577.0 - ISC
|
|
129
129
|
*
|
|
130
130
|
* This source code is licensed under the ISC license.
|
|
131
131
|
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
-
*/const
|
|
132
|
+
*/const Nu=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],no=ce("share-2",Nu);/**
|
|
133
133
|
* @license lucide-react v0.577.0 - ISC
|
|
134
134
|
*
|
|
135
135
|
* This source code is licensed under the ISC license.
|
|
136
136
|
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
-
*/const
|
|
137
|
+
*/const Eu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Du=ce("smartphone",Eu);/**
|
|
138
138
|
* @license lucide-react v0.577.0 - ISC
|
|
139
139
|
*
|
|
140
140
|
* This source code is licensed under the ISC license.
|
|
141
141
|
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
-
*/const
|
|
142
|
+
*/const Ru=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]],Pu=ce("tablet",Ru);/**
|
|
143
143
|
* @license lucide-react v0.577.0 - ISC
|
|
144
144
|
*
|
|
145
145
|
* This source code is licensed under the ISC license.
|
|
146
146
|
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
-
*/const
|
|
147
|
+
*/const Mu=[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]],ri=ce("test-tube-diagonal",Mu);/**
|
|
148
148
|
* @license lucide-react v0.577.0 - ISC
|
|
149
149
|
*
|
|
150
150
|
* This source code is licensed under the ISC license.
|
|
151
151
|
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
-
*/const
|
|
152
|
+
*/const Lu=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],Bu=ce("thumbs-down",Lu);/**
|
|
153
153
|
* @license lucide-react v0.577.0 - ISC
|
|
154
154
|
*
|
|
155
155
|
* This source code is licensed under the ISC license.
|
|
156
156
|
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
-
*/const
|
|
157
|
+
*/const Tu=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],cc=ce("timer",Tu);/**
|
|
158
158
|
* @license lucide-react v0.577.0 - ISC
|
|
159
159
|
*
|
|
160
160
|
* This source code is licensed under the ISC license.
|
|
161
161
|
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
-
*/const
|
|
163
|
-
|
|
164
|
-
*
|
|
165
|
-
* This source code is licensed under the ISC license.
|
|
166
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
-
*/const Tu=[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]],ri=ae("test-tube-diagonal",Tu);/**
|
|
168
|
-
* @license lucide-react v0.577.0 - ISC
|
|
169
|
-
*
|
|
170
|
-
* This source code is licensed under the ISC license.
|
|
171
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
-
*/const zu=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],Au=ae("thumbs-down",zu);/**
|
|
173
|
-
* @license lucide-react v0.577.0 - ISC
|
|
174
|
-
*
|
|
175
|
-
* This source code is licensed under the ISC license.
|
|
176
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
-
*/const Ou=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],$u=ae("thumbs-up",Ou);/**
|
|
178
|
-
* @license lucide-react v0.577.0 - ISC
|
|
179
|
-
*
|
|
180
|
-
* This source code is licensed under the ISC license.
|
|
181
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
-
*/const Iu=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],cc=ae("timer",Iu);/**
|
|
183
|
-
* @license lucide-react v0.577.0 - ISC
|
|
184
|
-
*
|
|
185
|
-
* This source code is licensed under the ISC license.
|
|
186
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
187
|
-
*/const Fu=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],Hu=ae("unplug",Fu);function la(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,i=Array(t);s<t;s++)i[s]=e[s];return i}function Wu(e){if(Array.isArray(e))return e}function Uu(e,t,s){return(t=Ju(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Ku(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var i,n,o,a,l=[],h=!0,c=!1;try{if(o=(s=s.call(e)).next,t!==0)for(;!(h=(i=o.call(s)).done)&&(l.push(i.value),l.length!==t);h=!0);}catch(u){c=!0,n=u}finally{try{if(!h&&s.return!=null&&(a=s.return(),Object(a)!==a))return}finally{if(c)throw n}}return l}}function qu(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
188
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ca(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function ha(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?ca(Object(s),!0).forEach(function(i){Uu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ca(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function Vu(e,t){if(e==null)return{};var s,i,n=Gu(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)s=o[i],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function Gu(e,t){if(e==null)return{};var s={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;s[i]=e[i]}return s}function Yu(e,t){return Wu(e)||Ku(e,t)||Zu(e,t)||qu()}function Xu(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var i=s.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ju(e){var t=Xu(e,"string");return typeof t=="symbol"?t:t+""}function Zu(e,t){if(e){if(typeof e=="string")return la(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?la(e,t):void 0}}function Qu(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function da(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function ua(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?da(Object(s),!0).forEach(function(i){Qu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):da(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function ef(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(i){return t.reduceRight(function(n,o){return o(n)},i)}}function Ys(e){return function t(){for(var s=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return n.length>=e.length?e.apply(this,n):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(n,l))}}}function sr(e){return{}.toString.call(e).includes("Object")}function tf(e){return!Object.keys(e).length}function li(e){return typeof e=="function"}function sf(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function rf(e,t){return sr(t)||Ft("changeType"),Object.keys(t).some(function(s){return!sf(e,s)})&&Ft("changeField"),t}function nf(e){li(e)||Ft("selectorType")}function of(e){li(e)||sr(e)||Ft("handlerType"),sr(e)&&Object.values(e).some(function(t){return!li(t)})&&Ft("handlersType")}function af(e){e||Ft("initialIsRequired"),sr(e)||Ft("initialType"),tf(e)&&Ft("initialContent")}function lf(e,t){throw new Error(e[t]||e.default)}var cf={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ft=Ys(lf)(cf),Mi={changes:rf,selector:nf,handler:of,initial:af};function hf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Mi.initial(e),Mi.handler(t);var s={current:e},i=Ys(ff)(s,t),n=Ys(uf)(s),o=Ys(Mi.changes)(e),a=Ys(df)(s);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Mi.selector(c),c(s.current)}function h(c){ef(i,n,o,a)(c)}return[l,h]}function df(e,t){return li(t)?t(e.current):t}function uf(e,t){return e.current=ua(ua({},e.current),t),t}function ff(e,t,s){return li(t)?t(e.current):Object.keys(s).forEach(function(i){var n;return(n=t[i])===null||n===void 0?void 0:n.call(t,e.current[i])}),s}var mf={create:hf},pf={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function gf(e){return function t(){for(var s=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return n.length>=e.length?e.apply(this,n):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(n,l))}}}function _f(e){return{}.toString.call(e).includes("Object")}function xf(e){return e||fa("configIsRequired"),_f(e)||fa("configType"),e.urls?(vf(),{paths:{vs:e.urls.monacoBase}}):e}function vf(){console.warn(hc.deprecation)}function bf(e,t){throw new Error(e[t]||e.default)}var hc={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
162
|
+
*/const zu=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],Au=ce("unplug",zu);function la(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,i=Array(t);s<t;s++)i[s]=e[s];return i}function Ou(e){if(Array.isArray(e))return e}function $u(e,t,s){return(t=qu(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Iu(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var i,n,o,a,l=[],h=!0,c=!1;try{if(o=(s=s.call(e)).next,t!==0)for(;!(h=(i=o.call(s)).done)&&(l.push(i.value),l.length!==t);h=!0);}catch(u){c=!0,n=u}finally{try{if(!h&&s.return!=null&&(a=s.return(),Object(a)!==a))return}finally{if(c)throw n}}return l}}function Fu(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
163
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ca(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function ha(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?ca(Object(s),!0).forEach(function(i){$u(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ca(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function Hu(e,t){if(e==null)return{};var s,i,n=Wu(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)s=o[i],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function Wu(e,t){if(e==null)return{};var s={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;s[i]=e[i]}return s}function Uu(e,t){return Ou(e)||Iu(e,t)||Vu(e,t)||Fu()}function Ku(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var i=s.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qu(e){var t=Ku(e,"string");return typeof t=="symbol"?t:t+""}function Vu(e,t){if(e){if(typeof e=="string")return la(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?la(e,t):void 0}}function Gu(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function da(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function ua(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?da(Object(s),!0).forEach(function(i){Gu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):da(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function Yu(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(i){return t.reduceRight(function(n,o){return o(n)},i)}}function Ys(e){return function t(){for(var s=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return n.length>=e.length?e.apply(this,n):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(n,l))}}}function sr(e){return{}.toString.call(e).includes("Object")}function Xu(e){return!Object.keys(e).length}function li(e){return typeof e=="function"}function Ju(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Zu(e,t){return sr(t)||Ft("changeType"),Object.keys(t).some(function(s){return!Ju(e,s)})&&Ft("changeField"),t}function Qu(e){li(e)||Ft("selectorType")}function ef(e){li(e)||sr(e)||Ft("handlerType"),sr(e)&&Object.values(e).some(function(t){return!li(t)})&&Ft("handlersType")}function tf(e){e||Ft("initialIsRequired"),sr(e)||Ft("initialType"),Xu(e)&&Ft("initialContent")}function sf(e,t){throw new Error(e[t]||e.default)}var rf={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ft=Ys(sf)(rf),Mi={changes:Zu,selector:Qu,handler:ef,initial:tf};function nf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Mi.initial(e),Mi.handler(t);var s={current:e},i=Ys(lf)(s,t),n=Ys(af)(s),o=Ys(Mi.changes)(e),a=Ys(of)(s);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Mi.selector(c),c(s.current)}function h(c){Yu(i,n,o,a)(c)}return[l,h]}function of(e,t){return li(t)?t(e.current):t}function af(e,t){return e.current=ua(ua({},e.current),t),t}function lf(e,t,s){return li(t)?t(e.current):Object.keys(s).forEach(function(i){var n;return(n=t[i])===null||n===void 0?void 0:n.call(t,e.current[i])}),s}var cf={create:nf},hf={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function df(e){return function t(){for(var s=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return n.length>=e.length?e.apply(this,n):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(n,l))}}}function uf(e){return{}.toString.call(e).includes("Object")}function ff(e){return e||fa("configIsRequired"),uf(e)||fa("configType"),e.urls?(mf(),{paths:{vs:e.urls.monacoBase}}):e}function mf(){console.warn(hc.deprecation)}function pf(e,t){throw new Error(e[t]||e.default)}var hc={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
189
164
|
You are using deprecated way of configuration.
|
|
190
165
|
|
|
191
166
|
Instead of using
|
|
@@ -194,7 +169,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
194
169
|
monaco.config({ paths: { vs: '...' } })
|
|
195
170
|
|
|
196
171
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
197
|
-
`},fa=gf(bf)(hc),yf={config:xf},Sf=function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return function(n){return s.reduceRight(function(o,a){return a(o)},n)}};function dc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],dc(e[s],t[s]))}),ha(ha({},e),t)}var wf={type:"cancelation",msg:"operation is manually canceled"};function Dr(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(wf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var Cf=["monaco"],kf=mf.create({config:pf,isInitialized:!1,resolve:null,reject:null,monaco:null}),uc=Yu(kf,2),pi=uc[0],gr=uc[1];function Nf(e){var t=yf.config(e),s=t.monaco,i=Vu(t,Cf);gr(function(n){return{config:dc(n.config,i),monaco:s}})}function jf(){var e=pi(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(gr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Dr(Rr);if(window.monaco&&window.monaco.editor)return fc(window.monaco),e.resolve(window.monaco),Dr(Rr);Sf(Ef,Rf)(Pf)}return Dr(Rr)}function Ef(e){return document.body.appendChild(e)}function Df(e){var t=document.createElement("script");return e&&(t.src=e),t}function Rf(e){var t=pi(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=Df("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Pf(){var e=pi(function(s){var i=s.config,n=s.resolve,o=s.reject;return{config:i,resolve:n,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var i=s.m||s;fc(i),e.resolve(i)},function(s){e.reject(s)})}function fc(e){pi().monaco||gr({monaco:e})}function Mf(){return pi(function(e){var t=e.monaco;return t})}var Rr=new Promise(function(e,t){return gr({resolve:e,reject:t})}),mc={config:Nf,init:jf,__getMonacoInstance:Mf},Lf={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Pr=Lf,Bf={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Tf=Bf;function zf({children:e}){return ks.createElement("div",{style:Tf.container},e)}var Af=zf,Of=Af;function $f({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return ks.createElement("section",{style:{...Pr.wrapper,width:e,height:t},...a},!s&&ks.createElement(Of,null,i),ks.createElement("div",{ref:n,style:{...Pr.fullWidth,...!s&&Pr.hide},className:o}))}var If=$f,pc=d.memo(If);function Ff(e){d.useEffect(e,[])}var gc=Ff;function Hf(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var Qe=Hf;function ni(){}function Ss(e,t,s,i){return Wf(e,i)||Uf(e,t,s,i)}function Wf(e,t){return e.editor.getModel(_c(e,t))}function Uf(e,t,s,i){return e.editor.createModel(t,s,i?_c(e,i):void 0)}function _c(e,t){return e.Uri.parse(t)}function Kf({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:u="Loading...",options:m={},height:f="100%",width:_="100%",className:p,wrapperProps:g={},beforeMount:v=ni,onMount:y=ni}){let[x,k]=d.useState(!1),[N,w]=d.useState(!0),D=d.useRef(null),T=d.useRef(null),U=d.useRef(null),G=d.useRef(y),K=d.useRef(v),A=d.useRef(!1);gc(()=>{let S=mc.init();return S.then(j=>(T.current=j)&&w(!1)).catch(j=>(j==null?void 0:j.type)!=="cancelation"&&console.error("Monaco initialization: error:",j)),()=>D.current?L():S.cancel()}),Qe(()=>{if(D.current&&T.current){let S=D.current.getOriginalEditor(),j=Ss(T.current,e||"",i||s||"text",o||"");j!==S.getModel()&&S.setModel(j)}},[o],x),Qe(()=>{if(D.current&&T.current){let S=D.current.getModifiedEditor(),j=Ss(T.current,t||"",n||s||"text",a||"");j!==S.getModel()&&S.setModel(j)}},[a],x),Qe(()=>{let S=D.current.getModifiedEditor();S.getOption(T.current.editor.EditorOption.readOnly)?S.setValue(t||""):t!==S.getValue()&&(S.executeEdits("",[{range:S.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),S.pushUndoStop())},[t],x),Qe(()=>{var S,j;(j=(S=D.current)==null?void 0:S.getModel())==null||j.original.setValue(e||"")},[e],x),Qe(()=>{let{original:S,modified:j}=D.current.getModel();T.current.editor.setModelLanguage(S,i||s||"text"),T.current.editor.setModelLanguage(j,n||s||"text")},[s,i,n],x),Qe(()=>{var S;(S=T.current)==null||S.editor.setTheme(c)},[c],x),Qe(()=>{var S;(S=D.current)==null||S.updateOptions(m)},[m],x);let M=d.useCallback(()=>{var C;if(!T.current)return;K.current(T.current);let S=Ss(T.current,e||"",i||s||"text",o||""),j=Ss(T.current,t||"",n||s||"text",a||"");(C=D.current)==null||C.setModel({original:S,modified:j})},[s,t,n,e,i,o,a]),E=d.useCallback(()=>{var S;!A.current&&U.current&&(D.current=T.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...m}),M(),(S=T.current)==null||S.editor.setTheme(c),k(!0),A.current=!0)},[m,c,M]);d.useEffect(()=>{x&&G.current(D.current,T.current)},[x]),d.useEffect(()=>{!N&&!x&&E()},[N,x,E]);function L(){var j,C,B,X;let S=(j=D.current)==null?void 0:j.getModel();l||((C=S==null?void 0:S.original)==null||C.dispose()),h||((B=S==null?void 0:S.modified)==null||B.dispose()),(X=D.current)==null||X.dispose()}return ks.createElement(pc,{width:_,height:f,isEditorReady:x,loading:u,_ref:U,className:p,wrapperProps:g})}var qf=Kf;d.memo(qf);function Vf(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var Gf=Vf,Li=new Map;function Yf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:u={},saveViewState:m=!0,keepCurrentModel:f=!1,width:_="100%",height:p="100%",className:g,wrapperProps:v={},beforeMount:y=ni,onMount:x=ni,onChange:k,onValidate:N=ni}){let[w,D]=d.useState(!1),[T,U]=d.useState(!0),G=d.useRef(null),K=d.useRef(null),A=d.useRef(null),M=d.useRef(x),E=d.useRef(y),L=d.useRef(),S=d.useRef(i),j=Gf(o),C=d.useRef(!1),B=d.useRef(!1);gc(()=>{let q=mc.init();return q.then(Q=>(G.current=Q)&&U(!1)).catch(Q=>(Q==null?void 0:Q.type)!=="cancelation"&&console.error("Monaco initialization: error:",Q)),()=>K.current?oe():q.cancel()}),Qe(()=>{var Q,ie,de,ue;let q=Ss(G.current,e||i||"",t||n||"",o||s||"");q!==((Q=K.current)==null?void 0:Q.getModel())&&(m&&Li.set(j,(ie=K.current)==null?void 0:ie.saveViewState()),(de=K.current)==null||de.setModel(q),m&&((ue=K.current)==null||ue.restoreViewState(Li.get(o))))},[o],w),Qe(()=>{var q;(q=K.current)==null||q.updateOptions(c)},[c],w),Qe(()=>{!K.current||i===void 0||(K.current.getOption(G.current.editor.EditorOption.readOnly)?K.current.setValue(i):i!==K.current.getValue()&&(B.current=!0,K.current.executeEdits("",[{range:K.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),K.current.pushUndoStop(),B.current=!1))},[i],w),Qe(()=>{var Q,ie;let q=(Q=K.current)==null?void 0:Q.getModel();q&&n&&((ie=G.current)==null||ie.editor.setModelLanguage(q,n))},[n],w),Qe(()=>{var q;l!==void 0&&((q=K.current)==null||q.revealLine(l))},[l],w),Qe(()=>{var q;(q=G.current)==null||q.editor.setTheme(a)},[a],w);let X=d.useCallback(()=>{var q;if(!(!A.current||!G.current)&&!C.current){E.current(G.current);let Q=o||s,ie=Ss(G.current,i||e||"",t||n||"",Q||"");K.current=(q=G.current)==null?void 0:q.editor.create(A.current,{model:ie,automaticLayout:!0,...c},u),m&&K.current.restoreViewState(Li.get(Q)),G.current.editor.setTheme(a),l!==void 0&&K.current.revealLine(l),D(!0),C.current=!0}},[e,t,s,i,n,o,c,u,m,a,l]);d.useEffect(()=>{w&&M.current(K.current,G.current)},[w]),d.useEffect(()=>{!T&&!w&&X()},[T,w,X]),S.current=i,d.useEffect(()=>{var q,Q;w&&k&&((q=L.current)==null||q.dispose(),L.current=(Q=K.current)==null?void 0:Q.onDidChangeModelContent(ie=>{B.current||k(K.current.getValue(),ie)}))},[w,k]),d.useEffect(()=>{if(w){let q=G.current.editor.onDidChangeMarkers(Q=>{var de;let ie=(de=K.current.getModel())==null?void 0:de.uri;if(ie&&Q.find(ue=>ue.path===ie.path)){let ue=G.current.editor.getModelMarkers({resource:ie});N==null||N(ue)}});return()=>{q==null||q.dispose()}}return()=>{}},[w,N]);function oe(){var q,Q;(q=L.current)==null||q.dispose(),f?m&&Li.set(o,K.current.saveViewState()):(Q=K.current.getModel())==null||Q.dispose(),K.current.dispose()}return ks.createElement(pc,{width:_,height:p,isEditorReady:w,loading:h,_ref:A,className:g,wrapperProps:v})}var Xf=Yf,Jf=d.memo(Xf),Zf=Jf;function Qf(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function em(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function tm(e){return e/100*window.innerHeight}function sm(e){return e/100*window.innerWidth}function im(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Xs({groupSize:e,panelElement:t,styleProp:s}){let i;const[n,o]=im(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=em(t,n);break}case"em":{i=Qf(t,n);break}case"vh":{i=tm(n);break}case"vw":{i=sm(n);break}}return i}function Ve(e){return parseFloat(e.toFixed(3))}function Es({group:e}){const{orientation:t,panels:s}=e;return s.reduce((i,n)=>(i+=t==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,i),0)}function an(e){const{panels:t}=e,s=Es({group:e});return s===0?t.map(i=>({groupResizeBehavior:i.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:i.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:i.panelConstraints.disabled,minSize:0,maxSize:100,panelId:i.id})):t.map(i=>{const{element:n,panelConstraints:o}=i;let a=0;if(o.collapsedSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.collapsedSize});a=Ve(u/s*100)}let l;if(o.defaultSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.defaultSize});l=Ve(u/s*100)}let h=0;if(o.minSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.minSize});h=Ve(u/s*100)}let c=100;if(o.maxSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.maxSize});c=Ve(u/s*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:a,collapsible:o.collapsible===!0,defaultSize:l,disabled:o.disabled,minSize:h,maxSize:c,panelId:i.id}})}function pe(e,t="Assertion error"){if(!e)throw Error(t)}function ln(e,t){return Array.from(t).sort(e==="horizontal"?rm:nm)}function rm(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function nm(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function xc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function vc(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function om({orientation:e,rects:t,targetRect:s}){const i={x:s.x+s.width/2,y:s.y+s.height/2};let n,o=Number.MAX_VALUE;for(const a of t){const{x:l,y:h}=vc(i,a),c=e==="horizontal"?l:h;c<o&&(o=c,n=a)}return pe(n,"No rect found"),n}let Bi;function am(){return Bi===void 0&&(typeof matchMedia=="function"?Bi=!!matchMedia("(pointer:coarse)").matches:Bi=!1),Bi}function bc(e){const{element:t,orientation:s,panels:i,separators:n}=e,o=ln(s,Array.from(t.children).filter(xc).map(p=>({element:p}))).map(({element:p})=>p),a=[];let l=!1,h=!1,c=-1,u=-1,m=0,f,_=[];{let p=-1;for(const g of o)g.hasAttribute("data-panel")&&(p++,g.ariaDisabled===null&&(m++,c===-1&&(c=p),u=p))}if(m>1){let p=-1;for(const g of o)if(g.hasAttribute("data-panel")){p++;const v=i.find(y=>y.element===g);if(v){if(f){const y=f.element.getBoundingClientRect(),x=g.getBoundingClientRect();let k;if(h){const N=s==="horizontal"?new DOMRect(y.right,y.top,0,y.height):new DOMRect(y.left,y.bottom,y.width,0),w=s==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(_.length){case 0:{k=[N,w];break}case 1:{const D=_[0],T=om({orientation:s,rects:[y,x],targetRect:D.element.getBoundingClientRect()});k=[D,T===y?w:N];break}default:{k=_;break}}}else _.length?k=_:k=[s==="horizontal"?new DOMRect(y.right,x.top,x.left-y.right,x.height):new DOMRect(x.left,y.bottom,x.width,x.top-y.bottom)];for(const N of k){let w="width"in N?N:N.element.getBoundingClientRect();const D=am()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(w.width<D){const U=D-w.width;w=new DOMRect(w.x-U/2,w.y,w.width+U,w.height)}if(w.height<D){const U=D-w.height;w=new DOMRect(w.x,w.y-U/2,w.width,w.height+U)}const T=p<=c||p>u;!l&&!T&&a.push({group:e,groupSize:Es({group:e}),panels:[f,v],separator:"width"in N?void 0:N,rect:w}),l=!1}}h=!1,f=v,_=[]}}else if(g.hasAttribute("data-separator")){g.ariaDisabled!==null&&(l=!0);const v=n.find(y=>y.element===g);v?_.push(v):(f=void 0,_=[])}else h=!0}return a}var zt,Il;let yc=(Il=class{constructor(){ia(this,zt,{})}addListener(t,s){const i=Fs(this,zt)[t];return i===void 0?Fs(this,zt)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Fs(this,zt)[t];if(i!==void 0)if(i.length===1)i[0].call(null,s);else{let n=!1,o=null;const a=Array.from(i);for(let l=0;l<a.length;l++){const h=a[l];try{h.call(null,s)}catch(c){o===null&&(n=!0,o=c)}}if(n)throw o}}removeAllListeners(){ra(this,zt,{})}removeListener(t,s){const i=Fs(this,zt)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},zt=new WeakMap,Il),mt=new Map;const Sc=new yc;function lm(e){mt=new Map(mt),mt.delete(e)}function ma(e,t){for(const[s]of mt)if(s.id===e)return s}function Ht(e,t){for(const[s,i]of mt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function cs(){return mt}function oo(e,t){return Sc.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function Nt(e,t){const s=mt.get(e);mt=new Map(mt),mt.set(e,t),Sc.emit("groupChange",{group:e,prev:s,next:t})}function cm(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=vc(s,o.rect);switch(e){case"horizontal":{a.x<=n.x&&(i=o,n=a);break}case"vertical":{a.y<=n.y&&(i=o,n=a);break}}}return i?{distance:n,hitRegion:i}:void 0}function hm(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function dm(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:_a(e),b:_a(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();pe(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:ga(pa(s.a)),b:ga(pa(s.b))};if(n.a===n.b){const o=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let l=o.length;for(;l--;){const h=o[l];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(n.a-n.b)}const um=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function fm(e){const t=getComputedStyle(wc(e)??e).display;return t==="flex"||t==="inline-flex"}function mm(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||fm(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||um.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function pa(e){let t=e.length;for(;t--;){const s=e[t];if(pe(s,"Missing node"),mm(s))return s}return null}function ga(e){return e&&Number(getComputedStyle(e).zIndex)||0}function _a(e){const t=[];for(;e;)t.push(e),e=wc(e);return t}function wc(e){const{parentNode:t}=e;return hm(t)?t.host:t}function pm(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function gm({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!xc(s)||s.contains(e)||e.contains(s))return!0;if(dm(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(pm(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function ao(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=bc(n),a=cm(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&gm({groupElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function _m(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=t[s])return!1;return!0}function He(e,t,s=0){return Math.abs(Ve(e)-Ve(t))<=s}function ut(e,t){return He(e,t)?0:e>t?1:-1}function ws({overrideDisabledPanels:e,panelConstraints:t,prevSize:s,size:i}){const{collapsedSize:n=0,collapsible:o,disabled:a,maxSize:l=100,minSize:h=0}=t;if(a&&!e)return s;if(ut(i,h)<0)if(o){const c=(n+h)/2;ut(i,c)<0?i=n:i=h}else i=h;return i=Math.min(l,i),i=Ve(i),i}function ci({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(He(e,0))return t;const a=o==="imperative-api",l=Object.values(t),h=Object.values(n),c=[...l],[u,m]=i;pe(u!=null,"Invalid first pivot index"),pe(m!=null,"Invalid second pivot index");let f=0;switch(o){case"keyboard":{{const g=e<0?m:u,v=s[g];pe(v,`Panel constraints not found for index ${g}`);const{collapsedSize:y=0,collapsible:x,minSize:k=0}=v;if(x){const N=l[g];if(pe(N!=null,`Previous layout not found for panel index ${g}`),He(N,y)){const w=k-N;ut(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const g=e<0?u:m,v=s[g];pe(v,`No panel constraints found for index ${g}`);const{collapsedSize:y=0,collapsible:x,minSize:k=0}=v;if(x){const N=l[g];if(pe(N!=null,`Previous layout not found for panel index ${g}`),He(N,k)){const w=N-y;ut(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const g=e<0?m:u,v=s[g];pe(v,`Panel constraints not found for index ${g}`);const y=l[g],{collapsible:x,collapsedSize:k,minSize:N}=v;if(x&&ut(y,N)<0)if(e>0){const w=N-k,D=w/2,T=y+e;ut(T,N)<0&&(e=ut(e,D)<=0?0:w)}else{const w=N-k,D=100-w/2,T=y-e;ut(T,N)<0&&(e=ut(100+e,D)>0?0:-w)}break}}{const g=e<0?1:-1;let v=e<0?m:u,y=0;for(;;){const k=l[v];pe(k!=null,`Previous layout not found for panel index ${v}`);const N=ws({overrideDisabledPanels:a,panelConstraints:s[v],prevSize:k,size:100})-k;if(y+=N,v+=g,v<0||v>=s.length)break}const x=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-x:x}{let g=e<0?u:m;for(;g>=0&&g<s.length;){const v=Math.abs(e)-Math.abs(f),y=l[g];pe(y!=null,`Previous layout not found for panel index ${g}`);const x=y-v,k=ws({overrideDisabledPanels:a,panelConstraints:s[g],prevSize:y,size:x});if(!He(y,k)&&(f+=y-k,c[g]=k,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(_m(h,c))return n;{const g=e<0?m:u,v=l[g];pe(v!=null,`Previous layout not found for panel index ${g}`);const y=v+f,x=ws({overrideDisabledPanels:a,panelConstraints:s[g],prevSize:v,size:y});if(c[g]=x,!He(x,y)){let k=y-x,N=e<0?m:u;for(;N>=0&&N<s.length;){const w=c[N];pe(w!=null,`Previous layout not found for panel index ${N}`);const D=w+k,T=ws({overrideDisabledPanels:a,panelConstraints:s[N],prevSize:w,size:D});if(He(w,T)||(k-=T-w,c[N]=T),He(k,0))break;e>0?N--:N++}}}const _=Object.values(c).reduce((g,v)=>v+g,0);if(!He(_,100,.1))return n;const p=Object.keys(n);return c.reduce((g,v,y)=>(g[p[y]]=v,g),{})}function is(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||ut(e[s],t[s])!==0)return!1;return!0}function rs({layout:e,panelConstraints:t}){const s=Object.values(e),i=[...s],n=i.reduce((l,h)=>l+h,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(l=>`${l}%`).join(", ")}`);if(!He(n,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=100/n*h;i[l]=c}let o=0;for(let l=0;l<t.length;l++){const h=s[l];pe(h!=null,`No layout data found for index ${l}`);const c=i[l];pe(c!=null,`No layout data found for index ${l}`);const u=ws({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=u&&(o+=c-u,i[l]=u)}if(!He(o,0))for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=h+o,u=ws({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==u&&(o-=u-h,i[l]=u,He(o,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function Cc({groupId:e,panelId:t}){const s=()=>{const l=cs();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:u,layout:m,groupSize:f,separatorToPanels:_}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:h,groupSize:f,layout:m,separatorToPanels:_};throw Error(`Group ${e} not found`)},i=()=>{const l=s().derivedPanelConstraints.find(h=>h.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},n=()=>{const l=s().group.panels.find(h=>h.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const l=s().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const h=o();if(l===h)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:m,groupSize:f,layout:_,separatorToPanels:p}=s(),g=m.panels.findIndex(k=>k.id===t),v=g===m.panels.length-1,y=ci({delta:v?h-l:l-h,initialLayout:_,panelConstraints:u,pivotIndices:v?[g-1,g]:[g,g+1],prevLayout:_,trigger:"imperative-api"}),x=rs({layout:y,panelConstraints:u});is(_,x)||Nt(m,{defaultLayoutDeferred:c,derivedPanelConstraints:u,groupSize:f,layout:x,separatorToPanels:p})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=n(),u=o();l&&u!==h&&(c.expandToSize=u,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:u}=n(),m=o();if(l&&m===h){let f=u.expandToSize??c;f===0&&(f=1),a(f)}},getSize:()=>{const{group:l}=s(),h=o(),{element:c}=n(),u=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:u}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=o();return l&&He(h,c)},resize:l=>{const{group:h}=s(),{element:c}=n(),u=Es({group:h}),m=Xs({groupSize:u,panelElement:c,styleProp:l}),f=Ve(m/u*100);a(f)}}}function xa(e){if(e.defaultPrevented)return;const t=cs();ao(e,t).forEach(s=>{if(s.separator){const i=s.panels.find(n=>n.panelConstraints.defaultSize!==void 0);if(i){const n=i.panelConstraints.defaultSize,o=Cc({groupId:s.group.id,panelId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Wi(e){const t=cs();for(const[s]of t)if(s.separators.some(i=>i.element===e))return s;throw Error("Could not find parent Group for separator element")}function kc({groupId:e}){const t=()=>{const s=cs();for(const[i,n]of s)if(i.id===e)return{group:i,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:s,layout:i}=t();return s?{}:i},setLayout(s){const{defaultLayoutDeferred:i,derivedPanelConstraints:n,group:o,groupSize:a,layout:l,separatorToPanels:h}=t(),c=rs({layout:s,panelConstraints:n});return i?l:(is(l,c)||Nt(o,{defaultLayoutDeferred:i,derivedPanelConstraints:n,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function qt(e,t){const s=Wi(e),i=Ht(s.id,!0),n=s.separators.find(u=>u.element===e);pe(n,"Matching separator not found");const o=i.separatorToPanels.get(n);pe(o,"Matching panels not found");const a=o.map(u=>s.panels.indexOf(u)),l=kc({groupId:s.id}).getLayout(),h=ci({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=rs({layout:h,panelConstraints:i.derivedPanelConstraints});is(l,c)||Nt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function va(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=Wi(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&qt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&qt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&qt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&qt(t,-5);break}case"End":{e.preventDefault(),qt(t,100);break}case"Enter":{e.preventDefault();const i=Wi(t),n=Ht(i.id,!0),{derivedPanelConstraints:o,layout:a,separatorToPanels:l}=n,h=i.separators.find(f=>f.element===t);pe(h,"Matching separator not found");const c=l.get(h);pe(c,"Matching panels not found");const u=c[0],m=o.find(f=>f.panelId===u.id);if(pe(m,"Panel metadata not found"),m.collapsible){const f=a[u.id],_=m.collapsedSize===f?i.mutableState.expandedPanelSizes[u.id]??m.minSize:m.collapsedSize;qt(t,_-f)}break}case"F6":{e.preventDefault();const i=Wi(t).separators.map(a=>a.element),n=Array.from(i).findIndex(a=>a===e.currentTarget);pe(n!==null,"Index not found");const o=e.shiftKey?n>0?n-1:i.length-1:n+1<i.length?n+1:0;i[o].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),qt(t,-100);break}}}let Ns={cursorFlags:0,state:"inactive"};const lo=new yc;function ns(){return Ns}function xm(e){return lo.addListener("change",e)}function vm(e){const t=Ns,s={...Ns};s.cursorFlags=e,Ns=s,lo.emit("change",{prev:t,next:s})}function js(e){const t=Ns;Ns=e,lo.emit("change",{prev:t,next:e})}function ba(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=cs(),s=ao(e,t),i=new Map;let n=!1;s.forEach(o=>{o.separator&&(n||(n=!0,o.separator.element.focus({preventScroll:!0})));const a=t.get(o.group);a&&i.set(o.group,a.layout)}),js({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const bm=e=>e,Mr=()=>{},Nc=1,jc=2,Ec=4,Dc=8,ya=3,Sa=12;let Ti;function wa(){return Ti===void 0&&(Ti=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ti=!0)),Ti}function ym({cursorFlags:e,groups:t,state:s}){let i=0,n=0;switch(s){case"active":case"hover":t.forEach(o=>{if(!o.mutableState.disableCursor)switch(o.orientation){case"horizontal":{i++;break}case"vertical":{n++;break}}})}if(!(i===0&&n===0)){switch(s){case"active":{if(e&&wa()){const o=(e&Nc)!==0,a=(e&jc)!==0,l=(e&Ec)!==0,h=(e&Dc)!==0;if(o)return l?"se-resize":h?"ne-resize":"e-resize";if(a)return l?"sw-resize":h?"nw-resize":"w-resize";if(l)return"s-resize";if(h)return"n-resize"}break}}return wa()?i>0&&n>0?"move":i>0?"ew-resize":"ns-resize":i>0&&n>0?"grab":i>0?"col-resize":"row-resize"}}const Ca=new WeakMap;function co(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=Ca.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=ns();switch(i.state){case"active":case"hover":{const n=ym({cursorFlags:i.cursorFlags,groups:i.hitRegions.map(a=>a.group),state:i.state}),o=`*, *:hover {cursor: ${n} !important; }`;if(t===o)return;t=o,n?s.cssRules.length===0?s.insertRule(o):s.replaceSync(o):s.cssRules.length===1&&s.deleteRule(0);break}case"inactive":{t=void 0,s.cssRules.length===1&&s.deleteRule(0);break}}Ca.set(e,{prevStyle:t,styleSheet:s})}function Rc({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:n,pointerDownAtPoint:o,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:u,groupSize:m}=c,{orientation:f,panels:_}=u,{disableCursor:p}=u.mutableState;let g=0;o?f==="horizontal"?g=(t.clientX-o.x)/m*100:g=(t.clientY-o.y)/m*100:f==="horizontal"?g=t.clientX<0?-100:100:g=t.clientY<0?-100:100;const v=i.get(u),y=n.get(u);if(!v||!y)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:k,groupSize:N,layout:w,separatorToPanels:D}=y;if(k&&w&&D){const T=ci({delta:g,initialLayout:v,panelConstraints:k,pivotIndices:c.panels.map(U=>_.indexOf(U)),prevLayout:w,trigger:"mouse-or-touch"});if(is(T,w)){if(g!==0&&!p)switch(f){case"horizontal":{l|=g<0?Nc:jc;break}case"vertical":{l|=g<0?Ec:Dc;break}}}else Nt(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:k,groupSize:N,layout:T,separatorToPanels:D})}});let h=0;t.movementX===0?h|=a&ya:h|=l&ya,t.movementY===0?h|=a&Sa:h|=l&Sa,vm(h),co(e)}function ka(e){const t=cs(),s=ns();switch(s.state){case"active":Rc({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function Na(e){if(e.defaultPrevented)return;const t=ns(),s=cs();switch(t.state){case"active":{if(e.buttons===0){js({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const n=Ht(i.group.id,!0);Nt(i.group,n)});return}Rc({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=ao(e,s);i.length===0?t.state!=="inactive"&&js({cursorFlags:0,state:"inactive"}):js({cursorFlags:0,hitRegions:i,state:"hover"}),co(e.currentTarget);break}}}function ja(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ns().state){case"hover":js({cursorFlags:0,state:"inactive"})}}function Ea(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ns();switch(t.state){case"active":js({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(co(e.currentTarget),t.hitRegions.forEach(s=>{const i=Ht(s.group.id,!0);Nt(s.group,i)}),e.preventDefault())}}function Da(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=Ve(o.defaultSize);s+=a,i[o.panelId]=a}else i[o.panelId]=void 0;const n=e.length-t;if(n!==0){const o=Ve((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=o)}return i}function Sm(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const n=Es({group:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:Ve(o/n*100),inPixels:o};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function wm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Cm({group:e,nextGroupSize:t,prevGroupSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let n=0,o=0,a=!1;const l=new Map,h=[];for(const m of e.panels){const f=i[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const _=f/100*s,p=Ve(_/t*100);l.set(m.id,p),n+=p;break}case"preserve-relative-size":default:{h.push(m.id),o+=f;break}}}if(!a||h.length===0)return i;const c=100-n,u={...i};if(l.forEach((m,f)=>{u[f]=m}),o>0)for(const m of h){const f=i[m]??0;u[m]=Ve(f/o*c)}else{const m=Ve(c/h.length);for(const f of h)u[f]=m}return u}function km(e,t){const s=e.map(n=>n.id),i=Object.keys(t);if(s.length!==i.length)return!1;for(const n of s)if(!i.includes(n))return!1;return!0}const _s=new Map;function Nm(e){let t=!0;pe(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const s=e.element.ownerDocument.defaultView.ResizeObserver,i=new Set,n=new Set,o=new s(p=>{for(const g of p){const{borderBoxSize:v,target:y}=g;if(y===e.element){if(t){const x=Es({group:e});if(x===0)return;const k=Ht(e.id);if(!k)return;const N=an(e),w=k.defaultLayoutDeferred?Da(N):k.layout,D=Cm({group:e,nextGroupSize:x,prevGroupSize:k.groupSize,prevLayout:w}),T=rs({layout:D,panelConstraints:N});if(!k.defaultLayoutDeferred&&is(k.layout,T)&&wm(k.derivedPanelConstraints,N)&&k.groupSize===x)return;Nt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:N,groupSize:x,layout:T,separatorToPanels:k.separatorToPanels})}}else Sm(e,y,v)}});o.observe(e.element),e.panels.forEach(p=>{pe(!i.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),i.add(p.id),p.onResize&&o.observe(p.element)});const a=Es({group:e}),l=an(e),h=e.panels.map(({id:p})=>p).join(",");let c=e.mutableState.defaultLayout;c&&(km(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[h]??c??Da(l),m=rs({layout:u,panelConstraints:l}),f=e.element.ownerDocument;_s.set(f,(_s.get(f)??0)+1);const _=new Map;return bc(e).forEach(p=>{p.separator&&_.set(p.separator,p.panels)}),Nt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:m,separatorToPanels:_}),e.separators.forEach(p=>{pe(!n.has(p.id),`Separator ids must be unique; id "${p.id}" was used more than once`),n.add(p.id),p.element.addEventListener("keydown",va)}),_s.get(f)===1&&(f.addEventListener("dblclick",xa,!0),f.addEventListener("pointerdown",ba,!0),f.addEventListener("pointerleave",ka),f.addEventListener("pointermove",Na),f.addEventListener("pointerout",ja),f.addEventListener("pointerup",Ea,!0)),function(){t=!1,_s.set(f,Math.max(0,(_s.get(f)??0)-1)),lm(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",va)}),_s.get(f)||(f.removeEventListener("dblclick",xa,!0),f.removeEventListener("pointerdown",ba,!0),f.removeEventListener("pointerleave",ka),f.removeEventListener("pointermove",Na),f.removeEventListener("pointerout",ja),f.removeEventListener("pointerup",Ea,!0)),o.disconnect()}}function jm(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function ho(e){const t=d.useId();return`${e??t}`}const hs=typeof window<"u"?d.useLayoutEffect:d.useEffect;function oi(e){const t=d.useRef(e);return hs(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function uo(...e){return oi(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function fo(e){const t=d.useRef({...e});return hs(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Pc=d.createContext(null);function Em(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:bm});d.useImperativeHandle(t,()=>s.current,[]),hs(()=>{Object.assign(s.current,kc({groupId:e}))})}function cn({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:f,..._}){const p=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),g=oi(A=>{is(p.current.onLayoutChange,A)||(p.current.onLayoutChange=A,h==null||h(A))}),v=oi(A=>{is(p.current.onLayoutChanged,A)||(p.current.onLayoutChanged=A,c==null||c(A))}),y=ho(l),x=d.useRef(null),[k,N]=jm(),w=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),D=uo(x,o);Em(y,a);const T=oi((A,M)=>{const E=ns(),L=ma(A),S=Ht(A);if(S){let j=!1;switch(E.state){case"active":{j=E.hitRegions.some(C=>C.group===L);break}}return{flexGrow:S.layout[M]??1,pointerEvents:j?"none":void 0}}return{flexGrow:(s==null?void 0:s[M])??1}}),U=fo({defaultLayout:s,disableCursor:i}),G=d.useMemo(()=>({get disableCursor(){return!!U.disableCursor},getPanelStyles:T,id:y,orientation:u,registerPanel:A=>{const M=w.current;return M.panels=ln(u,[...M.panels,A]),N(),()=>{M.panels=M.panels.filter(E=>E!==A),N()}},registerSeparator:A=>{const M=w.current;return M.separators=ln(u,[...M.separators,A]),N(),()=>{M.separators=M.separators.filter(E=>E!==A),N()}},togglePanelDisabled:(A,M)=>{const E=w.current.panels.find(j=>j.id===A);E&&(E.panelConstraints.disabled=M);const L=ma(y),S=Ht(y);L&&S&&Nt(L,{...S,derivedPanelConstraints:an(L)})},toggleSeparatorDisabled:(A,M)=>{const E=w.current.separators.find(L=>L.id===A);E&&(E.disabled=M)}}),[T,y,N,u,U]),K=d.useRef(null);return hs(()=>{const A=x.current;if(A===null)return;const M=w.current;let E;if(U.defaultLayout!==void 0&&Object.keys(U.defaultLayout).length===M.panels.length){E={};for(const oe of M.panels){const q=U.defaultLayout[oe.id];q!==void 0&&(E[oe.id]=q)}}const L={disabled:!!n,element:A,id:y,mutableState:{defaultLayout:E,disableCursor:!!U.disableCursor,expandedPanelSizes:w.current.lastExpandedPanelSizes,layouts:w.current.layouts},orientation:u,panels:M.panels,resizeTargetMinimumSize:M.resizeTargetMinimumSize,separators:M.separators};K.current=L;const S=Nm(L),{defaultLayoutDeferred:j,derivedPanelConstraints:C,layout:B}=Ht(L.id,!0);!j&&C.length>0&&(g(B),v(B));const X=oo(y,oe=>{const{defaultLayoutDeferred:q,derivedPanelConstraints:Q,layout:ie}=oe.next;if(q||Q.length===0)return;const de=L.panels.map(({id:z})=>z).join(",");L.mutableState.layouts[de]=ie,Q.forEach(z=>{if(z.collapsible){const{layout:V}=oe.prev??{};if(V){const J=He(z.collapsedSize,ie[z.panelId]),R=He(z.collapsedSize,V[z.panelId]);J&&!R&&(L.mutableState.expandedPanelSizes[z.panelId]=V[z.panelId])}}});const ue=ns().state!=="active";g(ie),ue&&v(ie)});return()=>{K.current=null,S(),X()}},[n,y,v,g,u,k,U]),d.useEffect(()=>{const A=K.current;A&&(A.mutableState.defaultLayout=s,A.mutableState.disableCursor=!!i)}),r.jsx(Pc.Provider,{value:G,children:r.jsx("div",{..._,className:t,"data-group":!0,"data-testid":y,id:y,ref:D,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}cn.displayName="Group";function mo(){const e=d.useContext(Pc);return pe(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Dm(e,t){const{id:s}=mo(),i=d.useRef({collapse:Mr,expand:Mr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Mr});d.useImperativeHandle(t,()=>i.current,[]),hs(()=>{Object.assign(i.current,Cc({groupId:s,panelId:e}))})}function Js({children:e,className:t,collapsedSize:s="0%",collapsible:i=!1,defaultSize:n,disabled:o,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:h,maxSize:c="100%",minSize:u="0%",onResize:m,panelRef:f,style:_,...p}){const g=!!h,v=ho(h),y=fo({disabled:o}),x=d.useRef(null),k=uo(x,a),{getPanelStyles:N,id:w,orientation:D,registerPanel:T,togglePanelDisabled:U}=mo(),G=m!==null,K=oi((M,E,L)=>{m==null||m(M,h,L)});hs(()=>{const M=x.current;if(M!==null){const E={element:M,id:v,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?K:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:n,disabled:y.disabled,maxSize:c,minSize:u}};return T(E)}},[l,s,i,n,G,v,g,c,u,K,T,y]),d.useEffect(()=>{U(v,!!o)},[o,v,U]),Dm(v,f);const A=d.useSyncExternalStore(M=>oo(w,M),()=>JSON.stringify(N(w,v)),()=>JSON.stringify(N(w,v)));return r.jsx("div",{...p,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":v,id:v,ref:k,style:{...Rm,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(A)},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",..._,touchAction:D==="horizontal"?"pan-y":"pan-x"},children:e})})}Js.displayName="Panel";const Rm={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Pm({layout:e,panelConstraints:t,panelId:s,panelIndex:i}){let n,o;const a=e[s],l=t.find(h=>h.panelId===s);if(l){const h=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,u=[i,i+1];o=rs({layout:ci({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s],n=rs({layout:ci({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function hn({children:e,className:t,disabled:s,elementRef:i,id:n,style:o,...a}){const l=ho(n),h=fo({disabled:s}),[c,u]=d.useState({}),[m,f]=d.useState("inactive"),_=d.useRef(null),p=uo(_,i),{disableCursor:g,id:v,orientation:y,registerSeparator:x,toggleSeparatorDisabled:k}=mo(),N=y==="horizontal"?"vertical":"horizontal";hs(()=>{const D=_.current;if(D!==null){const T={disabled:h.disabled,element:D,id:l},U=x(T),G=xm(A=>{f(A.next.state!=="inactive"&&A.next.hitRegions.some(M=>M.separator===T)?A.next.state:"inactive")}),K=oo(v,A=>{const{derivedPanelConstraints:M,layout:E,separatorToPanels:L}=A.next,S=L.get(T);if(S){const j=S[0],C=S.indexOf(j);u(Pm({layout:E,panelConstraints:M,panelId:j.id,panelIndex:C}))}});return()=>{G(),K(),U()}}},[v,l,x,h]),d.useEffect(()=>{k(l,!!s)},[s,l,k]);let w;return s&&!g&&(w="not-allowed"),r.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":s||void 0,"aria-orientation":N,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":m,"data-testid":l,id:l,ref:p,role:"separator",style:{flexBasis:"auto",cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}hn.displayName="Separator";const Mm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Lm={sm:"w-7 h-7",md:"w-8 h-8"},Bm={sm:14,md:16};function Pt({icon:e,label:t,size:s="md",variant:i="ghost",onClick:n,className:o="",disabled:a=!1,title:l}){return r.jsx("button",{type:"button","aria-label":t,title:l??t,disabled:a,onClick:n,className:["inline-flex items-center justify-center rounded-btn transition-colors",Mm[i],Lm[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:Bm[s]})})}function Tm({x:e,y:t,items:s,onClose:i}){const[n,o]=d.useState(0),a=d.useRef(null),l=d.useRef([]);d.useEffect(()=>{var c;(c=l.current[0])==null||c.focus()},[]),d.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=d.useCallback(c=>{var u,m;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),o(f=>{var p;const _=(f+1)%s.length;return(p=l.current[_])==null||p.focus(),_});break;case"ArrowUp":c.preventDefault(),o(f=>{var p;const _=(f-1+s.length)%s.length;return(p=l.current[_])==null||p.focus(),_});break;case"Home":c.preventDefault(),o(0),(u=l.current[0])==null||u.focus();break;case"End":c.preventDefault(),o(s.length-1),(m=l.current[s.length-1])==null||m.focus();break}},[s.length,i]);return r.jsx("div",{ref:a,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:h,children:s.map((c,u)=>{const m=c.icon,f=c.variant==="danger";return r.jsxs("button",{ref:_=>{l.current[u]=_},role:"menuitem",tabIndex:n===u?0:-1,onClick:()=>{c.onClick(),i()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",f?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[r.jsx(m,{size:14}),c.label]},c.label)})})}/**
|
|
172
|
+
`},fa=df(pf)(hc),gf={config:ff},_f=function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return function(n){return s.reduceRight(function(o,a){return a(o)},n)}};function dc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],dc(e[s],t[s]))}),ha(ha({},e),t)}var xf={type:"cancelation",msg:"operation is manually canceled"};function Dr(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(xf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var vf=["monaco"],bf=cf.create({config:hf,isInitialized:!1,resolve:null,reject:null,monaco:null}),uc=Uu(bf,2),pi=uc[0],gr=uc[1];function yf(e){var t=gf.config(e),s=t.monaco,i=Hu(t,vf);gr(function(n){return{config:dc(n.config,i),monaco:s}})}function Sf(){var e=pi(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(gr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Dr(Rr);if(window.monaco&&window.monaco.editor)return fc(window.monaco),e.resolve(window.monaco),Dr(Rr);_f(wf,kf)(jf)}return Dr(Rr)}function wf(e){return document.body.appendChild(e)}function Cf(e){var t=document.createElement("script");return e&&(t.src=e),t}function kf(e){var t=pi(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=Cf("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function jf(){var e=pi(function(s){var i=s.config,n=s.resolve,o=s.reject;return{config:i,resolve:n,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var i=s.m||s;fc(i),e.resolve(i)},function(s){e.reject(s)})}function fc(e){pi().monaco||gr({monaco:e})}function Nf(){return pi(function(e){var t=e.monaco;return t})}var Rr=new Promise(function(e,t){return gr({resolve:e,reject:t})}),mc={config:yf,init:Sf,__getMonacoInstance:Nf},Ef={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Pr=Ef,Df={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Rf=Df;function Pf({children:e}){return ks.createElement("div",{style:Rf.container},e)}var Mf=Pf,Lf=Mf;function Bf({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return ks.createElement("section",{style:{...Pr.wrapper,width:e,height:t},...a},!s&&ks.createElement(Lf,null,i),ks.createElement("div",{ref:n,style:{...Pr.fullWidth,...!s&&Pr.hide},className:o}))}var Tf=Bf,pc=d.memo(Tf);function zf(e){d.useEffect(e,[])}var gc=zf;function Af(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var Qe=Af;function ni(){}function Ss(e,t,s,i){return Of(e,i)||$f(e,t,s,i)}function Of(e,t){return e.editor.getModel(_c(e,t))}function $f(e,t,s,i){return e.editor.createModel(t,s,i?_c(e,i):void 0)}function _c(e,t){return e.Uri.parse(t)}function If({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:u="Loading...",options:m={},height:f="100%",width:_="100%",className:p,wrapperProps:g={},beforeMount:v=ni,onMount:y=ni}){let[x,k]=d.useState(!1),[j,w]=d.useState(!0),D=d.useRef(null),T=d.useRef(null),U=d.useRef(null),G=d.useRef(y),K=d.useRef(v),A=d.useRef(!1);gc(()=>{let S=mc.init();return S.then(N=>(T.current=N)&&w(!1)).catch(N=>(N==null?void 0:N.type)!=="cancelation"&&console.error("Monaco initialization: error:",N)),()=>D.current?L():S.cancel()}),Qe(()=>{if(D.current&&T.current){let S=D.current.getOriginalEditor(),N=Ss(T.current,e||"",i||s||"text",o||"");N!==S.getModel()&&S.setModel(N)}},[o],x),Qe(()=>{if(D.current&&T.current){let S=D.current.getModifiedEditor(),N=Ss(T.current,t||"",n||s||"text",a||"");N!==S.getModel()&&S.setModel(N)}},[a],x),Qe(()=>{let S=D.current.getModifiedEditor();S.getOption(T.current.editor.EditorOption.readOnly)?S.setValue(t||""):t!==S.getValue()&&(S.executeEdits("",[{range:S.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),S.pushUndoStop())},[t],x),Qe(()=>{var S,N;(N=(S=D.current)==null?void 0:S.getModel())==null||N.original.setValue(e||"")},[e],x),Qe(()=>{let{original:S,modified:N}=D.current.getModel();T.current.editor.setModelLanguage(S,i||s||"text"),T.current.editor.setModelLanguage(N,n||s||"text")},[s,i,n],x),Qe(()=>{var S;(S=T.current)==null||S.editor.setTheme(c)},[c],x),Qe(()=>{var S;(S=D.current)==null||S.updateOptions(m)},[m],x);let M=d.useCallback(()=>{var C;if(!T.current)return;K.current(T.current);let S=Ss(T.current,e||"",i||s||"text",o||""),N=Ss(T.current,t||"",n||s||"text",a||"");(C=D.current)==null||C.setModel({original:S,modified:N})},[s,t,n,e,i,o,a]),E=d.useCallback(()=>{var S;!A.current&&U.current&&(D.current=T.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...m}),M(),(S=T.current)==null||S.editor.setTheme(c),k(!0),A.current=!0)},[m,c,M]);d.useEffect(()=>{x&&G.current(D.current,T.current)},[x]),d.useEffect(()=>{!j&&!x&&E()},[j,x,E]);function L(){var N,C,B,X;let S=(N=D.current)==null?void 0:N.getModel();l||((C=S==null?void 0:S.original)==null||C.dispose()),h||((B=S==null?void 0:S.modified)==null||B.dispose()),(X=D.current)==null||X.dispose()}return ks.createElement(pc,{width:_,height:f,isEditorReady:x,loading:u,_ref:U,className:p,wrapperProps:g})}var Ff=If;d.memo(Ff);function Hf(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var Wf=Hf,Li=new Map;function Uf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:u={},saveViewState:m=!0,keepCurrentModel:f=!1,width:_="100%",height:p="100%",className:g,wrapperProps:v={},beforeMount:y=ni,onMount:x=ni,onChange:k,onValidate:j=ni}){let[w,D]=d.useState(!1),[T,U]=d.useState(!0),G=d.useRef(null),K=d.useRef(null),A=d.useRef(null),M=d.useRef(x),E=d.useRef(y),L=d.useRef(),S=d.useRef(i),N=Wf(o),C=d.useRef(!1),B=d.useRef(!1);gc(()=>{let q=mc.init();return q.then(Q=>(G.current=Q)&&U(!1)).catch(Q=>(Q==null?void 0:Q.type)!=="cancelation"&&console.error("Monaco initialization: error:",Q)),()=>K.current?oe():q.cancel()}),Qe(()=>{var Q,ie,de,ue;let q=Ss(G.current,e||i||"",t||n||"",o||s||"");q!==((Q=K.current)==null?void 0:Q.getModel())&&(m&&Li.set(N,(ie=K.current)==null?void 0:ie.saveViewState()),(de=K.current)==null||de.setModel(q),m&&((ue=K.current)==null||ue.restoreViewState(Li.get(o))))},[o],w),Qe(()=>{var q;(q=K.current)==null||q.updateOptions(c)},[c],w),Qe(()=>{!K.current||i===void 0||(K.current.getOption(G.current.editor.EditorOption.readOnly)?K.current.setValue(i):i!==K.current.getValue()&&(B.current=!0,K.current.executeEdits("",[{range:K.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),K.current.pushUndoStop(),B.current=!1))},[i],w),Qe(()=>{var Q,ie;let q=(Q=K.current)==null?void 0:Q.getModel();q&&n&&((ie=G.current)==null||ie.editor.setModelLanguage(q,n))},[n],w),Qe(()=>{var q;l!==void 0&&((q=K.current)==null||q.revealLine(l))},[l],w),Qe(()=>{var q;(q=G.current)==null||q.editor.setTheme(a)},[a],w);let X=d.useCallback(()=>{var q;if(!(!A.current||!G.current)&&!C.current){E.current(G.current);let Q=o||s,ie=Ss(G.current,i||e||"",t||n||"",Q||"");K.current=(q=G.current)==null?void 0:q.editor.create(A.current,{model:ie,automaticLayout:!0,...c},u),m&&K.current.restoreViewState(Li.get(Q)),G.current.editor.setTheme(a),l!==void 0&&K.current.revealLine(l),D(!0),C.current=!0}},[e,t,s,i,n,o,c,u,m,a,l]);d.useEffect(()=>{w&&M.current(K.current,G.current)},[w]),d.useEffect(()=>{!T&&!w&&X()},[T,w,X]),S.current=i,d.useEffect(()=>{var q,Q;w&&k&&((q=L.current)==null||q.dispose(),L.current=(Q=K.current)==null?void 0:Q.onDidChangeModelContent(ie=>{B.current||k(K.current.getValue(),ie)}))},[w,k]),d.useEffect(()=>{if(w){let q=G.current.editor.onDidChangeMarkers(Q=>{var de;let ie=(de=K.current.getModel())==null?void 0:de.uri;if(ie&&Q.find(ue=>ue.path===ie.path)){let ue=G.current.editor.getModelMarkers({resource:ie});j==null||j(ue)}});return()=>{q==null||q.dispose()}}return()=>{}},[w,j]);function oe(){var q,Q;(q=L.current)==null||q.dispose(),f?m&&Li.set(o,K.current.saveViewState()):(Q=K.current.getModel())==null||Q.dispose(),K.current.dispose()}return ks.createElement(pc,{width:_,height:p,isEditorReady:w,loading:h,_ref:A,className:g,wrapperProps:v})}var Kf=Uf,qf=d.memo(Kf),Vf=qf;function Gf(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function Yf(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function Xf(e){return e/100*window.innerHeight}function Jf(e){return e/100*window.innerWidth}function Zf(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Xs({groupSize:e,panelElement:t,styleProp:s}){let i;const[n,o]=Zf(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=Yf(t,n);break}case"em":{i=Gf(t,n);break}case"vh":{i=Xf(n);break}case"vw":{i=Jf(n);break}}return i}function Ve(e){return parseFloat(e.toFixed(3))}function Es({group:e}){const{orientation:t,panels:s}=e;return s.reduce((i,n)=>(i+=t==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,i),0)}function an(e){const{panels:t}=e,s=Es({group:e});return s===0?t.map(i=>({groupResizeBehavior:i.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:i.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:i.panelConstraints.disabled,minSize:0,maxSize:100,panelId:i.id})):t.map(i=>{const{element:n,panelConstraints:o}=i;let a=0;if(o.collapsedSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.collapsedSize});a=Ve(u/s*100)}let l;if(o.defaultSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.defaultSize});l=Ve(u/s*100)}let h=0;if(o.minSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.minSize});h=Ve(u/s*100)}let c=100;if(o.maxSize!==void 0){const u=Xs({groupSize:s,panelElement:n,styleProp:o.maxSize});c=Ve(u/s*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:a,collapsible:o.collapsible===!0,defaultSize:l,disabled:o.disabled,minSize:h,maxSize:c,panelId:i.id}})}function pe(e,t="Assertion error"){if(!e)throw Error(t)}function ln(e,t){return Array.from(t).sort(e==="horizontal"?Qf:em)}function Qf(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function em(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function xc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function vc(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function tm({orientation:e,rects:t,targetRect:s}){const i={x:s.x+s.width/2,y:s.y+s.height/2};let n,o=Number.MAX_VALUE;for(const a of t){const{x:l,y:h}=vc(i,a),c=e==="horizontal"?l:h;c<o&&(o=c,n=a)}return pe(n,"No rect found"),n}let Bi;function sm(){return Bi===void 0&&(typeof matchMedia=="function"?Bi=!!matchMedia("(pointer:coarse)").matches:Bi=!1),Bi}function bc(e){const{element:t,orientation:s,panels:i,separators:n}=e,o=ln(s,Array.from(t.children).filter(xc).map(p=>({element:p}))).map(({element:p})=>p),a=[];let l=!1,h=!1,c=-1,u=-1,m=0,f,_=[];{let p=-1;for(const g of o)g.hasAttribute("data-panel")&&(p++,g.ariaDisabled===null&&(m++,c===-1&&(c=p),u=p))}if(m>1){let p=-1;for(const g of o)if(g.hasAttribute("data-panel")){p++;const v=i.find(y=>y.element===g);if(v){if(f){const y=f.element.getBoundingClientRect(),x=g.getBoundingClientRect();let k;if(h){const j=s==="horizontal"?new DOMRect(y.right,y.top,0,y.height):new DOMRect(y.left,y.bottom,y.width,0),w=s==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(_.length){case 0:{k=[j,w];break}case 1:{const D=_[0],T=tm({orientation:s,rects:[y,x],targetRect:D.element.getBoundingClientRect()});k=[D,T===y?w:j];break}default:{k=_;break}}}else _.length?k=_:k=[s==="horizontal"?new DOMRect(y.right,x.top,x.left-y.right,x.height):new DOMRect(x.left,y.bottom,x.width,x.top-y.bottom)];for(const j of k){let w="width"in j?j:j.element.getBoundingClientRect();const D=sm()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(w.width<D){const U=D-w.width;w=new DOMRect(w.x-U/2,w.y,w.width+U,w.height)}if(w.height<D){const U=D-w.height;w=new DOMRect(w.x,w.y-U/2,w.width,w.height+U)}const T=p<=c||p>u;!l&&!T&&a.push({group:e,groupSize:Es({group:e}),panels:[f,v],separator:"width"in j?void 0:j,rect:w}),l=!1}}h=!1,f=v,_=[]}}else if(g.hasAttribute("data-separator")){g.ariaDisabled!==null&&(l=!0);const v=n.find(y=>y.element===g);v?_.push(v):(f=void 0,_=[])}else h=!0}return a}var zt,Il;let yc=(Il=class{constructor(){ia(this,zt,{})}addListener(t,s){const i=Fs(this,zt)[t];return i===void 0?Fs(this,zt)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Fs(this,zt)[t];if(i!==void 0)if(i.length===1)i[0].call(null,s);else{let n=!1,o=null;const a=Array.from(i);for(let l=0;l<a.length;l++){const h=a[l];try{h.call(null,s)}catch(c){o===null&&(n=!0,o=c)}}if(n)throw o}}removeAllListeners(){ra(this,zt,{})}removeListener(t,s){const i=Fs(this,zt)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},zt=new WeakMap,Il),mt=new Map;const Sc=new yc;function im(e){mt=new Map(mt),mt.delete(e)}function ma(e,t){for(const[s]of mt)if(s.id===e)return s}function Ht(e,t){for(const[s,i]of mt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function cs(){return mt}function oo(e,t){return Sc.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function jt(e,t){const s=mt.get(e);mt=new Map(mt),mt.set(e,t),Sc.emit("groupChange",{group:e,prev:s,next:t})}function rm(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=vc(s,o.rect);switch(e){case"horizontal":{a.x<=n.x&&(i=o,n=a);break}case"vertical":{a.y<=n.y&&(i=o,n=a);break}}}return i?{distance:n,hitRegion:i}:void 0}function nm(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function om(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:_a(e),b:_a(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();pe(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:ga(pa(s.a)),b:ga(pa(s.b))};if(n.a===n.b){const o=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let l=o.length;for(;l--;){const h=o[l];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(n.a-n.b)}const am=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function lm(e){const t=getComputedStyle(wc(e)??e).display;return t==="flex"||t==="inline-flex"}function cm(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||lm(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||am.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function pa(e){let t=e.length;for(;t--;){const s=e[t];if(pe(s,"Missing node"),cm(s))return s}return null}function ga(e){return e&&Number(getComputedStyle(e).zIndex)||0}function _a(e){const t=[];for(;e;)t.push(e),e=wc(e);return t}function wc(e){const{parentNode:t}=e;return nm(t)?t.host:t}function hm(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function dm({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!xc(s)||s.contains(e)||e.contains(s))return!0;if(om(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(hm(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function ao(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=bc(n),a=rm(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&dm({groupElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function um(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=t[s])return!1;return!0}function He(e,t,s=0){return Math.abs(Ve(e)-Ve(t))<=s}function ut(e,t){return He(e,t)?0:e>t?1:-1}function ws({overrideDisabledPanels:e,panelConstraints:t,prevSize:s,size:i}){const{collapsedSize:n=0,collapsible:o,disabled:a,maxSize:l=100,minSize:h=0}=t;if(a&&!e)return s;if(ut(i,h)<0)if(o){const c=(n+h)/2;ut(i,c)<0?i=n:i=h}else i=h;return i=Math.min(l,i),i=Ve(i),i}function ci({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(He(e,0))return t;const a=o==="imperative-api",l=Object.values(t),h=Object.values(n),c=[...l],[u,m]=i;pe(u!=null,"Invalid first pivot index"),pe(m!=null,"Invalid second pivot index");let f=0;switch(o){case"keyboard":{{const g=e<0?m:u,v=s[g];pe(v,`Panel constraints not found for index ${g}`);const{collapsedSize:y=0,collapsible:x,minSize:k=0}=v;if(x){const j=l[g];if(pe(j!=null,`Previous layout not found for panel index ${g}`),He(j,y)){const w=k-j;ut(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const g=e<0?u:m,v=s[g];pe(v,`No panel constraints found for index ${g}`);const{collapsedSize:y=0,collapsible:x,minSize:k=0}=v;if(x){const j=l[g];if(pe(j!=null,`Previous layout not found for panel index ${g}`),He(j,k)){const w=j-y;ut(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const g=e<0?m:u,v=s[g];pe(v,`Panel constraints not found for index ${g}`);const y=l[g],{collapsible:x,collapsedSize:k,minSize:j}=v;if(x&&ut(y,j)<0)if(e>0){const w=j-k,D=w/2,T=y+e;ut(T,j)<0&&(e=ut(e,D)<=0?0:w)}else{const w=j-k,D=100-w/2,T=y-e;ut(T,j)<0&&(e=ut(100+e,D)>0?0:-w)}break}}{const g=e<0?1:-1;let v=e<0?m:u,y=0;for(;;){const k=l[v];pe(k!=null,`Previous layout not found for panel index ${v}`);const j=ws({overrideDisabledPanels:a,panelConstraints:s[v],prevSize:k,size:100})-k;if(y+=j,v+=g,v<0||v>=s.length)break}const x=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-x:x}{let g=e<0?u:m;for(;g>=0&&g<s.length;){const v=Math.abs(e)-Math.abs(f),y=l[g];pe(y!=null,`Previous layout not found for panel index ${g}`);const x=y-v,k=ws({overrideDisabledPanels:a,panelConstraints:s[g],prevSize:y,size:x});if(!He(y,k)&&(f+=y-k,c[g]=k,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(um(h,c))return n;{const g=e<0?m:u,v=l[g];pe(v!=null,`Previous layout not found for panel index ${g}`);const y=v+f,x=ws({overrideDisabledPanels:a,panelConstraints:s[g],prevSize:v,size:y});if(c[g]=x,!He(x,y)){let k=y-x,j=e<0?m:u;for(;j>=0&&j<s.length;){const w=c[j];pe(w!=null,`Previous layout not found for panel index ${j}`);const D=w+k,T=ws({overrideDisabledPanels:a,panelConstraints:s[j],prevSize:w,size:D});if(He(w,T)||(k-=T-w,c[j]=T),He(k,0))break;e>0?j--:j++}}}const _=Object.values(c).reduce((g,v)=>v+g,0);if(!He(_,100,.1))return n;const p=Object.keys(n);return c.reduce((g,v,y)=>(g[p[y]]=v,g),{})}function is(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||ut(e[s],t[s])!==0)return!1;return!0}function rs({layout:e,panelConstraints:t}){const s=Object.values(e),i=[...s],n=i.reduce((l,h)=>l+h,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(l=>`${l}%`).join(", ")}`);if(!He(n,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=100/n*h;i[l]=c}let o=0;for(let l=0;l<t.length;l++){const h=s[l];pe(h!=null,`No layout data found for index ${l}`);const c=i[l];pe(c!=null,`No layout data found for index ${l}`);const u=ws({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=u&&(o+=c-u,i[l]=u)}if(!He(o,0))for(let l=0;l<t.length;l++){const h=i[l];pe(h!=null,`No layout data found for index ${l}`);const c=h+o,u=ws({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==u&&(o-=u-h,i[l]=u,He(o,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function Cc({groupId:e,panelId:t}){const s=()=>{const l=cs();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:u,layout:m,groupSize:f,separatorToPanels:_}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:h,groupSize:f,layout:m,separatorToPanels:_};throw Error(`Group ${e} not found`)},i=()=>{const l=s().derivedPanelConstraints.find(h=>h.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},n=()=>{const l=s().group.panels.find(h=>h.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const l=s().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const h=o();if(l===h)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:u,group:m,groupSize:f,layout:_,separatorToPanels:p}=s(),g=m.panels.findIndex(k=>k.id===t),v=g===m.panels.length-1,y=ci({delta:v?h-l:l-h,initialLayout:_,panelConstraints:u,pivotIndices:v?[g-1,g]:[g,g+1],prevLayout:_,trigger:"imperative-api"}),x=rs({layout:y,panelConstraints:u});is(_,x)||jt(m,{defaultLayoutDeferred:c,derivedPanelConstraints:u,groupSize:f,layout:x,separatorToPanels:p})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=n(),u=o();l&&u!==h&&(c.expandToSize=u,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:u}=n(),m=o();if(l&&m===h){let f=u.expandToSize??c;f===0&&(f=1),a(f)}},getSize:()=>{const{group:l}=s(),h=o(),{element:c}=n(),u=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:u}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=o();return l&&He(h,c)},resize:l=>{const{group:h}=s(),{element:c}=n(),u=Es({group:h}),m=Xs({groupSize:u,panelElement:c,styleProp:l}),f=Ve(m/u*100);a(f)}}}function xa(e){if(e.defaultPrevented)return;const t=cs();ao(e,t).forEach(s=>{if(s.separator){const i=s.panels.find(n=>n.panelConstraints.defaultSize!==void 0);if(i){const n=i.panelConstraints.defaultSize,o=Cc({groupId:s.group.id,panelId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Wi(e){const t=cs();for(const[s]of t)if(s.separators.some(i=>i.element===e))return s;throw Error("Could not find parent Group for separator element")}function kc({groupId:e}){const t=()=>{const s=cs();for(const[i,n]of s)if(i.id===e)return{group:i,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:s,layout:i}=t();return s?{}:i},setLayout(s){const{defaultLayoutDeferred:i,derivedPanelConstraints:n,group:o,groupSize:a,layout:l,separatorToPanels:h}=t(),c=rs({layout:s,panelConstraints:n});return i?l:(is(l,c)||jt(o,{defaultLayoutDeferred:i,derivedPanelConstraints:n,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function qt(e,t){const s=Wi(e),i=Ht(s.id,!0),n=s.separators.find(u=>u.element===e);pe(n,"Matching separator not found");const o=i.separatorToPanels.get(n);pe(o,"Matching panels not found");const a=o.map(u=>s.panels.indexOf(u)),l=kc({groupId:s.id}).getLayout(),h=ci({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=rs({layout:h,panelConstraints:i.derivedPanelConstraints});is(l,c)||jt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function va(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=Wi(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&qt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&qt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&qt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&qt(t,-5);break}case"End":{e.preventDefault(),qt(t,100);break}case"Enter":{e.preventDefault();const i=Wi(t),n=Ht(i.id,!0),{derivedPanelConstraints:o,layout:a,separatorToPanels:l}=n,h=i.separators.find(f=>f.element===t);pe(h,"Matching separator not found");const c=l.get(h);pe(c,"Matching panels not found");const u=c[0],m=o.find(f=>f.panelId===u.id);if(pe(m,"Panel metadata not found"),m.collapsible){const f=a[u.id],_=m.collapsedSize===f?i.mutableState.expandedPanelSizes[u.id]??m.minSize:m.collapsedSize;qt(t,_-f)}break}case"F6":{e.preventDefault();const i=Wi(t).separators.map(a=>a.element),n=Array.from(i).findIndex(a=>a===e.currentTarget);pe(n!==null,"Index not found");const o=e.shiftKey?n>0?n-1:i.length-1:n+1<i.length?n+1:0;i[o].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),qt(t,-100);break}}}let js={cursorFlags:0,state:"inactive"};const lo=new yc;function ns(){return js}function fm(e){return lo.addListener("change",e)}function mm(e){const t=js,s={...js};s.cursorFlags=e,js=s,lo.emit("change",{prev:t,next:s})}function Ns(e){const t=js;js=e,lo.emit("change",{prev:t,next:e})}function ba(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=cs(),s=ao(e,t),i=new Map;let n=!1;s.forEach(o=>{o.separator&&(n||(n=!0,o.separator.element.focus({preventScroll:!0})));const a=t.get(o.group);a&&i.set(o.group,a.layout)}),Ns({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const pm=e=>e,Mr=()=>{},jc=1,Nc=2,Ec=4,Dc=8,ya=3,Sa=12;let Ti;function wa(){return Ti===void 0&&(Ti=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ti=!0)),Ti}function gm({cursorFlags:e,groups:t,state:s}){let i=0,n=0;switch(s){case"active":case"hover":t.forEach(o=>{if(!o.mutableState.disableCursor)switch(o.orientation){case"horizontal":{i++;break}case"vertical":{n++;break}}})}if(!(i===0&&n===0)){switch(s){case"active":{if(e&&wa()){const o=(e&jc)!==0,a=(e&Nc)!==0,l=(e&Ec)!==0,h=(e&Dc)!==0;if(o)return l?"se-resize":h?"ne-resize":"e-resize";if(a)return l?"sw-resize":h?"nw-resize":"w-resize";if(l)return"s-resize";if(h)return"n-resize"}break}}return wa()?i>0&&n>0?"move":i>0?"ew-resize":"ns-resize":i>0&&n>0?"grab":i>0?"col-resize":"row-resize"}}const Ca=new WeakMap;function co(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=Ca.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=ns();switch(i.state){case"active":case"hover":{const n=gm({cursorFlags:i.cursorFlags,groups:i.hitRegions.map(a=>a.group),state:i.state}),o=`*, *:hover {cursor: ${n} !important; }`;if(t===o)return;t=o,n?s.cssRules.length===0?s.insertRule(o):s.replaceSync(o):s.cssRules.length===1&&s.deleteRule(0);break}case"inactive":{t=void 0,s.cssRules.length===1&&s.deleteRule(0);break}}Ca.set(e,{prevStyle:t,styleSheet:s})}function Rc({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:n,pointerDownAtPoint:o,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:u,groupSize:m}=c,{orientation:f,panels:_}=u,{disableCursor:p}=u.mutableState;let g=0;o?f==="horizontal"?g=(t.clientX-o.x)/m*100:g=(t.clientY-o.y)/m*100:f==="horizontal"?g=t.clientX<0?-100:100:g=t.clientY<0?-100:100;const v=i.get(u),y=n.get(u);if(!v||!y)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:k,groupSize:j,layout:w,separatorToPanels:D}=y;if(k&&w&&D){const T=ci({delta:g,initialLayout:v,panelConstraints:k,pivotIndices:c.panels.map(U=>_.indexOf(U)),prevLayout:w,trigger:"mouse-or-touch"});if(is(T,w)){if(g!==0&&!p)switch(f){case"horizontal":{l|=g<0?jc:Nc;break}case"vertical":{l|=g<0?Ec:Dc;break}}}else jt(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:k,groupSize:j,layout:T,separatorToPanels:D})}});let h=0;t.movementX===0?h|=a&ya:h|=l&ya,t.movementY===0?h|=a&Sa:h|=l&Sa,mm(h),co(e)}function ka(e){const t=cs(),s=ns();switch(s.state){case"active":Rc({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function ja(e){if(e.defaultPrevented)return;const t=ns(),s=cs();switch(t.state){case"active":{if(e.buttons===0){Ns({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const n=Ht(i.group.id,!0);jt(i.group,n)});return}Rc({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=ao(e,s);i.length===0?t.state!=="inactive"&&Ns({cursorFlags:0,state:"inactive"}):Ns({cursorFlags:0,hitRegions:i,state:"hover"}),co(e.currentTarget);break}}}function Na(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ns().state){case"hover":Ns({cursorFlags:0,state:"inactive"})}}function Ea(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ns();switch(t.state){case"active":Ns({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(co(e.currentTarget),t.hitRegions.forEach(s=>{const i=Ht(s.group.id,!0);jt(s.group,i)}),e.preventDefault())}}function Da(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=Ve(o.defaultSize);s+=a,i[o.panelId]=a}else i[o.panelId]=void 0;const n=e.length-t;if(n!==0){const o=Ve((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=o)}return i}function _m(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const n=Es({group:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:Ve(o/n*100),inPixels:o};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function xm(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function vm({group:e,nextGroupSize:t,prevGroupSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let n=0,o=0,a=!1;const l=new Map,h=[];for(const m of e.panels){const f=i[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const _=f/100*s,p=Ve(_/t*100);l.set(m.id,p),n+=p;break}case"preserve-relative-size":default:{h.push(m.id),o+=f;break}}}if(!a||h.length===0)return i;const c=100-n,u={...i};if(l.forEach((m,f)=>{u[f]=m}),o>0)for(const m of h){const f=i[m]??0;u[m]=Ve(f/o*c)}else{const m=Ve(c/h.length);for(const f of h)u[f]=m}return u}function bm(e,t){const s=e.map(n=>n.id),i=Object.keys(t);if(s.length!==i.length)return!1;for(const n of s)if(!i.includes(n))return!1;return!0}const _s=new Map;function ym(e){let t=!0;pe(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const s=e.element.ownerDocument.defaultView.ResizeObserver,i=new Set,n=new Set,o=new s(p=>{for(const g of p){const{borderBoxSize:v,target:y}=g;if(y===e.element){if(t){const x=Es({group:e});if(x===0)return;const k=Ht(e.id);if(!k)return;const j=an(e),w=k.defaultLayoutDeferred?Da(j):k.layout,D=vm({group:e,nextGroupSize:x,prevGroupSize:k.groupSize,prevLayout:w}),T=rs({layout:D,panelConstraints:j});if(!k.defaultLayoutDeferred&&is(k.layout,T)&&xm(k.derivedPanelConstraints,j)&&k.groupSize===x)return;jt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:j,groupSize:x,layout:T,separatorToPanels:k.separatorToPanels})}}else _m(e,y,v)}});o.observe(e.element),e.panels.forEach(p=>{pe(!i.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),i.add(p.id),p.onResize&&o.observe(p.element)});const a=Es({group:e}),l=an(e),h=e.panels.map(({id:p})=>p).join(",");let c=e.mutableState.defaultLayout;c&&(bm(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[h]??c??Da(l),m=rs({layout:u,panelConstraints:l}),f=e.element.ownerDocument;_s.set(f,(_s.get(f)??0)+1);const _=new Map;return bc(e).forEach(p=>{p.separator&&_.set(p.separator,p.panels)}),jt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:m,separatorToPanels:_}),e.separators.forEach(p=>{pe(!n.has(p.id),`Separator ids must be unique; id "${p.id}" was used more than once`),n.add(p.id),p.element.addEventListener("keydown",va)}),_s.get(f)===1&&(f.addEventListener("dblclick",xa,!0),f.addEventListener("pointerdown",ba,!0),f.addEventListener("pointerleave",ka),f.addEventListener("pointermove",ja),f.addEventListener("pointerout",Na),f.addEventListener("pointerup",Ea,!0)),function(){t=!1,_s.set(f,Math.max(0,(_s.get(f)??0)-1)),im(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",va)}),_s.get(f)||(f.removeEventListener("dblclick",xa,!0),f.removeEventListener("pointerdown",ba,!0),f.removeEventListener("pointerleave",ka),f.removeEventListener("pointermove",ja),f.removeEventListener("pointerout",Na),f.removeEventListener("pointerup",Ea,!0)),o.disconnect()}}function Sm(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function ho(e){const t=d.useId();return`${e??t}`}const hs=typeof window<"u"?d.useLayoutEffect:d.useEffect;function oi(e){const t=d.useRef(e);return hs(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function uo(...e){return oi(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function fo(e){const t=d.useRef({...e});return hs(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Pc=d.createContext(null);function wm(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:pm});d.useImperativeHandle(t,()=>s.current,[]),hs(()=>{Object.assign(s.current,kc({groupId:e}))})}function cn({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:f,..._}){const p=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),g=oi(A=>{is(p.current.onLayoutChange,A)||(p.current.onLayoutChange=A,h==null||h(A))}),v=oi(A=>{is(p.current.onLayoutChanged,A)||(p.current.onLayoutChanged=A,c==null||c(A))}),y=ho(l),x=d.useRef(null),[k,j]=Sm(),w=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),D=uo(x,o);wm(y,a);const T=oi((A,M)=>{const E=ns(),L=ma(A),S=Ht(A);if(S){let N=!1;switch(E.state){case"active":{N=E.hitRegions.some(C=>C.group===L);break}}return{flexGrow:S.layout[M]??1,pointerEvents:N?"none":void 0}}return{flexGrow:(s==null?void 0:s[M])??1}}),U=fo({defaultLayout:s,disableCursor:i}),G=d.useMemo(()=>({get disableCursor(){return!!U.disableCursor},getPanelStyles:T,id:y,orientation:u,registerPanel:A=>{const M=w.current;return M.panels=ln(u,[...M.panels,A]),j(),()=>{M.panels=M.panels.filter(E=>E!==A),j()}},registerSeparator:A=>{const M=w.current;return M.separators=ln(u,[...M.separators,A]),j(),()=>{M.separators=M.separators.filter(E=>E!==A),j()}},togglePanelDisabled:(A,M)=>{const E=w.current.panels.find(N=>N.id===A);E&&(E.panelConstraints.disabled=M);const L=ma(y),S=Ht(y);L&&S&&jt(L,{...S,derivedPanelConstraints:an(L)})},toggleSeparatorDisabled:(A,M)=>{const E=w.current.separators.find(L=>L.id===A);E&&(E.disabled=M)}}),[T,y,j,u,U]),K=d.useRef(null);return hs(()=>{const A=x.current;if(A===null)return;const M=w.current;let E;if(U.defaultLayout!==void 0&&Object.keys(U.defaultLayout).length===M.panels.length){E={};for(const oe of M.panels){const q=U.defaultLayout[oe.id];q!==void 0&&(E[oe.id]=q)}}const L={disabled:!!n,element:A,id:y,mutableState:{defaultLayout:E,disableCursor:!!U.disableCursor,expandedPanelSizes:w.current.lastExpandedPanelSizes,layouts:w.current.layouts},orientation:u,panels:M.panels,resizeTargetMinimumSize:M.resizeTargetMinimumSize,separators:M.separators};K.current=L;const S=ym(L),{defaultLayoutDeferred:N,derivedPanelConstraints:C,layout:B}=Ht(L.id,!0);!N&&C.length>0&&(g(B),v(B));const X=oo(y,oe=>{const{defaultLayoutDeferred:q,derivedPanelConstraints:Q,layout:ie}=oe.next;if(q||Q.length===0)return;const de=L.panels.map(({id:z})=>z).join(",");L.mutableState.layouts[de]=ie,Q.forEach(z=>{if(z.collapsible){const{layout:V}=oe.prev??{};if(V){const J=He(z.collapsedSize,ie[z.panelId]),R=He(z.collapsedSize,V[z.panelId]);J&&!R&&(L.mutableState.expandedPanelSizes[z.panelId]=V[z.panelId])}}});const ue=ns().state!=="active";g(ie),ue&&v(ie)});return()=>{K.current=null,S(),X()}},[n,y,v,g,u,k,U]),d.useEffect(()=>{const A=K.current;A&&(A.mutableState.defaultLayout=s,A.mutableState.disableCursor=!!i)}),r.jsx(Pc.Provider,{value:G,children:r.jsx("div",{..._,className:t,"data-group":!0,"data-testid":y,id:y,ref:D,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}cn.displayName="Group";function mo(){const e=d.useContext(Pc);return pe(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Cm(e,t){const{id:s}=mo(),i=d.useRef({collapse:Mr,expand:Mr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Mr});d.useImperativeHandle(t,()=>i.current,[]),hs(()=>{Object.assign(i.current,Cc({groupId:s,panelId:e}))})}function Js({children:e,className:t,collapsedSize:s="0%",collapsible:i=!1,defaultSize:n,disabled:o,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:h,maxSize:c="100%",minSize:u="0%",onResize:m,panelRef:f,style:_,...p}){const g=!!h,v=ho(h),y=fo({disabled:o}),x=d.useRef(null),k=uo(x,a),{getPanelStyles:j,id:w,orientation:D,registerPanel:T,togglePanelDisabled:U}=mo(),G=m!==null,K=oi((M,E,L)=>{m==null||m(M,h,L)});hs(()=>{const M=x.current;if(M!==null){const E={element:M,id:v,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?K:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:n,disabled:y.disabled,maxSize:c,minSize:u}};return T(E)}},[l,s,i,n,G,v,g,c,u,K,T,y]),d.useEffect(()=>{U(v,!!o)},[o,v,U]),Cm(v,f);const A=d.useSyncExternalStore(M=>oo(w,M),()=>JSON.stringify(j(w,v)),()=>JSON.stringify(j(w,v)));return r.jsx("div",{...p,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":v,id:v,ref:k,style:{...km,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(A)},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",..._,touchAction:D==="horizontal"?"pan-y":"pan-x"},children:e})})}Js.displayName="Panel";const km={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function jm({layout:e,panelConstraints:t,panelId:s,panelIndex:i}){let n,o;const a=e[s],l=t.find(h=>h.panelId===s);if(l){const h=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,u=[i,i+1];o=rs({layout:ci({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s],n=rs({layout:ci({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function hn({children:e,className:t,disabled:s,elementRef:i,id:n,style:o,...a}){const l=ho(n),h=fo({disabled:s}),[c,u]=d.useState({}),[m,f]=d.useState("inactive"),_=d.useRef(null),p=uo(_,i),{disableCursor:g,id:v,orientation:y,registerSeparator:x,toggleSeparatorDisabled:k}=mo(),j=y==="horizontal"?"vertical":"horizontal";hs(()=>{const D=_.current;if(D!==null){const T={disabled:h.disabled,element:D,id:l},U=x(T),G=fm(A=>{f(A.next.state!=="inactive"&&A.next.hitRegions.some(M=>M.separator===T)?A.next.state:"inactive")}),K=oo(v,A=>{const{derivedPanelConstraints:M,layout:E,separatorToPanels:L}=A.next,S=L.get(T);if(S){const N=S[0],C=S.indexOf(N);u(jm({layout:E,panelConstraints:M,panelId:N.id,panelIndex:C}))}});return()=>{G(),K(),U()}}},[v,l,x,h]),d.useEffect(()=>{k(l,!!s)},[s,l,k]);let w;return s&&!g&&(w="not-allowed"),r.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":s||void 0,"aria-orientation":j,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":m,"data-testid":l,id:l,ref:p,role:"separator",style:{flexBasis:"auto",cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}hn.displayName="Separator";const Nm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Em={sm:"w-7 h-7",md:"w-8 h-8"},Dm={sm:14,md:16};function Pt({icon:e,label:t,size:s="md",variant:i="ghost",onClick:n,className:o="",disabled:a=!1,title:l}){return r.jsx("button",{type:"button","aria-label":t,title:l??t,disabled:a,onClick:n,className:["inline-flex items-center justify-center rounded-btn transition-colors",Nm[i],Em[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:Dm[s]})})}function Rm({x:e,y:t,items:s,onClose:i}){const[n,o]=d.useState(0),a=d.useRef(null),l=d.useRef([]);d.useEffect(()=>{var c;(c=l.current[0])==null||c.focus()},[]),d.useEffect(()=>{const c=u=>{a.current&&!a.current.contains(u.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=d.useCallback(c=>{var u,m;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),o(f=>{var p;const _=(f+1)%s.length;return(p=l.current[_])==null||p.focus(),_});break;case"ArrowUp":c.preventDefault(),o(f=>{var p;const _=(f-1+s.length)%s.length;return(p=l.current[_])==null||p.focus(),_});break;case"Home":c.preventDefault(),o(0),(u=l.current[0])==null||u.focus();break;case"End":c.preventDefault(),o(s.length-1),(m=l.current[s.length-1])==null||m.focus();break}},[s.length,i]);return r.jsx("div",{ref:a,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:h,children:s.map((c,u)=>{const m=c.icon,f=c.variant==="danger";return r.jsxs("button",{ref:_=>{l.current[u]=_},role:"menuitem",tabIndex:n===u?0:-1,onClick:()=>{c.onClick(),i()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",f?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[r.jsx(m,{size:14}),c.label]},c.label)})})}/**
|
|
198
173
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
199
174
|
* @license MIT
|
|
200
175
|
*
|
|
@@ -205,21 +180,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
205
180
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
206
181
|
* http://bellard.org/jslinux/
|
|
207
182
|
* Copyright (c) 2011 Fabrice Bellard
|
|
208
|
-
*/var Mc=Object.defineProperty,
|
|
183
|
+
*/var Mc=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Mm=(e,t)=>{for(var s in t)Mc(e,s,{get:t[s],enumerable:!0})},we=(e,t,s,i)=>{for(var n=i>1?void 0:i?Pm(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(n=(i?a(t,s,n):a(n))||n);return i&&n&&Mc(t,s,n),n},H=(e,t)=>(s,i)=>t(s,i,e),Ra="Terminal input",dn={get:()=>Ra,set:e=>Ra=e},Pa="Too much output to announce, navigate to rows manually to read",un={get:()=>Pa,set:e=>Pa=e};function Lm(e){return e.replace(/\r?\n/g,"\r")}function Bm(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Tm(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function zm(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let n=e.clipboardData.getData("text/plain");Lc(n,t,s,i)}}function Lc(e,t,s,i){e=Lm(e),e=Bm(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Bc(e,t,s){let i=s.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${n}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function Ma(e,t,s,i,n){Bc(e,t,s),n&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function Tt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _r(e,t=0,s=e.length){let i="";for(let n=t;n<s;++n){let o=e[n];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var Am=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=n;o<s;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[i++]=(a-55296)*1024+l-56320+65536:(t[i++]=a,t[i++]=l);continue}a!==65279&&(t[i++]=a)}return i}},Om=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let f=!1,_=this.interim[0];_&=(_&224)===192?31:(_&240)===224?15:7;let p=0,g;for(;(g=this.interim[++p]&63)&&p<4;)_<<=6,_|=g;let v=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=v-p;for(;c<y;){if(c>=s)return 0;if(g=e[c++],(g&192)!==128){c--,f=!0;break}else this.interim[p++]=g,_<<=6,_|=g&63}f||(v===2?_<128?c--:t[i++]=_:v===3?_<2048||_>=55296&&_<=57343||_===65279||(t[i++]=_):_<65536||_>1114111||(t[i++]=_)),this.interim.fill(0)}let u=s-4,m=c;for(;m<s;){for(;m<u&&!((n=e[m])&128)&&!((o=e[m+1])&128)&&!((a=e[m+2])&128)&&!((l=e[m+3])&128);)t[i++]=n,t[i++]=o,t[i++]=a,t[i++]=l,m+=4;if(n=e[m++],n<128)t[i++]=n;else if((n&224)===192){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(h=(n&31)<<6|o&63,h<128){m--;continue}t[i++]=h}else if((n&240)===224){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[m++],(a&192)!==128){m--;continue}if(h=(n&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[i++]=h}else if((n&248)===240){if(m>=s)return this.interim[0]=n,i;if(o=e[m++],(o&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[m++],(a&192)!==128){m--;continue}if(m>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,i;if(l=e[m++],(l&192)!==128){m--;continue}if(h=(n&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},Tc="",At=" ",gi=class zc{constructor(){this.fg=0,this.bg=0,this.extended=new ir}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new zc;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ir=class Ac{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Ac(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},rt=class Oc extends gi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ir,this.combinedData=""}static fromCharData(t){let s=new Oc;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Tt(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let n=t[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(i-55296)*1024+n-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},La="di$target",fn="di$dependencies",Lr=new Map;function $m(e){return e[fn]||[]}function Ae(e){if(Lr.has(e))return Lr.get(e);let t=function(s,i,n){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Im(t,s,n)};return t._id=e,Lr.set(e,t),t}function Im(e,t,s){t[La]===t?t[fn].push({id:e,index:s}):(t[fn]=[{id:e,index:s}],t[La]=t)}var We=Ae("BufferService"),$c=Ae("CoreMouseService"),ds=Ae("CoreService"),Fm=Ae("CharsetService"),po=Ae("InstantiationService"),Ic=Ae("LogService"),Ue=Ae("OptionsService"),Fc=Ae("OscLinkService"),Hm=Ae("UnicodeService"),_i=Ae("DecorationService"),mn=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var u;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],n=this._optionsService.rawOptions.linkHandler,o=new rt,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let m=0;m<a;m++)if(!(h===-1&&!s.hasContent(m))){if(s.loadCell(m,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=m,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&m===a-1){let f=(u=this._oscLinkService.getLinkData(l))==null?void 0:u.uri;if(f){let _={start:{x:h+1,y:e},end:{x:m+(!c&&m===a-1?1:0),y:e}},p=!1;if(!(n!=null&&n.allowNonHttpProtocols))try{let g=new URL(f);["http:","https:"].includes(g.protocol)||(p=!0)}catch{p=!0}p||i.push({text:f,range:_,activate:(g,v)=>n?n.activate(g,v,_):Wm(g,v),hover:(g,v)=>{var y;return(y=n==null?void 0:n.hover)==null?void 0:y.call(n,g,v,_)},leave:(g,v)=>{var y;return(y=n==null?void 0:n.leave)==null?void 0:y.call(n,g,v,_)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=m,l=o.extended.urlId):(h=-1,l=-1)}}t(i)}};mn=we([H(0,We),H(1,Ue),H(2,Fc)],mn);function Wm(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
209
184
|
|
|
210
|
-
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var xr=Ae("CharSizeService"),
|
|
185
|
+
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var xr=Ae("CharSizeService"),Nt=Ae("CoreBrowserService"),go=Ae("MouseService"),Et=Ae("RenderService"),Um=Ae("SelectionService"),Hc=Ae("CharacterJoinerService"),Ps=Ae("ThemeService"),Wc=Ae("LinkProviderService"),Km=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ba.isErrorNoTelemetry(e)?new Ba(e.message+`
|
|
211
186
|
|
|
212
187
|
`+e.stack):new Error(e.message+`
|
|
213
188
|
|
|
214
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Jm=new Xm;function Ui(e){Zm(e)||Jm.onUnexpectedError(e)}var pn="Canceled";function Zm(e){return e instanceof Qm?!0:e instanceof Error&&e.name===pn&&e.message===pn}var Qm=class extends Error{constructor(){super(pn),this.name=this.message}};function ep(e){return new Error(`Illegal argument: ${e}`)}var Ba=class gn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof gn)return t;let s=new gn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},_n=class Uc extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Uc.prototype)}};function Je(e,t=0){return e[e.length-(1+t)]}var tp;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function n(o){return o===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(tp||(tp={}));function sp(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var Kc;(e=>{function t(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(N){yield N}e.single=n;function o(N){return t(N)?N:n(N)}e.wrap=o;function a(N){return N||s}e.from=a;function*l(N){for(let w=N.length-1;w>=0;w--)yield N[w]}e.reverse=l;function h(N){return!N||N[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(N){return N[Symbol.iterator]().next().value}e.first=c;function u(N,w){let D=0;for(let T of N)if(w(T,D++))return!0;return!1}e.some=u;function m(N,w){for(let D of N)if(w(D))return D}e.find=m;function*f(N,w){for(let D of N)w(D)&&(yield D)}e.filter=f;function*_(N,w){let D=0;for(let T of N)yield w(T,D++)}e.map=_;function*p(N,w){let D=0;for(let T of N)yield*w(T,D++)}e.flatMap=p;function*g(...N){for(let w of N)yield*w}e.concat=g;function v(N,w,D){let T=D;for(let U of N)T=w(T,U);return T}e.reduce=v;function*y(N,w,D=N.length){for(w<0&&(w+=N.length),D<0?D+=N.length:D>N.length&&(D=N.length);w<D;w++)yield N[w]}e.slice=y;function x(N,w=Number.POSITIVE_INFINITY){let D=[];if(w===0)return[D,N];let T=N[Symbol.iterator]();for(let U=0;U<w;U++){let G=T.next();if(G.done)return[D,e.empty()];D.push(G.value)}return[D,{[Symbol.iterator](){return T}}]}e.consume=x;async function k(N){let w=[];for await(let D of N)w.push(D);return Promise.resolve(w)}e.asyncToArray=k})(Kc||(Kc={}));function os(e){if(Kc.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function ip(...e){return ve(()=>os(e))}function ve(e){return{dispose:sp(()=>{e()})}}var qc=class Vc{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{os(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Vc.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};qc.DISABLE_DISPOSED_WARNING=!1;var Wt=qc,ne=class{constructor(){this._store=new Wt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ne.None=Object.freeze({dispose(){}});var Ds=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Ct=typeof window=="object"?window:globalThis,xn=class vn{constructor(t){this.element=t,this.next=vn.Undefined,this.prev=vn.Undefined}};xn.Undefined=new xn(void 0);var be=xn,Ta=class{constructor(){this._first=be.Undefined,this._last=be.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===be.Undefined}clear(){let e=this._first;for(;e!==be.Undefined;){let t=e.next;e.prev=be.Undefined,e.next=be.Undefined,e=t}this._first=be.Undefined,this._last=be.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new be(e);if(this._first===be.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==be.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==be.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==be.Undefined&&e.next!==be.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===be.Undefined&&e.next===be.Undefined?(this._first=be.Undefined,this._last=be.Undefined):e.next===be.Undefined?(this._last=this._last.prev,this._last.next=be.Undefined):e.prev===be.Undefined&&(this._first=this._first.next,this._first.prev=be.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==be.Undefined;)yield e.element,e=e.next}},rp=globalThis.performance&&typeof globalThis.performance.now=="function",np=class Gc{static create(t){return new Gc(t)}constructor(t){this._now=rp&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},$e;(e=>{e.None=()=>ne.None;function t(M,E){return m(M,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function s(M){return(E,L=null,S)=>{let j=!1,C;return C=M(B=>{if(!j)return C?C.dispose():j=!0,E.call(L,B)},null,S),j&&C.dispose(),C}}e.once=s;function i(M,E,L){return c((S,j=null,C)=>M(B=>S.call(j,E(B)),null,C),L)}e.map=i;function n(M,E,L){return c((S,j=null,C)=>M(B=>{E(B),S.call(j,B)},null,C),L)}e.forEach=n;function o(M,E,L){return c((S,j=null,C)=>M(B=>E(B)&&S.call(j,B),null,C),L)}e.filter=o;function a(M){return M}e.signal=a;function l(...M){return(E,L=null,S)=>{let j=ip(...M.map(C=>C(B=>E.call(L,B))));return u(j,S)}}e.any=l;function h(M,E,L,S){let j=L;return i(M,C=>(j=E(j,C),j),S)}e.reduce=h;function c(M,E){let L,S={onWillAddFirstListener(){L=M(j.fire,j)},onDidRemoveLastListener(){L==null||L.dispose()}},j=new O(S);return E==null||E.add(j),j.event}function u(M,E){return E instanceof Array?E.push(M):E&&E.add(M),M}function m(M,E,L=100,S=!1,j=!1,C,B){let X,oe,q,Q=0,ie,de={leakWarningThreshold:C,onWillAddFirstListener(){X=M(z=>{Q++,oe=E(oe,z),S&&!q&&(ue.fire(oe),oe=void 0),ie=()=>{let V=oe;oe=void 0,q=void 0,(!S||Q>1)&&ue.fire(V),Q=0},typeof L=="number"?(clearTimeout(q),q=setTimeout(ie,L)):q===void 0&&(q=0,queueMicrotask(ie))})},onWillRemoveListener(){j&&Q>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,X.dispose()}},ue=new O(de);return B==null||B.add(ue),ue.event}e.debounce=m;function f(M,E=0,L){return e.debounce(M,(S,j)=>S?(S.push(j),S):[j],E,void 0,!0,void 0,L)}e.accumulate=f;function _(M,E=(S,j)=>S===j,L){let S=!0,j;return o(M,C=>{let B=S||!E(C,j);return S=!1,j=C,B},L)}e.latch=_;function p(M,E,L){return[e.filter(M,E,L),e.filter(M,S=>!E(S),L)]}e.split=p;function g(M,E=!1,L=[],S){let j=L.slice(),C=M(oe=>{j?j.push(oe):X.fire(oe)});S&&S.add(C);let B=()=>{j==null||j.forEach(oe=>X.fire(oe)),j=null},X=new O({onWillAddFirstListener(){C||(C=M(oe=>X.fire(oe)),S&&S.add(C))},onDidAddFirstListener(){j&&(E?setTimeout(B):B())},onDidRemoveLastListener(){C&&C.dispose(),C=null}});return S&&S.add(X),X.event}e.buffer=g;function v(M,E){return(L,S,j)=>{let C=E(new x);return M(function(B){let X=C.evaluate(B);X!==y&&L.call(S,X)},void 0,j)}}e.chain=v;let y=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(L=>(E(L),L)),this}filter(E){return this.steps.push(L=>E(L)?L:y),this}reduce(E,L){let S=L;return this.steps.push(j=>(S=E(S,j),S)),this}latch(E=(L,S)=>L===S){let L=!0,S;return this.steps.push(j=>{let C=L||!E(j,S);return L=!1,S=j,C?j:y}),this}evaluate(E){for(let L of this.steps)if(E=L(E),E===y)break;return E}}function k(M,E,L=S=>S){let S=(...X)=>B.fire(L(...X)),j=()=>M.on(E,S),C=()=>M.removeListener(E,S),B=new O({onWillAddFirstListener:j,onDidRemoveLastListener:C});return B.event}e.fromNodeEventEmitter=k;function N(M,E,L=S=>S){let S=(...X)=>B.fire(L(...X)),j=()=>M.addEventListener(E,S),C=()=>M.removeEventListener(E,S),B=new O({onWillAddFirstListener:j,onDidRemoveLastListener:C});return B.event}e.fromDOMEventEmitter=N;function w(M){return new Promise(E=>s(M)(E))}e.toPromise=w;function D(M){let E=new O;return M.then(L=>{E.fire(L)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=D;function T(M,E){return M(L=>E.fire(L))}e.forward=T;function U(M,E,L){return E(L),M(S=>E(S))}e.runAndSubscribe=U;class G{constructor(E,L){this._observable=E,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new O(S),L&&L.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,L){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function K(M,E){return new G(M,E).emitter.event}e.fromObservable=K;function A(M){return(E,L,S)=>{let j=0,C=!1,B={beginUpdate(){j++},endUpdate(){j--,j===0&&(M.reportChanges(),C&&(C=!1,E.call(L)))},handlePossibleChange(){},handleChange(){C=!0}};M.addObserver(B),M.reportChanges();let X={dispose(){M.removeObserver(B)}};return S instanceof Wt?S.add(X):Array.isArray(S)&&S.push(X),X}}e.fromObservableLight=A})($e||($e={}));var bn=class yn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${yn._idPool++}`,yn.all.add(this)}start(t){this._stopWatch=new np,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};bn.all=new Set,bn._idPool=0;var op=bn,ap=-1,Yc=class Xc{constructor(t,s,i=(Xc._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new hp(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,n]of this._stacks)(!t||s<n)&&(t=[i,n],s=n);return t}};Yc._idPool=1;var lp=Yc,cp=class Jc{constructor(t){this.value=t}static create(){let t=new Error;return new Jc(t.stack??"")}print(){console.warn(this.value.split(`
|
|
189
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},qm=new Km;function Ui(e){Vm(e)||qm.onUnexpectedError(e)}var pn="Canceled";function Vm(e){return e instanceof Gm?!0:e instanceof Error&&e.name===pn&&e.message===pn}var Gm=class extends Error{constructor(){super(pn),this.name=this.message}};function Ym(e){return new Error(`Illegal argument: ${e}`)}var Ba=class gn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof gn)return t;let s=new gn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},_n=class Uc extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Uc.prototype)}};function Je(e,t=0){return e[e.length-(1+t)]}var Xm;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function n(o){return o===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Xm||(Xm={}));function Jm(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var Kc;(e=>{function t(j){return j&&typeof j=="object"&&typeof j[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(j){yield j}e.single=n;function o(j){return t(j)?j:n(j)}e.wrap=o;function a(j){return j||s}e.from=a;function*l(j){for(let w=j.length-1;w>=0;w--)yield j[w]}e.reverse=l;function h(j){return!j||j[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(j){return j[Symbol.iterator]().next().value}e.first=c;function u(j,w){let D=0;for(let T of j)if(w(T,D++))return!0;return!1}e.some=u;function m(j,w){for(let D of j)if(w(D))return D}e.find=m;function*f(j,w){for(let D of j)w(D)&&(yield D)}e.filter=f;function*_(j,w){let D=0;for(let T of j)yield w(T,D++)}e.map=_;function*p(j,w){let D=0;for(let T of j)yield*w(T,D++)}e.flatMap=p;function*g(...j){for(let w of j)yield*w}e.concat=g;function v(j,w,D){let T=D;for(let U of j)T=w(T,U);return T}e.reduce=v;function*y(j,w,D=j.length){for(w<0&&(w+=j.length),D<0?D+=j.length:D>j.length&&(D=j.length);w<D;w++)yield j[w]}e.slice=y;function x(j,w=Number.POSITIVE_INFINITY){let D=[];if(w===0)return[D,j];let T=j[Symbol.iterator]();for(let U=0;U<w;U++){let G=T.next();if(G.done)return[D,e.empty()];D.push(G.value)}return[D,{[Symbol.iterator](){return T}}]}e.consume=x;async function k(j){let w=[];for await(let D of j)w.push(D);return Promise.resolve(w)}e.asyncToArray=k})(Kc||(Kc={}));function os(e){if(Kc.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Zm(...e){return ve(()=>os(e))}function ve(e){return{dispose:Jm(()=>{e()})}}var qc=class Vc{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{os(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Vc.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};qc.DISABLE_DISPOSED_WARNING=!1;var Wt=qc,ne=class{constructor(){this._store=new Wt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ne.None=Object.freeze({dispose(){}});var Ds=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Ct=typeof window=="object"?window:globalThis,xn=class vn{constructor(t){this.element=t,this.next=vn.Undefined,this.prev=vn.Undefined}};xn.Undefined=new xn(void 0);var be=xn,Ta=class{constructor(){this._first=be.Undefined,this._last=be.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===be.Undefined}clear(){let e=this._first;for(;e!==be.Undefined;){let t=e.next;e.prev=be.Undefined,e.next=be.Undefined,e=t}this._first=be.Undefined,this._last=be.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new be(e);if(this._first===be.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==be.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==be.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==be.Undefined&&e.next!==be.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===be.Undefined&&e.next===be.Undefined?(this._first=be.Undefined,this._last=be.Undefined):e.next===be.Undefined?(this._last=this._last.prev,this._last.next=be.Undefined):e.prev===be.Undefined&&(this._first=this._first.next,this._first.prev=be.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==be.Undefined;)yield e.element,e=e.next}},Qm=globalThis.performance&&typeof globalThis.performance.now=="function",ep=class Gc{static create(t){return new Gc(t)}constructor(t){this._now=Qm&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},$e;(e=>{e.None=()=>ne.None;function t(M,E){return m(M,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function s(M){return(E,L=null,S)=>{let N=!1,C;return C=M(B=>{if(!N)return C?C.dispose():N=!0,E.call(L,B)},null,S),N&&C.dispose(),C}}e.once=s;function i(M,E,L){return c((S,N=null,C)=>M(B=>S.call(N,E(B)),null,C),L)}e.map=i;function n(M,E,L){return c((S,N=null,C)=>M(B=>{E(B),S.call(N,B)},null,C),L)}e.forEach=n;function o(M,E,L){return c((S,N=null,C)=>M(B=>E(B)&&S.call(N,B),null,C),L)}e.filter=o;function a(M){return M}e.signal=a;function l(...M){return(E,L=null,S)=>{let N=Zm(...M.map(C=>C(B=>E.call(L,B))));return u(N,S)}}e.any=l;function h(M,E,L,S){let N=L;return i(M,C=>(N=E(N,C),N),S)}e.reduce=h;function c(M,E){let L,S={onWillAddFirstListener(){L=M(N.fire,N)},onDidRemoveLastListener(){L==null||L.dispose()}},N=new O(S);return E==null||E.add(N),N.event}function u(M,E){return E instanceof Array?E.push(M):E&&E.add(M),M}function m(M,E,L=100,S=!1,N=!1,C,B){let X,oe,q,Q=0,ie,de={leakWarningThreshold:C,onWillAddFirstListener(){X=M(z=>{Q++,oe=E(oe,z),S&&!q&&(ue.fire(oe),oe=void 0),ie=()=>{let V=oe;oe=void 0,q=void 0,(!S||Q>1)&&ue.fire(V),Q=0},typeof L=="number"?(clearTimeout(q),q=setTimeout(ie,L)):q===void 0&&(q=0,queueMicrotask(ie))})},onWillRemoveListener(){N&&Q>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,X.dispose()}},ue=new O(de);return B==null||B.add(ue),ue.event}e.debounce=m;function f(M,E=0,L){return e.debounce(M,(S,N)=>S?(S.push(N),S):[N],E,void 0,!0,void 0,L)}e.accumulate=f;function _(M,E=(S,N)=>S===N,L){let S=!0,N;return o(M,C=>{let B=S||!E(C,N);return S=!1,N=C,B},L)}e.latch=_;function p(M,E,L){return[e.filter(M,E,L),e.filter(M,S=>!E(S),L)]}e.split=p;function g(M,E=!1,L=[],S){let N=L.slice(),C=M(oe=>{N?N.push(oe):X.fire(oe)});S&&S.add(C);let B=()=>{N==null||N.forEach(oe=>X.fire(oe)),N=null},X=new O({onWillAddFirstListener(){C||(C=M(oe=>X.fire(oe)),S&&S.add(C))},onDidAddFirstListener(){N&&(E?setTimeout(B):B())},onDidRemoveLastListener(){C&&C.dispose(),C=null}});return S&&S.add(X),X.event}e.buffer=g;function v(M,E){return(L,S,N)=>{let C=E(new x);return M(function(B){let X=C.evaluate(B);X!==y&&L.call(S,X)},void 0,N)}}e.chain=v;let y=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(L=>(E(L),L)),this}filter(E){return this.steps.push(L=>E(L)?L:y),this}reduce(E,L){let S=L;return this.steps.push(N=>(S=E(S,N),S)),this}latch(E=(L,S)=>L===S){let L=!0,S;return this.steps.push(N=>{let C=L||!E(N,S);return L=!1,S=N,C?N:y}),this}evaluate(E){for(let L of this.steps)if(E=L(E),E===y)break;return E}}function k(M,E,L=S=>S){let S=(...X)=>B.fire(L(...X)),N=()=>M.on(E,S),C=()=>M.removeListener(E,S),B=new O({onWillAddFirstListener:N,onDidRemoveLastListener:C});return B.event}e.fromNodeEventEmitter=k;function j(M,E,L=S=>S){let S=(...X)=>B.fire(L(...X)),N=()=>M.addEventListener(E,S),C=()=>M.removeEventListener(E,S),B=new O({onWillAddFirstListener:N,onDidRemoveLastListener:C});return B.event}e.fromDOMEventEmitter=j;function w(M){return new Promise(E=>s(M)(E))}e.toPromise=w;function D(M){let E=new O;return M.then(L=>{E.fire(L)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=D;function T(M,E){return M(L=>E.fire(L))}e.forward=T;function U(M,E,L){return E(L),M(S=>E(S))}e.runAndSubscribe=U;class G{constructor(E,L){this._observable=E,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new O(S),L&&L.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,L){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function K(M,E){return new G(M,E).emitter.event}e.fromObservable=K;function A(M){return(E,L,S)=>{let N=0,C=!1,B={beginUpdate(){N++},endUpdate(){N--,N===0&&(M.reportChanges(),C&&(C=!1,E.call(L)))},handlePossibleChange(){},handleChange(){C=!0}};M.addObserver(B),M.reportChanges();let X={dispose(){M.removeObserver(B)}};return S instanceof Wt?S.add(X):Array.isArray(S)&&S.push(X),X}}e.fromObservableLight=A})($e||($e={}));var bn=class yn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${yn._idPool++}`,yn.all.add(this)}start(t){this._stopWatch=new ep,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};bn.all=new Set,bn._idPool=0;var tp=bn,sp=-1,Yc=class Xc{constructor(t,s,i=(Xc._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new np(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,n]of this._stacks)(!t||s<n)&&(t=[i,n],s=n);return t}};Yc._idPool=1;var ip=Yc,rp=class Jc{constructor(t){this.value=t}static create(){let t=new Error;return new Jc(t.stack??"")}print(){console.warn(this.value.split(`
|
|
215
190
|
`).slice(2).join(`
|
|
216
|
-
`))}},hp=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},dp=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},up=0,Br=class{constructor(e){this.value=e,this.id=up++}},fp=2,mp,O=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new lp((t==null?void 0:t.onListenerError)??Ui,((i=this._options)==null?void 0:i.leakWarningThreshold)??ap):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new op(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,s,i,n;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,h,c,u,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new dp(`${f}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Ui)(p),ne.None}if(this._disposed)return ne.None;s&&(t=t.bind(s));let n=new Br(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=cp.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Br?(this._deliveryQueue??(this._deliveryQueue=new pp),this._listeners=[this._listeners,n]):this._listeners.push(n):((c=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||c.call(h,this),this._listeners=n,(m=(u=this._options)==null?void 0:u.onDidAddFirstListener)==null||m.call(u,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Wt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,l,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||h.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*fp<=s.length){let c=0;for(let u=0;u<s.length;u++)s[u]?s[c++]=s[u]:n&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=c}}_deliver(t,s){var n;if(!t)return;let i=((n=this._options)==null?void 0:n.onListenerError)||Ui;if(!i){t.value(s);return}try{t.value(s)}catch(o){i(o)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,n,o;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof Br)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},pp=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Sn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new O,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new O,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Sn.INSTANCE=new Sn;var _o=Sn;function gp(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}_o.INSTANCE.onDidChangeZoomLevel;function _p(e){return _o.INSTANCE.getZoomFactor(e)}_o.INSTANCE.onDidChangeFullscreen;var Ms=typeof navigator=="object"?navigator.userAgent:"",wn=Ms.indexOf("Firefox")>=0,xp=Ms.indexOf("AppleWebKit")>=0,xo=Ms.indexOf("Chrome")>=0,vp=!xo&&Ms.indexOf("Safari")>=0;Ms.indexOf("Electron/")>=0;Ms.indexOf("Android")>=0;var Tr=!1;if(typeof Ct.matchMedia=="function"){let e=Ct.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Ct.matchMedia("(display-mode: fullscreen)");Tr=e.matches,gp(Ct,e,({matches:s})=>{Tr&&t.matches||(Tr=s)})}var Cs="en",Cn=!1,kn=!1,Ki=!1,Zc=!1,zi,qi=Cs,za=Cs,bp,lt,Qt=globalThis,Oe,Fl;typeof Qt.vscode<"u"&&typeof Qt.vscode.process<"u"?Oe=Qt.vscode.process:typeof process<"u"&&typeof((Fl=process==null?void 0:process.versions)==null?void 0:Fl.node)=="string"&&(Oe=process);var Hl,yp=typeof((Hl=Oe==null?void 0:Oe.versions)==null?void 0:Hl.electron)=="string",Sp=yp&&(Oe==null?void 0:Oe.type)==="renderer",Wl;if(typeof Oe=="object"){Cn=Oe.platform==="win32",kn=Oe.platform==="darwin",Ki=Oe.platform==="linux",Ki&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,zi=Cs,qi=Cs;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);zi=t.userLocale,za=t.osLocale,qi=t.resolvedLanguage||Cs,bp=(Wl=t.languagePack)==null?void 0:Wl.translationsConfigFile}catch{}Zc=!0}else typeof navigator=="object"&&!Sp?(lt=navigator.userAgent,Cn=lt.indexOf("Windows")>=0,kn=lt.indexOf("Macintosh")>=0,(lt.indexOf("Macintosh")>=0||lt.indexOf("iPad")>=0||lt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ki=lt.indexOf("Linux")>=0,(lt==null?void 0:lt.indexOf("Mobi"))>=0,qi=globalThis._VSCODE_NLS_LANGUAGE||Cs,zi=navigator.language.toLowerCase(),za=zi):console.error("Unable to resolve platform.");var Qc=Cn,_t=kn,wp=Ki,Aa=Zc,xt=lt,Mt=qi,Cp;(e=>{function t(){return Mt}e.value=t;function s(){return Mt.length===2?Mt==="en":Mt.length>=3?Mt[0]==="e"&&Mt[1]==="n"&&Mt[2]==="-":!1}e.isDefaultVariant=s;function i(){return Mt==="en"}e.isDefault=i})(Cp||(Cp={}));var kp=typeof Qt.postMessage=="function"&&!Qt.importScripts;(()=>{if(kp){let e=[];Qt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,n=e.length;i<n;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Qt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var Np=!!(xt&&xt.indexOf("Chrome")>=0);xt&&xt.indexOf("Firefox")>=0;!Np&&xt&&xt.indexOf("Safari")>=0;xt&&xt.indexOf("Edg/")>=0;xt&&xt.indexOf("Android")>=0;var xs=typeof navigator=="object"?navigator:{};Aa||document.queryCommandSupported&&document.queryCommandSupported("copy")||xs&&xs.clipboard&&xs.clipboard.writeText,Aa||xs&&xs.clipboard&&xs.clipboard.readText;var vo=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},zr=new vo,Oa=new vo,$a=new vo,jp=new Array(230),eh;(e=>{function t(l){return zr.keyCodeToStr(l)}e.toString=t;function s(l){return zr.strToKeyCode(l)}e.fromString=s;function i(l){return Oa.keyCodeToStr(l)}e.toUserSettingsUS=i;function n(l){return $a.keyCodeToStr(l)}e.toUserSettingsGeneral=n;function o(l){return Oa.strToKeyCode(l)||$a.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return zr.keyCodeToStr(l)}e.toElectronAccelerator=a})(eh||(eh={}));var Ep=class th{constructor(t,s,i,n,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=n,this.keyCode=o}equals(t){return t instanceof th&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${t}${s}${i}${n}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Dp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Dp=class{constructor(e){if(e.length===0)throw ep("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Rp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return eh.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(wn)switch(t){case 59:return 85;case 60:if(wp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(_t)return 57;break}else if(xp&&(_t&&t===93||!_t&&t===92))return 57;return jp[t]||0}var Pp=_t?256:2048,Mp=512,Lp=1024,Bp=_t?2048:256,Ia=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=Rp(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=Pp),this.altKey&&(t|=Mp),this.shiftKey&&(t|=Lp),this.metaKey&&(t|=Bp),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Ep(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Fa=new WeakMap;function Tp(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var zp=class{static getSameOriginWindowChain(e){let t=Fa.get(e);if(!t){t=[],Fa.set(e,t);let s=e,i;do i=Tp(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,n=this.getSameOriginWindowChain(e);for(let o of n){let a=o.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Ai=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=zp.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Ha=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(xo){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,l=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*l):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?wn&&!_t?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")vp&&Qc?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*l):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?wn&&!_t?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},sh=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),Ap;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Op?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:sh})})(Ap||(Ap={}));var Op=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?sh:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},bo=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new _n("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _n("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},$p=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new _n("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ve(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Ip;(e=>{async function t(i){let n,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{n||(n=l)})));if(typeof n<"u")throw n;return o}e.settled=t;function s(i){return new Promise(async(n,o)=>{try{await i(n,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Ip||(Ip={}));var Wa=class st{static fromArray(t){return new st(s=>{s.emitMany(t)})}static fromPromise(t){return new st(async s=>{s.emitMany(await t)})}static fromPromises(t){return new st(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new st(async s=>{await Promise.all(t.map(async i=>{for await(let n of i)s.emitOne(n)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new O,queueMicrotask(async()=>{let i={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(i)),this.resolve()}catch(n){this.reject(n)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new st(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return st.map(this,t)}static filter(t,s){return new st(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return st.filter(this,t)}static coalesce(t){return st.filter(t,s=>!!s)}coalesce(){return st.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return st.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Wa.EMPTY=Wa.fromArray([]);var{getWindow:pt,getWindowId:Fp,onDidRegisterWindow:Hp}=(function(){let e=new Map,t={window:Ct,disposables:new Wt};e.set(Ct.vscodeWindowId,t);let s=new O,i=new O,n=new O;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ne.None;let l=new Wt,h={window:a,disposables:l.add(new Wt)};return e.set(a.vscodeWindowId,h),l.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(Y(a,Me.BEFORE_UNLOAD,()=>{n.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:Ct},getDocument(a){return pt(a).document}}})(),Wp=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Y(e,t,s,i){return new Wp(e,t,s,i)}var Ua=function(e,t,s,i){return Y(e,t,s,i)},yo,Up=class extends $p{constructor(e){super(),this.defaultTarget=e&&pt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},Ka=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ui(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,n=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(Ka.sort),a.shift().execute();i.set(o,!1)};yo=(o,a,l=0)=>{let h=Fp(o),c=new Ka(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),c}})();function Kp(e){let t=e.getBoundingClientRect(),s=pt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Me={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},qp=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=qe(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=qe(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=qe(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=qe(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=qe(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=qe(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=qe(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=qe(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=qe(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=qe(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=qe(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=qe(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=qe(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=qe(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function qe(e){return typeof e=="number"?`${e}px`:e}function ai(e){return new qp(e)}var ih=class{constructor(){this._hooks=new Wt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(ve(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=pt(e)}this._hooks.add(Y(o,Me.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Y(o,Me.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Vp(e,t,s){let i=null,n=null;if(typeof s.value=="function"?(i="value",n=s.value,n.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",n=s.get),!n)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,a)}),this[o]}}var dt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(dt||(dt={}));var Zs=class Ie extends ne{constructor(){super(),this.dispatched=!1,this.targets=new Ta,this.ignoreTargets=new Ta,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(Hp,({window:t,disposables:s})=>{s.add(Y(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(Y(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(Y(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Ct,disposables:this._store}))}static addTarget(t){if(!Ie.isTouchDevice())return ne.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.targets.push(t);return ve(s)}static ignoreTarget(t){if(!Ie.isTouchDevice())return ne.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.ignoreTargets.push(t);return ve(s)}static isTouchDevice(){return"ontouchstart"in Ct||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,n=t.targetTouches.length;i<n;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(dt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Ie.HOLD_DELAY&&Math.abs(h.initialPageX-Je(h.rollingPageX))<30&&Math.abs(h.initialPageY-Je(h.rollingPageY))<30){let u=this.newGestureEvent(dt.Tap,h.initialTarget);u.pageX=Je(h.rollingPageX),u.pageY=Je(h.rollingPageY),this.dispatchEvent(u)}else if(c>=Ie.HOLD_DELAY&&Math.abs(h.initialPageX-Je(h.rollingPageX))<30&&Math.abs(h.initialPageY-Je(h.rollingPageY))<30){let u=this.newGestureEvent(dt.Contextmenu,h.initialTarget);u.pageX=Je(h.rollingPageX),u.pageY=Je(h.rollingPageY),this.dispatchEvent(u)}else if(n===1){let u=Je(h.rollingPageX),m=Je(h.rollingPageY),f=Je(h.rollingTimestamps)-h.rollingTimestamps[0],_=u-h.rollingPageX[0],p=m-h.rollingPageY[0],g=[...this.targets].filter(v=>h.initialTarget instanceof Node&&v.contains(h.initialTarget));this.inertia(t,g,i,Math.abs(_)/f,_>0?1:-1,u,Math.abs(p)/f,p>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(dt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===dt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ie.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===dt.Change||t.type===dt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let n=0,o=t.initialTarget;for(;o&&o!==i;)n++,o=o.parentElement;s.push([n,i])}s.sort((i,n)=>i[0]-n[0]);for(let[i,n]of s)n.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,n,o,a,l,h,c){this.handle=yo(t,()=>{let u=Date.now(),m=u-i,f=0,_=0,p=!0;n+=Ie.SCROLL_FRICTION*m,l+=Ie.SCROLL_FRICTION*m,n>0&&(p=!1,f=o*n*m),l>0&&(p=!1,_=h*l*m);let g=this.newGestureEvent(dt.Change);g.translationX=f,g.translationY=_,s.forEach(v=>v.dispatchEvent(g)),p||this.inertia(t,s,u,n,o,a+f,l,h,c+_)})}onTouchMove(t){let s=Date.now();for(let i=0,n=t.changedTouches.length;i<n;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(dt.Change,a.initialTarget);l.translationX=o.pageX-Je(a.rollingPageX),l.translationY=o.pageY-Je(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Zs.SCROLL_FRICTION=-.005,Zs.HOLD_DELAY=700,Zs.CLEAR_TAP_COUNT_TIME=400,we([Vp],Zs,"isTouchDevice",1);var Gp=Zs,So=class extends ne{onclick(e,t){this._register(Y(e,Me.CLICK,s=>t(new Ai(pt(e),s))))}onmousedown(e,t){this._register(Y(e,Me.MOUSE_DOWN,s=>t(new Ai(pt(e),s))))}onmouseover(e,t){this._register(Y(e,Me.MOUSE_OVER,s=>t(new Ai(pt(e),s))))}onmouseleave(e,t){this._register(Y(e,Me.MOUSE_LEAVE,s=>t(new Ai(pt(e),s))))}onkeydown(e,t){this._register(Y(e,Me.KEY_DOWN,s=>t(new Ia(s))))}onkeyup(e,t){this._register(Y(e,Me.KEY_UP,s=>t(new Ia(s))))}oninput(e,t){this._register(Y(e,Me.INPUT,t))}onblur(e,t){this._register(Y(e,Me.BLUR,t))}onfocus(e,t){this._register(Y(e,Me.FOCUS,t))}onchange(e,t){this._register(Y(e,Me.CHANGE,t))}ignoreGesture(e){return Gp.ignoreTarget(e)}},qa=11,Yp=class extends So{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=qa+"px",this.domNode.style.height=qa+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new ih),this._register(Ua(this.bgDomNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Ua(this.domNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Up),this._pointerdownScheduleRepeatTimer=this._register(new bo)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,pt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Xp=class Nn{constructor(t,s,i,n,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,n=n|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=n,this.rawScrollTop=l,s<0&&(s=0),n+s>i&&(n=i-s),n<0&&(n=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=n,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Nn(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Nn(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,n=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:n,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},Jp=class extends ne{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Xp(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Ga(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Ga.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Va=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Ar(e,t){let s=t-e;return function(i){return e+s*eg(i)}}function Zp(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Ga=class jn{constructor(t,s,i,n){this.from=t,this.to=s,this.duration=n,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let n,o;return t<s?(n=t+.75*i,o=s-.75*i):(n=t-.75*i,o=s+.75*i),Zp(Ar(t,n),Ar(o,s),.33)}return Ar(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),n=this.scrollTop(s);return new Va(i,n,!1)}return new Va(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return jn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new jn(t,s,n,i)}};function Qp(e){return Math.pow(e,3)}function eg(e){return 1-Qp(1-e)}var tg=class extends ne{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new bo)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},sg=140,rh=class extends So{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new tg(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ih),this._shouldRender=!0,this.domNode=ai(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Y(this.domNode.domNode,Me.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Yp(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=ai(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Y(this.slider.domNode,Me.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let n=Kp(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(Qc&&a>sg){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},nh=class En{constructor(t,s,i,n,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=n,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new En(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,n,o){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),h=n>0&&n>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/n))),u=(l-c)/(n-i),m=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let t=En._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},ig=class extends rh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new nh(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,n.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},rg=class extends rh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new nh(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,n.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},ng=500,Ya=50,og=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Dn=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,n=this._rear;do{let o=n===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[n].score*o,n===this._front)break;n=(this._capacity+n-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(xo){let s=pt(t.browserEvent),i=_p(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let n=null,o=new og(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(n=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,n)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(n,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(n,a),m=Math.max(o,l);u%h===0&&m%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Dn.INSTANCE=new Dn;var ag=Dn,lg=class extends So{constructor(e,t,s){super(),this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new O),this.onWillScroll=this._onWillScroll.event,this._options=hg(t),this._scrollable=s,this._register(this._scrollable.onScroll(n=>{this._onWillScroll.fire(n),this._onDidScroll(n),this._onScroll.fire(n)}));let i={onMouseWheel:n=>this._onMouseWheel(n),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new rg(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new ig(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=ai(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=ai(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=ai(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,n=>this._onMouseOver(n)),this.onmouseleave(this._listenOnDomNode,n=>this._onMouseLeave(n)),this._hideTimeout=this._register(new bo),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=os(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,_t&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Ha(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=os(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Ha(s))};this._mouseWheelToDispose.push(Y(this._listenOnDomNode,Me.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=ag.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!_t&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Ya*o,m=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,m)}if(a){let u=Ya*a,m=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,m)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),ng)}},cg=class extends lg{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function hg(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,_t&&(t.className+=" mac"),t}var Rn=class extends ne{constructor(e,t,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Jp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>yo(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new cg(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ve(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ve(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
217
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Rn=we([H(2,We),H(3,jt),H(4,$c),H(5,Ps),H(6,Ue),H(7,Et)],Rn);var Pn=class extends ne{constructor(e,t,s,i,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(ve(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Pn=we([H(1,We),H(2,jt),H(3,_i),H(4,Et)],Pn);var dg=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ct={full:0,left:0,center:0,right:0},Lt={full:0,left:0,center:0,right:0},Hs={full:0,left:0,center:0,right:0},rr=class extends ne{constructor(e,t,s,i,n,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new dg,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(ve(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Lt.full=this._canvas.width,Lt.left=e,Lt.center=t,Lt.right=e,this._refreshDrawHeightConstants(),Hs.full=1,Hs.left=1,Hs.center=1+Lt.left,Hs.right=1+Lt.left+Lt.center}_refreshDrawHeightConstants(){ct.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ct.left=t,ct.center=t,ct.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Hs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ct[e.position||"full"]/2),Lt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ct[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};rr=we([H(2,We),H(3,_i),H(4,Et),H(5,Ue),H(6,Ps),H(7,jt)],rr);var P;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
218
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(P||(P={}));var Vi;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(Vi||(Vi={}));var oh;(e=>e.ST=`${P.ESC}\\`)(oh||(oh={}));var Mn=class{constructor(e,t,s,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${P.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Mn=we([H(2,We),H(3,Ue),H(4,ds),H(5,Et)],Mn);var Le=0,Be=0,Te=0,Se=0,Xa={css:"#00000000",rgba:0},je;(e=>{function t(n,o,a,l){return l!==void 0?`#${Vt(n)}${Vt(o)}${Vt(a)}${Vt(l)}`:`#${Vt(n)}${Vt(o)}${Vt(a)}`}e.toCss=t;function s(n,o,a,l=255){return(n<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function i(n,o,a,l){return{css:e.toCss(n,o,a,l),rgba:e.toRgba(n,o,a,l)}}e.toColor=i})(je||(je={}));var xe;(e=>{function t(h,c){if(Se=(c.rgba&255)/255,Se===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,m=c.rgba>>16&255,f=c.rgba>>8&255,_=h.rgba>>24&255,p=h.rgba>>16&255,g=h.rgba>>8&255;Le=_+Math.round((u-_)*Se),Be=p+Math.round((m-p)*Se),Te=g+Math.round((f-g)*Se);let v=je.toCss(Le,Be,Te),y=je.toRgba(Le,Be,Te);return{css:v,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,u){let m=Gi.ensureContrastRatio(h.rgba,c.rgba,u);if(m)return je.toColor(m>>24&255,m>>16&255,m>>8&255)}e.ensureContrastRatio=i;function n(h){let c=(h.rgba|255)>>>0;return[Le,Be,Te]=Gi.toChannels(c),{css:je.toCss(Le,Be,Te),rgba:c}}e.opaque=n;function o(h,c){return Se=Math.round(c*255),[Le,Be,Te]=Gi.toChannels(h.rgba),{css:je.toCss(Le,Be,Te,Se),rgba:je.toRgba(Le,Be,Te,Se)}}e.opacity=o;function a(h,c){return Se=h.rgba&255,o(h,Se*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(xe||(xe={}));var ye;(e=>{let t,s;try{let n=document.createElement("canvas");n.width=1,n.height=1;let o=n.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(n){if(n.match(/#[\da-f]{3,8}/i))switch(n.length){case 4:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),je.toColor(Le,Be,Te);case 5:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Se=parseInt(n.slice(4,5).repeat(2),16),je.toColor(Le,Be,Te,Se);case 7:return{css:n,rgba:(parseInt(n.slice(1),16)<<8|255)>>>0};case 9:return{css:n,rgba:parseInt(n.slice(1),16)>>>0}}let o=n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Le=parseInt(o[1]),Be=parseInt(o[2]),Te=parseInt(o[3]),Se=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),je.toColor(Le,Be,Te,Se);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=n,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Le,Be,Te,Se]=t.getImageData(0,0,1,1).data,Se!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:je.toRgba(Le,Be,Te,Se),css:n}}e.toColor=i})(ye||(ye={}));var Fe;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,n,o){let a=i/255,l=n/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+m*.0722}e.relativeLuminance2=s})(Fe||(Fe={}));var Gi;(e=>{function t(a,l){if(Se=(l&255)/255,Se===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,m=a>>24&255,f=a>>16&255,_=a>>8&255;return Le=m+Math.round((h-m)*Se),Be=f+Math.round((c-f)*Se),Te=_+Math.round((u-_)*Se),je.toRgba(Le,Be,Te)}e.blend=t;function s(a,l,h){let c=Fe.relativeLuminance(a>>8),u=Fe.relativeLuminance(l>>8);if(St(c,u)<h){if(u<c){let _=i(a,l,h),p=St(c,Fe.relativeLuminance(_>>8));if(p<h){let g=n(a,l,h),v=St(c,Fe.relativeLuminance(g>>8));return p>v?_:g}return _}let m=n(a,l,h),f=St(c,Fe.relativeLuminance(m>>8));if(f<h){let _=i(a,l,h),p=St(c,Fe.relativeLuminance(_>>8));return f>p?m:_}return m}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,_=l>>16&255,p=l>>8&255,g=St(Fe.relativeLuminance2(f,_,p),Fe.relativeLuminance2(c,u,m));for(;g<h&&(f>0||_>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=St(Fe.relativeLuminance2(f,_,p),Fe.relativeLuminance2(c,u,m));return(f<<24|_<<16|p<<8|255)>>>0}e.reduceLuminance=i;function n(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,_=l>>16&255,p=l>>8&255,g=St(Fe.relativeLuminance2(f,_,p),Fe.relativeLuminance2(c,u,m));for(;g<h&&(f<255||_<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=St(Fe.relativeLuminance2(f,_,p),Fe.relativeLuminance2(c,u,m));return(f<<24|_<<16|p<<8|255)>>>0}e.increaseLuminance=n;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Gi||(Gi={}));function Vt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function St(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ug=class extends gi{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},nr=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new rt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),n=0,o=0,a=0,l=t.getFg(0),h=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-n>1){let u=this._getJoinedRanges(i,a,o,t,n);for(let m=0;m<u.length;m++)s.push(u[m])}n=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||At.length}if(this._bufferService.cols-n>1){let c=this._getJoinedRanges(i,a,o,t,n);for(let u=0;u<c.length;u++)s.push(c[u])}return s}_getJoinedRanges(e,t,s,i,n){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)nr._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,t,s){let i=0,n=!1,o=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=t.getWidth(l),c=t.getString(l).length||At.length;if(h!==0){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,a=e[++i],!a)break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};nr=we([H(0,We)],nr);function fg(e){return 57508<=e&&e<=57558}function mg(e){return 9472<=e&&e<=9631}function pg(e){return fg(e)||mg(e)}function gg(){return{css:{canvas:Oi(),cell:Oi()},device:{canvas:Oi(),cell:Oi(),char:{width:0,height:0,left:0,top:0}}}}function Oi(){return{width:0,height:0}}var Ln=class{constructor(e,t,s,i,n,o,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new rt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,n,o,a,l,h,c,u){let m=[],f=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,v=0,y="",x=0,k=0,N=0,w=0,D=!1,T=0,U=!1,G=0,K=0,A=[],M=c!==-1&&u!==-1;for(let E=0;E<p;E++){e.loadCell(E,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let S=!1,j=E>=K,C=E,B=this._workCell;if(f.length>0&&E===f[0][0]&&j){let ee=f.shift(),fe=this._isCellInSelection(ee[0],t);for(x=ee[0]+1;x<ee[1];x++)j&&(j=fe===this._isCellInSelection(x,t));j&&(j=!s||o<ee[0]||o>=ee[1]),j?(S=!0,B=new ug(this._workCell,e.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),C=ee[1]-1,L=B.getWidth()):K=ee[1]}let X=this._isCellInSelection(E,t),oe=s&&E===o,q=M&&E>=c&&E<=u,Q=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ee=>{Q=!0});let ie=B.getChars()||At;if(ie===" "&&(B.isUnderline()||B.isOverline())&&(ie=" "),G=L*l-h.get(ie,B.isBold(),B.isItalic()),!g)g=this._document.createElement("span");else if(v&&(X&&U||!X&&!U&&B.bg===k)&&(X&&U&&_.selectionForeground||B.fg===N)&&B.extended.ext===w&&q===D&&G===T&&!oe&&!S&&!Q&&j){B.isInvisible()?y+=At:y+=ie,v++;continue}else v&&(g.textContent=y),g=this._document.createElement("span"),v=0,y="";if(k=B.bg,N=B.fg,w=B.extended.ext,D=q,T=G,U=X,S&&o>=E&&o<=C&&(o=E),!this._coreService.isCursorHidden&&oe&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(B.isBold()&&A.push("xterm-bold"),B.isItalic()&&A.push("xterm-italic"),B.isDim()&&A.push("xterm-dim"),B.isInvisible()?y=At:y=B.getChars()||At,B.isUnderline()&&(A.push(`xterm-underline-${B.extended.underlineStyle}`),y===" "&&(y=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${gi.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let ee=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&ee<8&&(ee+=8),g.style.textDecorationColor=_.ansi[ee].css}B.isOverline()&&(A.push("xterm-overline"),y===" "&&(y=" ")),B.isStrikethrough()&&A.push("xterm-strikethrough"),q&&(g.style.textDecoration="underline");let de=B.getFgColor(),ue=B.getFgColorMode(),z=B.getBgColor(),V=B.getBgColorMode(),J=!!B.isInverse();if(J){let ee=de;de=z,z=ee;let fe=ue;ue=V,V=fe}let R,le,_e=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ee=>{ee.options.layer!=="top"&&_e||(ee.backgroundColorRGB&&(V=50331648,z=ee.backgroundColorRGB.rgba>>8&16777215,R=ee.backgroundColorRGB),ee.foregroundColorRGB&&(ue=50331648,de=ee.foregroundColorRGB.rgba>>8&16777215,le=ee.foregroundColorRGB),_e=ee.options.layer==="top")}),!_e&&X&&(R=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,z=R.rgba>>8&16777215,V=50331648,_e=!0,_.selectionForeground&&(ue=50331648,de=_.selectionForeground.rgba>>8&16777215,le=_.selectionForeground)),_e&&A.push("xterm-decoration-top");let Ee;switch(V){case 16777216:case 33554432:Ee=_.ansi[z],A.push(`xterm-bg-${z}`);break;case 50331648:Ee=je.toColor(z>>16,z>>8&255,z&255),this._addStyle(g,`background-color:#${Ja((z>>>0).toString(16),"0",6)}`);break;case 0:default:J?(Ee=_.foreground,A.push("xterm-bg-257")):Ee=_.background}switch(R||B.isDim()&&(R=xe.multiplyOpacity(Ee,.5)),ue){case 16777216:case 33554432:B.isBold()&&de<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(de+=8),this._applyMinimumContrast(g,Ee,_.ansi[de],B,R,void 0)||A.push(`xterm-fg-${de}`);break;case 50331648:let ee=je.toColor(de>>16&255,de>>8&255,de&255);this._applyMinimumContrast(g,Ee,ee,B,R,le)||this._addStyle(g,`color:#${Ja(de.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(g,Ee,_.foreground,B,R,le)||J&&A.push("xterm-fg-257")}A.length&&(g.className=A.join(" "),A.length=0),!oe&&!S&&!Q&&j?v++:g.textContent=y,G!==this.defaultSpacing&&(g.style.letterSpacing=`${G}px`),m.push(g),E=C}return g&&v&&(g.textContent=y),m}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||pg(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!n&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=xe.ensureContrastRatio(n||t,o||s,h),a.setColor((n||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};Ln=we([H(1,Hc),H(2,Ue),H(3,jt),H(4,ds),H(5,_i),H(6,Ps)],Ln);function Ja(e,t,s){for(;e.length<s;)e=t+e;return e}var _g=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},xg=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function vg(){return new xg}var Or="xterm-dom-renderer-owner-",tt="xterm-rows",$i="xterm-fg-",Za="xterm-bg-",Ws="xterm-focus",Ii="xterm-selection",bg=1,Bn=class extends ne{constructor(e,t,s,i,n,o,a,l,h,c,u,m,f,_){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=m,this._coreBrowserService=f,this._themeService=_,this._terminalClass=bg++,this._rowElements=[],this._selectionRenderModel=vg(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(tt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ii),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=gg(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Ln,document),this._element.classList.add(Or+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(ve(()=>{this._element.classList.remove(Or+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new _g(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${tt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${tt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${tt} .xterm-dim { color: ${xe.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ii} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ii} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ii} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${$i}${o} { color: ${a.css}; }${this._terminalSelector} .${$i}${o}.xterm-dim { color: ${xe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Za}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${$i}257 { color: ${xe.opaque(e.background).css}; }${this._terminalSelector} .${$i}257.xterm-dim { color: ${xe.multiplyOpacity(xe.opaque(e.background),.5).css}; }${this._terminalSelector} .${Za}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ws),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ws),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=i===o?e[0]:0,c=o===n?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let m=n===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,m))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],m=s.lines.get(c);if(!u||!m)break;u.replaceChildren(...this._rowFactory.createRow(m,c,c===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Or}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,n,o){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),u=this._optionsService.rawOptions.cursorBlink,m=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=s;_<=i;++_){let p=_+l.ydisp,g=this._rowElements[_],v=l.lines.get(p);if(!g||!v)break;g.replaceChildren(...this._rowFactory.createRow(v,p,p===h,m,f,c,u,this.dimensions.css.cell.width,this._widthCache,o?_===s?e:0:-1,o?(_===i?t:n)-1:-1))}}};Bn=we([H(7,po),H(8,xr),H(9,Ue),H(10,We),H(11,ds),H(12,jt),H(13,Ps)],Bn);var Tn=class extends ne{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new O),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Sg(this._optionsService))}catch{this._measureStrategy=this._register(new yg(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Tn=we([H(2,Ue)],Tn);var ah=class extends ne{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},yg=class extends ah{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Sg=class extends ah{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},wg=class extends ne{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Cg(this._window)),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new O),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Y(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Y(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Cg=class extends ne{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ds),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ve(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Y(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},kg=class extends ne{constructor(){super(),this.linkProviders=[],this._register(ve(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function wo(e,t,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-a]}function Ng(e,t,s,i,n,o,a,l,h){if(!o)return;let c=wo(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),n),c}var zn=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return Ng(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=wo(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};zn=we([H(0,Et),H(1,xr)],zn);var jg=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},lh={};Am(lh,{getSafariVersion:()=>Dg,isChromeOS:()=>uh,isFirefox:()=>ch,isIpad:()=>Rg,isIphone:()=>Pg,isLegacyEdge:()=>Eg,isLinux:()=>Co,isMac:()=>or,isNode:()=>vr,isSafari:()=>hh,isWindows:()=>dh});var vr=typeof process<"u"&&"title"in process,xi=vr?"node":navigator.userAgent,vi=vr?"node":navigator.platform,ch=xi.includes("Firefox"),Eg=xi.includes("Edge"),hh=/^((?!chrome|android).)*safari/i.test(xi);function Dg(){if(!hh)return 0;let e=xi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var or=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(vi),Rg=vi==="iPad",Pg=vi==="iPhone",dh=["Windows","Win16","Win32","WinCE"].includes(vi),Co=vi.indexOf("Linux")>=0,uh=/\bCrOS\b/.test(xi),fh=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),n=e.timeRemaining(),s*1.5>n){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=n}this.clear()}},Mg=class extends fh{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Lg=class extends fh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ar=!vr&&"requestIdleCallback"in window?Lg:Mg,Bg=class{constructor(){this._queue=new ar}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},An=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new Ds),this._pausedResizeTask=new Bg,this._observerDisposable=this._register(new Ds),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new O),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new O),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new O),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new jg((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Tg(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ve(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ve(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};An=we([H(2,Ue),H(3,xr),H(4,ds),H(5,_i),H(6,We),H(7,jt),H(8,Ps)],An);var Tg=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function zg(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return $g(n,o,e,t,s,i)+br(o,t,s,i)+Ig(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",di(Math.abs(n-e),hi(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),h=Og(o>t?e:n,s)+(l-1)*s.cols+1+Ag(o>t?n:e);return di(h,hi(a,i))}function Ag(e,t){return e-1}function Og(e,t){return t.cols-e}function $g(e,t,s,i,n,o){return br(t,i,n,o).length===0?"":di(ph(e,t,e,t-as(t,n),!1,n).length,hi("D",o))}function br(e,t,s,i){let n=e-as(e,s),o=t-as(t,s),a=Math.abs(n-o)-Fg(e,t,s);return di(a,hi(mh(e,t),i))}function Ig(e,t,s,i,n,o){let a;br(t,i,n,o).length>0?a=i-as(i,n):a=t;let l=i,h=Hg(e,t,s,i,n,o);return di(ph(e,a,s,l,h==="C",n).length,hi(h,o))}function Fg(e,t,s){var a;let i=0,n=e-as(e,s),o=t-as(t,s);for(let l=0;l<Math.abs(n-o);l++){let h=mh(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*l))!=null&&a.isWrapped&&i++}return i}function as(e,t){let s=0,i=t.buffer.lines.get(e),n=i==null?void 0:i.isWrapped;for(;n&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),n=i==null?void 0:i.isWrapped;return s}function Hg(e,t,s,i,n,o){let a;return br(s,i,n,o).length>0?a=i-as(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function mh(e,t){return e>t?"A":"B"}function ph(e,t,s,i,n,o){let a=e,l=t,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function hi(e,t){let s=t?"O":"[";return P.ESC+s+e}function di(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var Wg=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Qa(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var $r=50,Ug=15,Kg=50,qg=500,Vg=" ",Gg=new RegExp(Vg,"g"),On=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new rt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new O),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new O),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Wg(this._bufferService),this._activeSelectionMode=0,this._register(ve(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);i.push(l)}}else{let n=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(n=>n.replace(Gg," ")).join(dh?`\r
|
|
191
|
+
`))}},np=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},op=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},ap=0,Br=class{constructor(e){this.value=e,this.id=ap++}},lp=2,cp,O=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new ip((t==null?void 0:t.onListenerError)??Ui,((i=this._options)==null?void 0:i.leakWarningThreshold)??sp):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new tp(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,s,i,n;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,h,c,u,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let f=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(f);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new op(`${f}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Ui)(p),ne.None}if(this._disposed)return ne.None;s&&(t=t.bind(s));let n=new Br(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=rp.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Br?(this._deliveryQueue??(this._deliveryQueue=new hp),this._listeners=[this._listeners,n]):this._listeners.push(n):((c=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||c.call(h,this),this._listeners=n,(m=(u=this._options)==null?void 0:u.onDidAddFirstListener)==null||m.call(u,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Wt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,l,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||h.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*lp<=s.length){let c=0;for(let u=0;u<s.length;u++)s[u]?s[c++]=s[u]:n&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=c}}_deliver(t,s){var n;if(!t)return;let i=((n=this._options)==null?void 0:n.onListenerError)||Ui;if(!i){t.value(s);return}try{t.value(s)}catch(o){i(o)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,n,o;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof Br)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},hp=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Sn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new O,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new O,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Sn.INSTANCE=new Sn;var _o=Sn;function dp(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}_o.INSTANCE.onDidChangeZoomLevel;function up(e){return _o.INSTANCE.getZoomFactor(e)}_o.INSTANCE.onDidChangeFullscreen;var Ms=typeof navigator=="object"?navigator.userAgent:"",wn=Ms.indexOf("Firefox")>=0,fp=Ms.indexOf("AppleWebKit")>=0,xo=Ms.indexOf("Chrome")>=0,mp=!xo&&Ms.indexOf("Safari")>=0;Ms.indexOf("Electron/")>=0;Ms.indexOf("Android")>=0;var Tr=!1;if(typeof Ct.matchMedia=="function"){let e=Ct.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Ct.matchMedia("(display-mode: fullscreen)");Tr=e.matches,dp(Ct,e,({matches:s})=>{Tr&&t.matches||(Tr=s)})}var Cs="en",Cn=!1,kn=!1,Ki=!1,Zc=!1,zi,qi=Cs,za=Cs,pp,lt,Qt=globalThis,Oe,Fl;typeof Qt.vscode<"u"&&typeof Qt.vscode.process<"u"?Oe=Qt.vscode.process:typeof process<"u"&&typeof((Fl=process==null?void 0:process.versions)==null?void 0:Fl.node)=="string"&&(Oe=process);var Hl,gp=typeof((Hl=Oe==null?void 0:Oe.versions)==null?void 0:Hl.electron)=="string",_p=gp&&(Oe==null?void 0:Oe.type)==="renderer",Wl;if(typeof Oe=="object"){Cn=Oe.platform==="win32",kn=Oe.platform==="darwin",Ki=Oe.platform==="linux",Ki&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,zi=Cs,qi=Cs;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);zi=t.userLocale,za=t.osLocale,qi=t.resolvedLanguage||Cs,pp=(Wl=t.languagePack)==null?void 0:Wl.translationsConfigFile}catch{}Zc=!0}else typeof navigator=="object"&&!_p?(lt=navigator.userAgent,Cn=lt.indexOf("Windows")>=0,kn=lt.indexOf("Macintosh")>=0,(lt.indexOf("Macintosh")>=0||lt.indexOf("iPad")>=0||lt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ki=lt.indexOf("Linux")>=0,(lt==null?void 0:lt.indexOf("Mobi"))>=0,qi=globalThis._VSCODE_NLS_LANGUAGE||Cs,zi=navigator.language.toLowerCase(),za=zi):console.error("Unable to resolve platform.");var Qc=Cn,_t=kn,xp=Ki,Aa=Zc,xt=lt,Mt=qi,vp;(e=>{function t(){return Mt}e.value=t;function s(){return Mt.length===2?Mt==="en":Mt.length>=3?Mt[0]==="e"&&Mt[1]==="n"&&Mt[2]==="-":!1}e.isDefaultVariant=s;function i(){return Mt==="en"}e.isDefault=i})(vp||(vp={}));var bp=typeof Qt.postMessage=="function"&&!Qt.importScripts;(()=>{if(bp){let e=[];Qt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,n=e.length;i<n;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Qt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var yp=!!(xt&&xt.indexOf("Chrome")>=0);xt&&xt.indexOf("Firefox")>=0;!yp&&xt&&xt.indexOf("Safari")>=0;xt&&xt.indexOf("Edg/")>=0;xt&&xt.indexOf("Android")>=0;var xs=typeof navigator=="object"?navigator:{};Aa||document.queryCommandSupported&&document.queryCommandSupported("copy")||xs&&xs.clipboard&&xs.clipboard.writeText,Aa||xs&&xs.clipboard&&xs.clipboard.readText;var vo=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},zr=new vo,Oa=new vo,$a=new vo,Sp=new Array(230),eh;(e=>{function t(l){return zr.keyCodeToStr(l)}e.toString=t;function s(l){return zr.strToKeyCode(l)}e.fromString=s;function i(l){return Oa.keyCodeToStr(l)}e.toUserSettingsUS=i;function n(l){return $a.keyCodeToStr(l)}e.toUserSettingsGeneral=n;function o(l){return Oa.strToKeyCode(l)||$a.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return zr.keyCodeToStr(l)}e.toElectronAccelerator=a})(eh||(eh={}));var wp=class th{constructor(t,s,i,n,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=n,this.keyCode=o}equals(t){return t instanceof th&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${t}${s}${i}${n}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Cp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Cp=class{constructor(e){if(e.length===0)throw Ym("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function kp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return eh.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(wn)switch(t){case 59:return 85;case 60:if(xp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(_t)return 57;break}else if(fp&&(_t&&t===93||!_t&&t===92))return 57;return Sp[t]||0}var jp=_t?256:2048,Np=512,Ep=1024,Dp=_t?2048:256,Ia=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=kp(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=jp),this.altKey&&(t|=Np),this.shiftKey&&(t|=Ep),this.metaKey&&(t|=Dp),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new wp(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Fa=new WeakMap;function Rp(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var Pp=class{static getSameOriginWindowChain(e){let t=Fa.get(e);if(!t){t=[],Fa.set(e,t);let s=e,i;do i=Rp(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,n=this.getSameOriginWindowChain(e);for(let o of n){let a=o.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Ai=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=Pp.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Ha=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(xo){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,l=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*l):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?wn&&!_t?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")mp&&Qc?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*l):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?wn&&!_t?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},sh=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),Mp;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Lp?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:sh})})(Mp||(Mp={}));var Lp=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?sh:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},bo=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new _n("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _n("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Bp=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new _n("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ve(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Tp;(e=>{async function t(i){let n,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{n||(n=l)})));if(typeof n<"u")throw n;return o}e.settled=t;function s(i){return new Promise(async(n,o)=>{try{await i(n,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Tp||(Tp={}));var Wa=class st{static fromArray(t){return new st(s=>{s.emitMany(t)})}static fromPromise(t){return new st(async s=>{s.emitMany(await t)})}static fromPromises(t){return new st(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new st(async s=>{await Promise.all(t.map(async i=>{for await(let n of i)s.emitOne(n)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new O,queueMicrotask(async()=>{let i={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(i)),this.resolve()}catch(n){this.reject(n)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new st(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return st.map(this,t)}static filter(t,s){return new st(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return st.filter(this,t)}static coalesce(t){return st.filter(t,s=>!!s)}coalesce(){return st.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return st.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Wa.EMPTY=Wa.fromArray([]);var{getWindow:pt,getWindowId:zp,onDidRegisterWindow:Ap}=(function(){let e=new Map,t={window:Ct,disposables:new Wt};e.set(Ct.vscodeWindowId,t);let s=new O,i=new O,n=new O;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return ne.None;let l=new Wt,h={window:a,disposables:l.add(new Wt)};return e.set(a.vscodeWindowId,h),l.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(Y(a,Me.BEFORE_UNLOAD,()=>{n.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:Ct},getDocument(a){return pt(a).document}}})(),Op=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Y(e,t,s,i){return new Op(e,t,s,i)}var Ua=function(e,t,s,i){return Y(e,t,s,i)},yo,$p=class extends Bp{constructor(e){super(),this.defaultTarget=e&&pt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},Ka=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ui(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,n=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(Ka.sort),a.shift().execute();i.set(o,!1)};yo=(o,a,l=0)=>{let h=zp(o),c=new Ka(a,l),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),c}})();function Ip(e){let t=e.getBoundingClientRect(),s=pt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Me={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Fp=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=qe(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=qe(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=qe(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=qe(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=qe(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=qe(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=qe(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=qe(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=qe(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=qe(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=qe(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=qe(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=qe(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=qe(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function qe(e){return typeof e=="number"?`${e}px`:e}function ai(e){return new Fp(e)}var ih=class{constructor(){this._hooks=new Wt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(ve(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=pt(e)}this._hooks.add(Y(o,Me.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Y(o,Me.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Hp(e,t,s){let i=null,n=null;if(typeof s.value=="function"?(i="value",n=s.value,n.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",n=s.get),!n)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,a)}),this[o]}}var dt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(dt||(dt={}));var Zs=class Ie extends ne{constructor(){super(),this.dispatched=!1,this.targets=new Ta,this.ignoreTargets=new Ta,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(Ap,({window:t,disposables:s})=>{s.add(Y(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(Y(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(Y(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Ct,disposables:this._store}))}static addTarget(t){if(!Ie.isTouchDevice())return ne.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.targets.push(t);return ve(s)}static ignoreTarget(t){if(!Ie.isTouchDevice())return ne.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.ignoreTargets.push(t);return ve(s)}static isTouchDevice(){return"ontouchstart"in Ct||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,n=t.targetTouches.length;i<n;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(dt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Ie.HOLD_DELAY&&Math.abs(h.initialPageX-Je(h.rollingPageX))<30&&Math.abs(h.initialPageY-Je(h.rollingPageY))<30){let u=this.newGestureEvent(dt.Tap,h.initialTarget);u.pageX=Je(h.rollingPageX),u.pageY=Je(h.rollingPageY),this.dispatchEvent(u)}else if(c>=Ie.HOLD_DELAY&&Math.abs(h.initialPageX-Je(h.rollingPageX))<30&&Math.abs(h.initialPageY-Je(h.rollingPageY))<30){let u=this.newGestureEvent(dt.Contextmenu,h.initialTarget);u.pageX=Je(h.rollingPageX),u.pageY=Je(h.rollingPageY),this.dispatchEvent(u)}else if(n===1){let u=Je(h.rollingPageX),m=Je(h.rollingPageY),f=Je(h.rollingTimestamps)-h.rollingTimestamps[0],_=u-h.rollingPageX[0],p=m-h.rollingPageY[0],g=[...this.targets].filter(v=>h.initialTarget instanceof Node&&v.contains(h.initialTarget));this.inertia(t,g,i,Math.abs(_)/f,_>0?1:-1,u,Math.abs(p)/f,p>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(dt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===dt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ie.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===dt.Change||t.type===dt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let n=0,o=t.initialTarget;for(;o&&o!==i;)n++,o=o.parentElement;s.push([n,i])}s.sort((i,n)=>i[0]-n[0]);for(let[i,n]of s)n.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,n,o,a,l,h,c){this.handle=yo(t,()=>{let u=Date.now(),m=u-i,f=0,_=0,p=!0;n+=Ie.SCROLL_FRICTION*m,l+=Ie.SCROLL_FRICTION*m,n>0&&(p=!1,f=o*n*m),l>0&&(p=!1,_=h*l*m);let g=this.newGestureEvent(dt.Change);g.translationX=f,g.translationY=_,s.forEach(v=>v.dispatchEvent(g)),p||this.inertia(t,s,u,n,o,a+f,l,h,c+_)})}onTouchMove(t){let s=Date.now();for(let i=0,n=t.changedTouches.length;i<n;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(dt.Change,a.initialTarget);l.translationX=o.pageX-Je(a.rollingPageX),l.translationY=o.pageY-Je(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Zs.SCROLL_FRICTION=-.005,Zs.HOLD_DELAY=700,Zs.CLEAR_TAP_COUNT_TIME=400,we([Hp],Zs,"isTouchDevice",1);var Wp=Zs,So=class extends ne{onclick(e,t){this._register(Y(e,Me.CLICK,s=>t(new Ai(pt(e),s))))}onmousedown(e,t){this._register(Y(e,Me.MOUSE_DOWN,s=>t(new Ai(pt(e),s))))}onmouseover(e,t){this._register(Y(e,Me.MOUSE_OVER,s=>t(new Ai(pt(e),s))))}onmouseleave(e,t){this._register(Y(e,Me.MOUSE_LEAVE,s=>t(new Ai(pt(e),s))))}onkeydown(e,t){this._register(Y(e,Me.KEY_DOWN,s=>t(new Ia(s))))}onkeyup(e,t){this._register(Y(e,Me.KEY_UP,s=>t(new Ia(s))))}oninput(e,t){this._register(Y(e,Me.INPUT,t))}onblur(e,t){this._register(Y(e,Me.BLUR,t))}onfocus(e,t){this._register(Y(e,Me.FOCUS,t))}onchange(e,t){this._register(Y(e,Me.CHANGE,t))}ignoreGesture(e){return Wp.ignoreTarget(e)}},qa=11,Up=class extends So{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=qa+"px",this.domNode.style.height=qa+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new ih),this._register(Ua(this.bgDomNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Ua(this.domNode,Me.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new $p),this._pointerdownScheduleRepeatTimer=this._register(new bo)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,pt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Kp=class jn{constructor(t,s,i,n,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,n=n|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=n,this.rawScrollTop=l,s<0&&(s=0),n+s>i&&(n=i-s),n<0&&(n=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=n,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new jn(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new jn(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,n=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:n,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},qp=class extends ne{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Kp(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Ga(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Ga.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Va=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Ar(e,t){let s=t-e;return function(i){return e+s*Yp(i)}}function Vp(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Ga=class Nn{constructor(t,s,i,n){this.from=t,this.to=s,this.duration=n,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let n,o;return t<s?(n=t+.75*i,o=s-.75*i):(n=t-.75*i,o=s+.75*i),Vp(Ar(t,n),Ar(o,s),.33)}return Ar(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),n=this.scrollTop(s);return new Va(i,n,!1)}return new Va(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Nn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new Nn(t,s,n,i)}};function Gp(e){return Math.pow(e,3)}function Yp(e){return 1-Gp(1-e)}var Xp=class extends ne{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new bo)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Jp=140,rh=class extends So{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Xp(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new ih),this._shouldRender=!0,this.domNode=ai(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Y(this.domNode.domNode,Me.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Up(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=ai(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Y(this.slider.domNode,Me.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let n=Ip(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(Qc&&a>Jp){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},nh=class En{constructor(t,s,i,n,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=n,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new En(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,n,o){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),h=n>0&&n>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/n))),u=(l-c)/(n-i),m=o*u;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:u,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let t=En._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},Zp=class extends rh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new nh(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,n.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Qp=class extends rh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new nh(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,n.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},eg=500,Ya=50,tg=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Dn=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,n=this._rear;do{let o=n===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[n].score*o,n===this._front)break;n=(this._capacity+n-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(xo){let s=pt(t.browserEvent),i=up(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let n=null,o=new tg(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(n=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,n)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(n,a),1),c=Math.max(Math.min(o,l),1),u=Math.max(n,a),m=Math.max(o,l);u%h===0&&m%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Dn.INSTANCE=new Dn;var sg=Dn,ig=class extends So{constructor(e,t,s){super(),this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new O),this.onWillScroll=this._onWillScroll.event,this._options=ng(t),this._scrollable=s,this._register(this._scrollable.onScroll(n=>{this._onWillScroll.fire(n),this._onDidScroll(n),this._onScroll.fire(n)}));let i={onMouseWheel:n=>this._onMouseWheel(n),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Qp(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new Zp(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=ai(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=ai(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=ai(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,n=>this._onMouseOver(n)),this.onmouseleave(this._listenOnDomNode,n=>this._onMouseLeave(n)),this._hideTimeout=this._register(new bo),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=os(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,_t&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Ha(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=os(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Ha(s))};this._mouseWheelToDispose.push(Y(this._listenOnDomNode,Me.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=sg.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!_t&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let u=Ya*o,m=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(c,m)}if(a){let u=Ya*a,m=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(c,m)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),eg)}},rg=class extends ig{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ng(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,_t&&(t.className+=" mac"),t}var Rn=class extends ne{constructor(e,t,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new qp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>yo(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new rg(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ve(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ve(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
192
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Rn=we([H(2,We),H(3,Nt),H(4,$c),H(5,Ps),H(6,Ue),H(7,Et)],Rn);var Pn=class extends ne{constructor(e,t,s,i,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(ve(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Pn=we([H(1,We),H(2,Nt),H(3,_i),H(4,Et)],Pn);var og=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ct={full:0,left:0,center:0,right:0},Lt={full:0,left:0,center:0,right:0},Hs={full:0,left:0,center:0,right:0},rr=class extends ne{constructor(e,t,s,i,n,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new og,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(ve(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Lt.full=this._canvas.width,Lt.left=e,Lt.center=t,Lt.right=e,this._refreshDrawHeightConstants(),Hs.full=1,Hs.left=1,Hs.center=1+Lt.left,Hs.right=1+Lt.left+Lt.center}_refreshDrawHeightConstants(){ct.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ct.left=t,ct.center=t,ct.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ct.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Hs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ct[e.position||"full"]/2),Lt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ct[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};rr=we([H(2,We),H(3,_i),H(4,Et),H(5,Ue),H(6,Ps),H(7,Nt)],rr);var P;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
193
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(P||(P={}));var Vi;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(Vi||(Vi={}));var oh;(e=>e.ST=`${P.ESC}\\`)(oh||(oh={}));var Mn=class{constructor(e,t,s,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${P.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Mn=we([H(2,We),H(3,Ue),H(4,ds),H(5,Et)],Mn);var Le=0,Be=0,Te=0,Se=0,Xa={css:"#00000000",rgba:0},Ne;(e=>{function t(n,o,a,l){return l!==void 0?`#${Vt(n)}${Vt(o)}${Vt(a)}${Vt(l)}`:`#${Vt(n)}${Vt(o)}${Vt(a)}`}e.toCss=t;function s(n,o,a,l=255){return(n<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function i(n,o,a,l){return{css:e.toCss(n,o,a,l),rgba:e.toRgba(n,o,a,l)}}e.toColor=i})(Ne||(Ne={}));var xe;(e=>{function t(h,c){if(Se=(c.rgba&255)/255,Se===1)return{css:c.css,rgba:c.rgba};let u=c.rgba>>24&255,m=c.rgba>>16&255,f=c.rgba>>8&255,_=h.rgba>>24&255,p=h.rgba>>16&255,g=h.rgba>>8&255;Le=_+Math.round((u-_)*Se),Be=p+Math.round((m-p)*Se),Te=g+Math.round((f-g)*Se);let v=Ne.toCss(Le,Be,Te),y=Ne.toRgba(Le,Be,Te);return{css:v,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,u){let m=Gi.ensureContrastRatio(h.rgba,c.rgba,u);if(m)return Ne.toColor(m>>24&255,m>>16&255,m>>8&255)}e.ensureContrastRatio=i;function n(h){let c=(h.rgba|255)>>>0;return[Le,Be,Te]=Gi.toChannels(c),{css:Ne.toCss(Le,Be,Te),rgba:c}}e.opaque=n;function o(h,c){return Se=Math.round(c*255),[Le,Be,Te]=Gi.toChannels(h.rgba),{css:Ne.toCss(Le,Be,Te,Se),rgba:Ne.toRgba(Le,Be,Te,Se)}}e.opacity=o;function a(h,c){return Se=h.rgba&255,o(h,Se*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(xe||(xe={}));var ye;(e=>{let t,s;try{let n=document.createElement("canvas");n.width=1,n.height=1;let o=n.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(n){if(n.match(/#[\da-f]{3,8}/i))switch(n.length){case 4:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Ne.toColor(Le,Be,Te);case 5:return Le=parseInt(n.slice(1,2).repeat(2),16),Be=parseInt(n.slice(2,3).repeat(2),16),Te=parseInt(n.slice(3,4).repeat(2),16),Se=parseInt(n.slice(4,5).repeat(2),16),Ne.toColor(Le,Be,Te,Se);case 7:return{css:n,rgba:(parseInt(n.slice(1),16)<<8|255)>>>0};case 9:return{css:n,rgba:parseInt(n.slice(1),16)>>>0}}let o=n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Le=parseInt(o[1]),Be=parseInt(o[2]),Te=parseInt(o[3]),Se=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Ne.toColor(Le,Be,Te,Se);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=n,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Le,Be,Te,Se]=t.getImageData(0,0,1,1).data,Se!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ne.toRgba(Le,Be,Te,Se),css:n}}e.toColor=i})(ye||(ye={}));var Fe;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,n,o){let a=i/255,l=n/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),u=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+u*.7152+m*.0722}e.relativeLuminance2=s})(Fe||(Fe={}));var Gi;(e=>{function t(a,l){if(Se=(l&255)/255,Se===1)return l;let h=l>>24&255,c=l>>16&255,u=l>>8&255,m=a>>24&255,f=a>>16&255,_=a>>8&255;return Le=m+Math.round((h-m)*Se),Be=f+Math.round((c-f)*Se),Te=_+Math.round((u-_)*Se),Ne.toRgba(Le,Be,Te)}e.blend=t;function s(a,l,h){let c=Fe.relativeLuminance(a>>8),u=Fe.relativeLuminance(l>>8);if(St(c,u)<h){if(u<c){let _=i(a,l,h),p=St(c,Fe.relativeLuminance(_>>8));if(p<h){let g=n(a,l,h),v=St(c,Fe.relativeLuminance(g>>8));return p>v?_:g}return _}let m=n(a,l,h),f=St(c,Fe.relativeLuminance(m>>8));if(f<h){let _=i(a,l,h),p=St(c,Fe.relativeLuminance(_>>8));return f>p?m:_}return m}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,_=l>>16&255,p=l>>8&255,g=St(Fe.relativeLuminance2(f,_,p),Fe.relativeLuminance2(c,u,m));for(;g<h&&(f>0||_>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),p-=Math.max(0,Math.ceil(p*.1)),g=St(Fe.relativeLuminance2(f,_,p),Fe.relativeLuminance2(c,u,m));return(f<<24|_<<16|p<<8|255)>>>0}e.reduceLuminance=i;function n(a,l,h){let c=a>>24&255,u=a>>16&255,m=a>>8&255,f=l>>24&255,_=l>>16&255,p=l>>8&255,g=St(Fe.relativeLuminance2(f,_,p),Fe.relativeLuminance2(c,u,m));for(;g<h&&(f<255||_<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),g=St(Fe.relativeLuminance2(f,_,p),Fe.relativeLuminance2(c,u,m));return(f<<24|_<<16|p<<8|255)>>>0}e.increaseLuminance=n;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Gi||(Gi={}));function Vt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function St(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ag=class extends gi{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},nr=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new rt}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),n=0,o=0,a=0,l=t.getFg(0),h=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-n>1){let u=this._getJoinedRanges(i,a,o,t,n);for(let m=0;m<u.length;m++)s.push(u[m])}n=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||At.length}if(this._bufferService.cols-n>1){let c=this._getJoinedRanges(i,a,o,t,n);for(let u=0;u<c.length;u++)s.push(c[u])}return s}_getJoinedRanges(e,t,s,i,n){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)nr._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,t,s){let i=0,n=!1,o=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=t.getWidth(l),c=t.getString(l).length||At.length;if(h!==0){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,a=e[++i],!a)break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};nr=we([H(0,We)],nr);function lg(e){return 57508<=e&&e<=57558}function cg(e){return 9472<=e&&e<=9631}function hg(e){return lg(e)||cg(e)}function dg(){return{css:{canvas:Oi(),cell:Oi()},device:{canvas:Oi(),cell:Oi(),char:{width:0,height:0,left:0,top:0}}}}function Oi(){return{width:0,height:0}}var Ln=class{constructor(e,t,s,i,n,o,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new rt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,n,o,a,l,h,c,u){let m=[],f=this._characterJoinerService.getJoinedCharacters(t),_=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,v=0,y="",x=0,k=0,j=0,w=0,D=!1,T=0,U=!1,G=0,K=0,A=[],M=c!==-1&&u!==-1;for(let E=0;E<p;E++){e.loadCell(E,this._workCell);let L=this._workCell.getWidth();if(L===0)continue;let S=!1,N=E>=K,C=E,B=this._workCell;if(f.length>0&&E===f[0][0]&&N){let ee=f.shift(),fe=this._isCellInSelection(ee[0],t);for(x=ee[0]+1;x<ee[1];x++)N&&(N=fe===this._isCellInSelection(x,t));N&&(N=!s||o<ee[0]||o>=ee[1]),N?(S=!0,B=new ag(this._workCell,e.translateToString(!0,ee[0],ee[1]),ee[1]-ee[0]),C=ee[1]-1,L=B.getWidth()):K=ee[1]}let X=this._isCellInSelection(E,t),oe=s&&E===o,q=M&&E>=c&&E<=u,Q=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ee=>{Q=!0});let ie=B.getChars()||At;if(ie===" "&&(B.isUnderline()||B.isOverline())&&(ie=" "),G=L*l-h.get(ie,B.isBold(),B.isItalic()),!g)g=this._document.createElement("span");else if(v&&(X&&U||!X&&!U&&B.bg===k)&&(X&&U&&_.selectionForeground||B.fg===j)&&B.extended.ext===w&&q===D&&G===T&&!oe&&!S&&!Q&&N){B.isInvisible()?y+=At:y+=ie,v++;continue}else v&&(g.textContent=y),g=this._document.createElement("span"),v=0,y="";if(k=B.bg,j=B.fg,w=B.extended.ext,D=q,T=G,U=X,S&&o>=E&&o<=C&&(o=E),!this._coreService.isCursorHidden&&oe&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(B.isBold()&&A.push("xterm-bold"),B.isItalic()&&A.push("xterm-italic"),B.isDim()&&A.push("xterm-dim"),B.isInvisible()?y=At:y=B.getChars()||At,B.isUnderline()&&(A.push(`xterm-underline-${B.extended.underlineStyle}`),y===" "&&(y=" "),!B.isUnderlineColorDefault()))if(B.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${gi.toColorRGB(B.getUnderlineColor()).join(",")})`;else{let ee=B.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&B.isBold()&&ee<8&&(ee+=8),g.style.textDecorationColor=_.ansi[ee].css}B.isOverline()&&(A.push("xterm-overline"),y===" "&&(y=" ")),B.isStrikethrough()&&A.push("xterm-strikethrough"),q&&(g.style.textDecoration="underline");let de=B.getFgColor(),ue=B.getFgColorMode(),z=B.getBgColor(),V=B.getBgColorMode(),J=!!B.isInverse();if(J){let ee=de;de=z,z=ee;let fe=ue;ue=V,V=fe}let R,ae,_e=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,ee=>{ee.options.layer!=="top"&&_e||(ee.backgroundColorRGB&&(V=50331648,z=ee.backgroundColorRGB.rgba>>8&16777215,R=ee.backgroundColorRGB),ee.foregroundColorRGB&&(ue=50331648,de=ee.foregroundColorRGB.rgba>>8&16777215,ae=ee.foregroundColorRGB),_e=ee.options.layer==="top")}),!_e&&X&&(R=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque,z=R.rgba>>8&16777215,V=50331648,_e=!0,_.selectionForeground&&(ue=50331648,de=_.selectionForeground.rgba>>8&16777215,ae=_.selectionForeground)),_e&&A.push("xterm-decoration-top");let Ee;switch(V){case 16777216:case 33554432:Ee=_.ansi[z],A.push(`xterm-bg-${z}`);break;case 50331648:Ee=Ne.toColor(z>>16,z>>8&255,z&255),this._addStyle(g,`background-color:#${Ja((z>>>0).toString(16),"0",6)}`);break;case 0:default:J?(Ee=_.foreground,A.push("xterm-bg-257")):Ee=_.background}switch(R||B.isDim()&&(R=xe.multiplyOpacity(Ee,.5)),ue){case 16777216:case 33554432:B.isBold()&&de<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(de+=8),this._applyMinimumContrast(g,Ee,_.ansi[de],B,R,void 0)||A.push(`xterm-fg-${de}`);break;case 50331648:let ee=Ne.toColor(de>>16&255,de>>8&255,de&255);this._applyMinimumContrast(g,Ee,ee,B,R,ae)||this._addStyle(g,`color:#${Ja(de.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(g,Ee,_.foreground,B,R,ae)||J&&A.push("xterm-fg-257")}A.length&&(g.className=A.join(" "),A.length=0),!oe&&!S&&!Q&&N?v++:g.textContent=y,G!==this.defaultSpacing&&(g.style.letterSpacing=`${G}px`),m.push(g),E=C}return g&&v&&(g.textContent=y),m}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||hg(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!n&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=xe.ensureContrastRatio(n||t,o||s,h),a.setColor((n||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};Ln=we([H(1,Hc),H(2,Ue),H(3,Nt),H(4,ds),H(5,_i),H(6,Ps)],Ln);function Ja(e,t,s){for(;e.length<s;)e=t+e;return e}var ug=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},fg=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function mg(){return new fg}var Or="xterm-dom-renderer-owner-",tt="xterm-rows",$i="xterm-fg-",Za="xterm-bg-",Ws="xterm-focus",Ii="xterm-selection",pg=1,Bn=class extends ne{constructor(e,t,s,i,n,o,a,l,h,c,u,m,f,_){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=u,this._coreService=m,this._coreBrowserService=f,this._themeService=_,this._terminalClass=pg++,this._rowElements=[],this._selectionRenderModel=mg(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(tt),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Ii),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=dg(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Ln,document),this._element.classList.add(Or+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(ve(()=>{this._element.classList.remove(Or+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new ug(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${tt} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${tt} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${tt} .xterm-dim { color: ${xe.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${tt}.${Ws} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${tt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ii} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ii} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ii} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${$i}${o} { color: ${a.css}; }${this._terminalSelector} .${$i}${o}.xterm-dim { color: ${xe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${Za}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${$i}257 { color: ${xe.opaque(e.background).css}; }${this._terminalSelector} .${$i}257.xterm-dim { color: ${xe.multiplyOpacity(xe.opaque(e.background),.5).css}; }${this._terminalSelector} .${Za}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Ws),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ws),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=i===o?e[0]:0,c=o===n?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let u=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,u)),o!==a){let m=n===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,m))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,u=this._rowElements[h],m=s.lines.get(c);if(!u||!m)break;u.replaceChildren(...this._rowFactory.createRow(m,c,c===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Or}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,n,o){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),u=this._optionsService.rawOptions.cursorBlink,m=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let _=s;_<=i;++_){let p=_+l.ydisp,g=this._rowElements[_],v=l.lines.get(p);if(!g||!v)break;g.replaceChildren(...this._rowFactory.createRow(v,p,p===h,m,f,c,u,this.dimensions.css.cell.width,this._widthCache,o?_===s?e:0:-1,o?(_===i?t:n)-1:-1))}}};Bn=we([H(7,po),H(8,xr),H(9,Ue),H(10,We),H(11,ds),H(12,Nt),H(13,Ps)],Bn);var Tn=class extends ne{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new O),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new _g(this._optionsService))}catch{this._measureStrategy=this._register(new gg(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Tn=we([H(2,Ue)],Tn);var ah=class extends ne{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},gg=class extends ah{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},_g=class extends ah{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},xg=class extends ne{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new vg(this._window)),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new O),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Y(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Y(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},vg=class extends ne{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Ds),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ve(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Y(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},bg=class extends ne{constructor(){super(),this.linkProviders=[],this._register(ve(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function wo(e,t,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-a]}function yg(e,t,s,i,n,o,a,l,h){if(!o)return;let c=wo(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),n),c}var zn=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return yg(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=wo(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};zn=we([H(0,Et),H(1,xr)],zn);var Sg=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},lh={};Mm(lh,{getSafariVersion:()=>Cg,isChromeOS:()=>uh,isFirefox:()=>ch,isIpad:()=>kg,isIphone:()=>jg,isLegacyEdge:()=>wg,isLinux:()=>Co,isMac:()=>or,isNode:()=>vr,isSafari:()=>hh,isWindows:()=>dh});var vr=typeof process<"u"&&"title"in process,xi=vr?"node":navigator.userAgent,vi=vr?"node":navigator.platform,ch=xi.includes("Firefox"),wg=xi.includes("Edge"),hh=/^((?!chrome|android).)*safari/i.test(xi);function Cg(){if(!hh)return 0;let e=xi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var or=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(vi),kg=vi==="iPad",jg=vi==="iPhone",dh=["Windows","Win16","Win32","WinCE"].includes(vi),Co=vi.indexOf("Linux")>=0,uh=/\bCrOS\b/.test(xi),fh=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),n=e.timeRemaining(),s*1.5>n){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=n}this.clear()}},Ng=class extends fh{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Eg=class extends fh{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ar=!vr&&"requestIdleCallback"in window?Eg:Ng,Dg=class{constructor(){this._queue=new ar}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},An=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new Ds),this._pausedResizeTask=new Dg,this._observerDisposable=this._register(new Ds),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new O),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new O),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new O),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Sg((c,u)=>this._renderRows(c,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Rg(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ve(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ve(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};An=we([H(2,Ue),H(3,xr),H(4,ds),H(5,_i),H(6,We),H(7,Nt),H(8,Ps)],An);var Rg=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Pg(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Bg(n,o,e,t,s,i)+br(o,t,s,i)+Tg(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",di(Math.abs(n-e),hi(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),h=Lg(o>t?e:n,s)+(l-1)*s.cols+1+Mg(o>t?n:e);return di(h,hi(a,i))}function Mg(e,t){return e-1}function Lg(e,t){return t.cols-e}function Bg(e,t,s,i,n,o){return br(t,i,n,o).length===0?"":di(ph(e,t,e,t-as(t,n),!1,n).length,hi("D",o))}function br(e,t,s,i){let n=e-as(e,s),o=t-as(t,s),a=Math.abs(n-o)-zg(e,t,s);return di(a,hi(mh(e,t),i))}function Tg(e,t,s,i,n,o){let a;br(t,i,n,o).length>0?a=i-as(i,n):a=t;let l=i,h=Ag(e,t,s,i,n,o);return di(ph(e,a,s,l,h==="C",n).length,hi(h,o))}function zg(e,t,s){var a;let i=0,n=e-as(e,s),o=t-as(t,s);for(let l=0;l<Math.abs(n-o);l++){let h=mh(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*l))!=null&&a.isWrapped&&i++}return i}function as(e,t){let s=0,i=t.buffer.lines.get(e),n=i==null?void 0:i.isWrapped;for(;n&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),n=i==null?void 0:i.isWrapped;return s}function Ag(e,t,s,i,n,o){let a;return br(s,i,n,o).length>0?a=i-as(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function mh(e,t){return e>t?"A":"B"}function ph(e,t,s,i,n,o){let a=e,l=t,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function hi(e,t){let s=t?"O":"[";return P.ESC+s+e}function di(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var Og=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Qa(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var $r=50,$g=15,Ig=50,Fg=500,Hg=" ",Wg=new RegExp(Hg,"g"),On=class extends ne{constructor(e,t,s,i,n,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new rt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new O),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new O),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new Og(this._bufferService),this._activeSelectionMode=0,this._register(ve(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);i.push(l)}}else{let n=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(n=>n.replace(Wg," ")).join(dh?`\r
|
|
219
194
|
`:`
|
|
220
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Co&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Qa(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=wo(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-$r),$r),t/=$r,t/Math.abs(t)+Math.round(t*(Ug-1)))}shouldForceSelection(e){return or?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Kg)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(or&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<qg&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=zg(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==i&&(s+=n-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,m=0,f=0,_=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let v=e[0],y=e[0];o.getWidth(v)===0&&(u++,v--),o.getWidth(y)===2&&(m++,y++);let x=o.getString(y).length;for(x>1&&(_+=x-1,h+=x-1);v>0&&l>0&&!this._isCharWordSeparator(o.loadCell(v-1,this._workCell));){o.loadCell(v-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,v--):k>1&&(f+=k-1,l-=k-1),l--,v--}for(;y<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(y+1,this._workCell));){o.loadCell(y+1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===2?(m++,y++):k>1&&(_+=k-1,h+=k-1),h++,y++}}h++;let p=l+c-u+f,g=Math.min(this._bufferService.cols,h-l+u+m-f-_);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let v=n.lines.get(e[1]-1);if(v&&o.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let x=this._bufferService.cols-y.start;p-=x,g+=x}}}if(i&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let v=n.lines.get(e[1]+1);if(v!=null&&v.isWrapped&&v.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(g+=y.length)}}return{start:p,length:g}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Qa(s,this._bufferService.cols)}};On=we([H(3,We),H(4,ds),H(5,go),H(6,Ue),H(7,Et),H(8,jt)],On);var el=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},tl=class{constructor(){this._color=new el,this._css=new el}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},De=Object.freeze((()=>{let e=[ye.toColor("#2e3436"),ye.toColor("#cc0000"),ye.toColor("#4e9a06"),ye.toColor("#c4a000"),ye.toColor("#3465a4"),ye.toColor("#75507b"),ye.toColor("#06989a"),ye.toColor("#d3d7cf"),ye.toColor("#555753"),ye.toColor("#ef2929"),ye.toColor("#8ae234"),ye.toColor("#fce94f"),ye.toColor("#729fcf"),ye.toColor("#ad7fa8"),ye.toColor("#34e2e2"),ye.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],n=t[s/6%6|0],o=t[s%6];e.push({css:je.toCss(i,n,o),rgba:je.toRgba(i,n,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:je.toCss(i,i,i),rgba:je.toRgba(i,i,i)})}return e})()),Yt=ye.toColor("#ffffff"),Qs=ye.toColor("#000000"),sl=ye.toColor("#ffffff"),il=Qs,Us={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Yg=Yt,$n=class extends ne{constructor(e){super(),this._optionsService=e,this._contrastCache=new tl,this._halfContrastCache=new tl,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Yt,background:Qs,cursor:sl,cursorAccent:il,selectionForeground:void 0,selectionBackgroundTransparent:Us,selectionBackgroundOpaque:xe.blend(Qs,Us),selectionInactiveBackgroundTransparent:Us,selectionInactiveBackgroundOpaque:xe.blend(Qs,Us),scrollbarSliderBackground:xe.opacity(Yt,.2),scrollbarSliderHoverBackground:xe.opacity(Yt,.4),scrollbarSliderActiveBackground:xe.opacity(Yt,.5),overviewRulerBorder:Yt,ansi:De.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=me(e.foreground,Yt),t.background=me(e.background,Qs),t.cursor=xe.blend(t.background,me(e.cursor,sl)),t.cursorAccent=xe.blend(t.background,me(e.cursorAccent,il)),t.selectionBackgroundTransparent=me(e.selectionBackground,Us),t.selectionBackgroundOpaque=xe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=me(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=xe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?me(e.selectionForeground,Xa):void 0,t.selectionForeground===Xa&&(t.selectionForeground=void 0),xe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=xe.opacity(t.selectionBackgroundTransparent,.3)),xe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=xe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=me(e.scrollbarSliderBackground,xe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=me(e.scrollbarSliderHoverBackground,xe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=me(e.scrollbarSliderActiveBackground,xe.opacity(t.foreground,.5)),t.overviewRulerBorder=me(e.overviewRulerBorder,Yg),t.ansi=De.slice(),t.ansi[0]=me(e.black,De[0]),t.ansi[1]=me(e.red,De[1]),t.ansi[2]=me(e.green,De[2]),t.ansi[3]=me(e.yellow,De[3]),t.ansi[4]=me(e.blue,De[4]),t.ansi[5]=me(e.magenta,De[5]),t.ansi[6]=me(e.cyan,De[6]),t.ansi[7]=me(e.white,De[7]),t.ansi[8]=me(e.brightBlack,De[8]),t.ansi[9]=me(e.brightRed,De[9]),t.ansi[10]=me(e.brightGreen,De[10]),t.ansi[11]=me(e.brightYellow,De[11]),t.ansi[12]=me(e.brightBlue,De[12]),t.ansi[13]=me(e.brightMagenta,De[13]),t.ansi[14]=me(e.brightCyan,De[14]),t.ansi[15]=me(e.brightWhite,De[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=me(e.extendedAnsi[i],De[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};$n=we([H(0,Ue)],$n);function me(e,t){if(e!==void 0)try{return ye.toColor(e)}catch{}return t}var Xg=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Jg=class{constructor(){this._services=new Xg,this._services.set(po,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=Um(e).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let n=s.length>0?s[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Zg={trace:0,debug:1,info:2,warn:3,error:4,off:5},Qg="xterm.js: ",In=class extends ne{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Zg[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Qg)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};In=we([H(0,Ue)],In);var rl=class extends ne{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},re=3,Ne=Object.freeze(new gi),Fi=0,Ir=2,ei=class gh{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*re);let n=s||rt.fromCharData([0,Tc,1,0]);for(let o=0;o<t;++o)this.setCell(o,n);this.length=t}get(t){let s=this._data[t*re+0],i=s&2097151;return[this._data[t*re+1],s&2097152?this._combined[t]:i?Tt(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*re+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*re+0]=t|2097152|s[2]<<22):this._data[t*re+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*re+0]>>22}hasWidth(t){return this._data[t*re+0]&12582912}getFg(t){return this._data[t*re+1]}getBg(t){return this._data[t*re+2]}hasContent(t){return this._data[t*re+0]&4194303}getCodePoint(t){let s=this._data[t*re+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*re+0]&2097152}getString(t){let s=this._data[t*re+0];return s&2097152?this._combined[t]:s&2097151?Tt(s&2097151):""}isProtected(t){return this._data[t*re+2]&536870912}loadCell(t,s){return Fi=t*re,s.content=this._data[Fi+0],s.fg=this._data[Fi+1],s.bg=this._data[Fi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*re+0]=s.content,this._data[t*re+1]=s.fg,this._data[t*re+2]=s.bg}setCellFromCodepoint(t,s,i,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*re+0]=s|i<<22,this._data[t*re+1]=n.fg,this._data[t*re+2]=n.bg}addCodepointToCell(t,s,i){let n=this._data[t*re+0];n&2097152?this._combined[t]+=Tt(s):n&2097151?(this._combined[t]=Tt(n&2097151)+Tt(s),n&=-2097152,n|=2097152):n=s|1<<22,i&&(n&=-12582913,n|=i<<22),this._data[t*re+0]=n}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let n=new rt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,n));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let n=new rt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,n));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,n=!1){if(n){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*Ir<this._data.buffer.byteLength;let i=t*re;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let n=new Uint32Array(i);n.set(this._data),this._data=n}for(let n=this.length;n<t;++n)this.setCell(n,s)}else{this._data=this._data.subarray(0,i);let n=Object.keys(this._combined);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*Ir<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ir<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new gh(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303)return t+(this._data[t*re+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303||this._data[t*re+2]&50331648)return t+(this._data[t*re+0]>>22);return 0}copyCellsFrom(t,s,i,n,o){let a=t._data;if(o)for(let h=n-1;h>=0;h--){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<n;h++){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=t._combined[c])}}translateToString(t,s,i,n){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),n&&(n.length=0);let o="";for(;s<i;){let a=this._data[s*re+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Tt(l):At;if(o+=h,n)for(let c=0;c<h.length;++c)n.push(s);s+=a>>22||1}return n&&n.push(s),o}};function e_(e,t,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let u=[e.get(l)];for(;h<e.length&&c.isWrapped;)u.push(c),c=e.get(++h);if(!o&&i>=l&&i<h){l+=u.length-1;continue}let m=0,f=ui(u,m,t),_=1,p=0;for(;_<u.length;){let v=ui(u,_,t),y=v-p,x=s-f,k=Math.min(y,x);u[m].copyCellsFrom(u[_],p,f,k,!1),f+=k,f===s&&(m++,f=0),p+=k,p===v&&(_++,p=0),f===0&&m!==0&&u[m-1].getWidth(s-1)===2&&(u[m].copyCellsFrom(u[m-1],s-1,f++,1,!1),u[m-1].setCell(s-1,n))}u[m].replaceCells(f,s,n);let g=0;for(let v=u.length-1;v>0&&(v>m||u[v].getTrimmedLength()===0);v--)g++;g>0&&(a.push(l+u.length-g),a.push(g)),l+=u.length-1}return a}function t_(e,t){let s=[],i=0,n=t[i],o=0;for(let a=0;a<e.length;a++)if(n===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,n=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function s_(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function i_(e,t,s){let i=[],n=e.map((h,c)=>ui(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let h=ui(e,a,t);o>h&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;i.push(u),l+=u}return i}function ui(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,n=e[t+1].getWidth(0)===2;return i&&n?s-1:s}var _h=class xh{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=xh._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),os(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};_h._nextId=1;var r_=_h,Pe={},Xt=Pe.B;Pe[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Pe.A={"#":"£"};Pe.B=void 0;Pe[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pe.C=Pe[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pe.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pe.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pe.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pe.E=Pe[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pe.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pe.H=Pe[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var nl=4294967295,ol=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ne.clone(),this.savedCharset=Xt,this.markers=[],this._nullCell=rt.fromCharData([0,Tc,1,0]),this._whitespaceCell=rt.fromCharData([0,At,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ar,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new rl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ir),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ir),this._whitespaceCell}getBlankLine(e,t){return new ei(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>nl?nl:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ne);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new rl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Ne),i=0,n=this._getCorrectBufferLength(t);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ei(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ei(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let a=this.lines.length-n;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=e_(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ne),s);if(i.length>0){let n=t_(this.lines,i);s_(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(Ne),n=s;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ei(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Ne),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let k=this.ybase+this.y;if(k>=a&&k<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),u=i_(h,this._cols,e),m=u.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+m):f=Math.max(0,this.lines.length-this.lines.maxLength+m);let _=[];for(let k=0;k<m;k++){let N=this.getBlankLine(Ne,!0);_.push(N)}_.length>0&&(n.push({start:a+h.length+o,newLines:_}),o+=_.length),h.push(..._);let p=u.length-1,g=u[p];g===0&&(p--,g=u[p]);let v=h.length-m-1,y=c;for(;v>=0;){let k=Math.min(y,g);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[v],y-k,g-k,k,!0),g-=k,g===0&&(p--,g=u[p]),y-=k,y===0){v--;let N=Math.max(v,0);y=ui(h,N,this._cols)}}for(let k=0;k<h.length;k++)u[k]<e&&h[k].setCell(u[k],i);let x=m-f;for(;x-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+t-1)}if(n.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let h=this.lines.length,c=h-1,u=0,m=n[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,h+o-1);g>=0;g--)if(m&&m.start>c+f){for(let v=m.newLines.length-1;v>=0;v--)this.lines.set(g--,m.newLines[v]);g++,a.push({index:c+1,amount:m.newLines.length}),f+=m.newLines.length,m=n[++u]}else this.lines.set(g,l[c--]);let _=0;for(let g=a.length-1;g>=0;g--)a[g].index+=_,this.lines.onInsertEmitter.fire(a[g]),_+=a[g].amount;let p=Math.max(0,h+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,s=0,i){let n=this.lines.get(e);return n?n.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new r_(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},n_=class extends ne{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new O),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new ol(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ol(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},vh=2,bh=1,Fn=class extends ne{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,vh),this.rows=Math.max(e.rawOptions.rows||0,bh),this.buffers=this._register(new n_(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-n+1;s.lines.shiftElements(n+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Fn=we([H(0,Ue)],Fn);var vs={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:or,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},o_=["normal","bold","100","200","300","400","500","600","700","800","900"],a_=class extends ne{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...vs};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ve(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in vs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in vs))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=vs[e]),!l_(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=vs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=o_.includes(t)?t:vs[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function l_(e){return e==="block"||e==="underline"||e==="bar"}function ti(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&ti(e[i],t-1);return s}var al=Object.freeze({insertMode:!1}),ll=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Hn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ti(al),this.decPrivateModes=ti(ll)}reset(){this.modes=ti(al),this.decPrivateModes=ti(ll)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Hn=we([H(0,We),H(1,Ic),H(2,Ue)],Hn);var cl={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Fr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Hr=String.fromCharCode,hl={DEFAULT:e=>{let t=[Fr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Hr(t[0])}${Hr(t[1])}${Hr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Fr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Fr(e,!0)};${e.x};${e.y}${t}`}},Wn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(cl))this.addProtocol(i,cl[i]);for(let i of Object.keys(hl))this.addEncoding(i,hl[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=i+0,Math.abs(e.deltaY)<50&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Wn=we([H(0,We),H(1,ds),H(2,Ue)],Wn);var Wr=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],c_=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Re;function h_(e,t){let s=0,i=t.length-1,n;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(n=s+i>>1,e>t[n][1])s=n+1;else if(e<t[n][0])i=n-1;else return!0;return!1}var d_=class{constructor(){if(this.version="6",!Re){Re=new Uint8Array(65536),Re.fill(1),Re[0]=0,Re.fill(0,1,32),Re.fill(0,127,160),Re.fill(2,4352,4448),Re[9001]=2,Re[9002]=2,Re.fill(2,11904,42192),Re[12351]=1,Re.fill(2,44032,55204),Re.fill(2,63744,64256),Re.fill(2,65040,65050),Re.fill(2,65072,65136),Re.fill(2,65280,65377),Re.fill(2,65504,65511);for(let e=0;e<Wr.length;++e)Re.fill(0,Wr[e][0],Wr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Re[e]:h_(e,c_)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let n=Jt.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return Jt.createPropertyValue(0,s,i)}},Jt=class Yi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new d_;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,n=t.length;for(let o=0;o<n;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=Yi.extractWidth(l);Yi.extractShouldJoin(l)&&(h-=Yi.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},u_=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function dl(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Ks=2147483647,f_=256,yh=class Un{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>f_)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Un;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let n=t[i];if(Array.isArray(n))for(let o=0;o<n.length;++o)s.addSubParam(n[o]);else s.addParam(n)}return s}clone(){let t=new Un(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,n))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Ks?Ks:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Ks?Ks:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&(t[s]=this._subParams.slice(i,n))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,n=i[s-1];i[s-1]=~n?Math.min(n*10+t,Ks):t}},qs=[],m_=class{constructor(){this._state=0,this._active=qs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=qs}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=qs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||qs,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",_r(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=qs,this._id=-1,this._state=0}}},Ze=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=_r(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Vs=[],p_=class{constructor(){this._handlers=Object.create(null),this._active=Vs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Vs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Vs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",_r(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Vs,this._ident=0}},si=new yh;si.addParam(0);var ul=class{constructor(e){this._handler=e,this._data="",this._params=si,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():si,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=_r(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=si,this._data="",this._hitLimit=!1,s));return this._params=si,this._data="",this._hitLimit=!1,t}},g_=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|i}},it=160,__=(function(){let e=new g_(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>t.slice(l,h),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(it,0,2,0),e.add(it,8,5,8),e.add(it,6,0,6),e.add(it,11,0,11),e.add(it,13,13,13),e})(),x_=class extends ne{constructor(e=__){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new yh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ve(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new m_),this._dcsParser=this._register(new p_),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,t,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<t;++l){switch(i=e[l],n=this._transitions.table[this.currentState<<8|(i<160?i:it)],n>>4){case 2:for(let f=l+1;;++f){if(f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let u=this._escHandlers[this._collect<<8|i],m=u?u.length-1:-1;for(;m>=0&&(a=u[m](),a!==!0);m--)if(a instanceof Promise)return this._preserveStack(4,u,m,n,l),a;m<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(i=e[f])===24||i===26||i===27||i>127&&i<it){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=t||(i=e[f])<32||i>127&&i<it){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},v_=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,b_=/^[\da-f]+$/;function fl(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=v_.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),b_.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let n=0;n<3;++n){let o=parseInt(t.slice(s*n,s*n+s),16);i[n]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function Ur(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function y_(e,t=16){let[s,i,n]=e;return`rgb:${Ur(s,t)}/${Ur(i,t)}/${Ur(n,t)}`}var S_={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Bt=131072,ml=10;function pl(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var gl=5e3,_l=0,w_=class extends ne{constructor(e,t,s,i,n,o,a,l,h=new x_){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Hm,this._utf8Decoder=new Wm,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ne.clone(),this._eraseAttrDataInternal=Ne.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Kn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:m})}),this._parser.setDcsHandlerFallback((c,u,m)=>{u==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:m})}),this._parser.setPrintHandler((c,u,m)=>this.print(c,u,m)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(P.BEL,()=>this.bell()),this._parser.setExecuteHandler(P.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(P.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(P.BS,()=>this.backspace()),this._parser.setExecuteHandler(P.HT,()=>this.tab()),this._parser.setExecuteHandler(P.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(P.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Vi.IND,()=>this.index()),this._parser.setExecuteHandler(Vi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Vi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ze(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Ze(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Ze(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Ze(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Ze(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Ze(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Ze(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Ze(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Ze(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Ze(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Ze(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Ze(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in Pe)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new ul((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),gl))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${gl} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Bt&&(o=this._parseStack.position+Bt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Bt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Bt))),a||this._dirtyRowTracker.clearRange(),e.length>Bt)for(let c=o;c<e.length;c+=Bt){let u=c+Bt<e.length?c+Bt:e.length,m=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,m))return this._preserveStack(i,n,m,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,n,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,u=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let _=t;_<s;++_){if(i=e[_],i<127&&o){let y=o[String.fromCharCode(i)];y&&(i=y.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);n=Jt.extractWidth(p);let g=Jt.extractShouldJoin(p),v=g?Jt.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Tt(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-v>l){if(h){let y=m,x=this._activeBuffer.x-v;for(this._activeBuffer.x=v,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof ei&&m.copyCellsFrom(y,x,0,v,!1);x<l;)y.setCellFromCodepoint(x++,0,1,u)}else if(this._activeBuffer.x=l-1,n===2)continue}if(g&&this._activeBuffer.x){let y=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-y,i,n);for(let x=n-v;--x>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(m.insertCells(this._activeBuffer.x,n-v,this._activeBuffer.getNullCell(u)),m.getWidth(l-1)===2&&m.setCellFromCodepoint(l-1,0,1,u)),m.setCellFromCodepoint(this._activeBuffer.x++,i,n,u),n>0)for(;--n;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>pl(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new ul(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ze(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ne));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=Jt.extractWidth(t),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let u=o.codePointAt(c)||0;a[l++]=u,c+=u>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(P.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(P.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(P.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(P.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(P.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Xt),this._charsetService.setgCharset(1,Xt),this._charsetService.setgCharset(2,Xt),this._charsetService.setgCharset(3,Xt);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,m=this._optionsService.rawOptions,f=(g,v)=>(a.triggerDataEvent(`${P.ESC}[${t?"":"?"}${g};${v}$y`),!0),_=g=>g?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,_(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,_(m.convertEol)):f(p,0):p===1?f(p,_(i.applicationCursorKeys)):p===3?f(p,m.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,_(i.origin)):p===7?f(p,_(i.wraparound)):p===8?f(p,3):p===9?f(p,_(n==="X10")):p===12?f(p,_(m.cursorBlink)):p===25?f(p,_(!a.isCursorHidden)):p===45?f(p,_(i.reverseWraparound)):p===66?f(p,_(i.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,_(n==="VT200")):p===1002?f(p,_(n==="DRAG")):p===1003?f(p,_(n==="ANY")):p===1004?f(p,_(i.sendFocus)):p===1005?f(p,4):p===1006?f(p,_(o==="SGR")):p===1015?f(p,4):p===1016?f(p,_(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,_(c===u)):p===2004?f(p,_(i.bracketedPasteMode)):p===2026?f(p,_(i.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=gi.fromColorRGB([s,i,n])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do i[1]===5&&(n=1),i[o+l+1+n]=a[l];while(++l<a.length&&l+o+1+n<i.length);break}if(i[1]===5&&o+n>=2||i[1]===2&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ne.fg,e.bg=Ne.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let n=0;n<t;n++)s=e.params[n],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Ne.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ne.bg&16777215):s===38||s===48||s===58?n+=this._extractColor(e,n,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Ne.fg&16777215,i.bg&=-67108864,i.bg|=Ne.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${P.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ne.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!pl(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${P.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ml&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ml&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),n=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(xl(o))if(n==="?")t.push({type:0,index:o});else{let a=fl(n);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(o=>o.startsWith("id="));return n!==-1&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let n=fl(s[i]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let n=parseInt(s[i]);xl(n)&&t.push({type:2,index:n})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Xt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(S_[e[0]],Pe[e[1]]||Xt),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ne.clone(),this._eraseAttrDataInternal=Ne.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new rt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${P.ESC}${a}${P.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[n.cursorStyle]-(n.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Kn=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(_l=e,e=t,t=_l),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Kn=we([H(0,We)],Kn);function xl(e){return 0<=e&&e<256}var C_=5e7,vl=12,k_=50,N_=class extends ne{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>C_)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],n=this._action(i,t);if(n){let a=l=>performance.now()-s>=vl?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=vl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>k_&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},qn=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),n=this._entriesWithId.get(i);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};qn=we([H(0,We)],qn);var bl=!1,j_=class extends ne{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ds),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new Jg,this.optionsService=this._register(new a_(e)),this._instantiationService.setService(Ue,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Fn)),this._instantiationService.setService(We,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(In)),this._instantiationService.setService(Ic,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Hn)),this._instantiationService.setService(ds,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Wn)),this._instantiationService.setService($c,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Jt)),this._instantiationService.setService(Vm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u_),this._instantiationService.setService(qm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(qn),this._instantiationService.setService(Fc,this._oscLinkService),this._inputHandler=this._register(new w_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new N_((t,s)=>this._inputHandler.parse(t,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!bl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),bl=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,vh),t=Math.max(t,bh),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(dl.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(dl(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ve(()=>{for(let t of e)t.dispose()})}}},E_={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function D_(e,t,s,i){var a;let n={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?n.key=P.ESC+"OA":n.key=P.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=P.ESC+"OD":n.key=P.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=P.ESC+"OC":n.key=P.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=P.ESC+"OB":n.key=P.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":P.DEL,e.altKey&&(n.key=P.ESC+n.key);break;case 9:if(e.shiftKey){n.key=P.ESC+"[Z";break}n.key=P.HT,n.cancel=!0;break;case 13:n.key=e.altKey?P.ESC+P.CR:P.CR,n.cancel=!0;break;case 27:n.key=P.ESC,e.altKey&&(n.key=P.ESC+P.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"D":t?n.key=P.ESC+"OD":n.key=P.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"C":t?n.key=P.ESC+"OC":n.key=P.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"A":t?n.key=P.ESC+"OA":n.key=P.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"B":t?n.key=P.ESC+"OB":n.key=P.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=P.ESC+"[2~");break;case 46:o?n.key=P.ESC+"[3;"+(o+1)+"~":n.key=P.ESC+"[3~";break;case 36:o?n.key=P.ESC+"[1;"+(o+1)+"H":t?n.key=P.ESC+"OH":n.key=P.ESC+"[H";break;case 35:o?n.key=P.ESC+"[1;"+(o+1)+"F":t?n.key=P.ESC+"OF":n.key=P.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=P.ESC+"[5;"+(o+1)+"~":n.key=P.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=P.ESC+"[6;"+(o+1)+"~":n.key=P.ESC+"[6~";break;case 112:o?n.key=P.ESC+"[1;"+(o+1)+"P":n.key=P.ESC+"OP";break;case 113:o?n.key=P.ESC+"[1;"+(o+1)+"Q":n.key=P.ESC+"OQ";break;case 114:o?n.key=P.ESC+"[1;"+(o+1)+"R":n.key=P.ESC+"OR";break;case 115:o?n.key=P.ESC+"[1;"+(o+1)+"S":n.key=P.ESC+"OS";break;case 116:o?n.key=P.ESC+"[15;"+(o+1)+"~":n.key=P.ESC+"[15~";break;case 117:o?n.key=P.ESC+"[17;"+(o+1)+"~":n.key=P.ESC+"[17~";break;case 118:o?n.key=P.ESC+"[18;"+(o+1)+"~":n.key=P.ESC+"[18~";break;case 119:o?n.key=P.ESC+"[19;"+(o+1)+"~":n.key=P.ESC+"[19~";break;case 120:o?n.key=P.ESC+"[20;"+(o+1)+"~":n.key=P.ESC+"[20~";break;case 121:o?n.key=P.ESC+"[21;"+(o+1)+"~":n.key=P.ESC+"[21~";break;case 122:o?n.key=P.ESC+"[23;"+(o+1)+"~":n.key=P.ESC+"[23~";break;case 123:o?n.key=P.ESC+"[24;"+(o+1)+"~":n.key=P.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?n.key=P.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=P.DEL:e.keyCode===219?n.key=P.ESC:e.keyCode===220?n.key=P.FS:e.keyCode===221&&(n.key=P.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=E_[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)n.key=P.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),n.key=P.ESC+c}else if(e.keyCode===32)n.key=P.ESC+(e.ctrlKey?P.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=P.ESC+h,n.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(n.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?n.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(n.key=P.US),e.key==="@"&&(n.key=P.NUL));break}return n}var ke=0,R_=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ar,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ar,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[n]=e[t],t++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ke=this._search(t),ke===-1)||this._getKey(this._array[ke])!==t)return!1;do if(this._array[ke]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ke),!0;while(++ke<this._array.length&&this._getKey(this._array[ke])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do yield this._array[ke];while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do t(this._array[ke]);while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Kr=0,yl=0,P_=class extends ne{constructor(){super(),this._decorations=new R_(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ve(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new M_(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,n=i+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,n=>{Kr=n.options.x??0,yl=Kr+(n.options.width??1),e>=Kr&&e<yl&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},M_=class extends Wt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ye.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ye.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},L_=1e3,B_=class{constructor(e,t=L_){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=i-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Sl=20,lr=class extends ne{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new B_(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
195
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Co&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Qa(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=wo(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-$r),$r),t/=$r,t/Math.abs(t)+Math.round(t*($g-1)))}shouldForceSelection(e){return or?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Ig)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(or&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Fg&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=Pg(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==i&&(s+=n-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,u=0,m=0,f=0,_=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let v=e[0],y=e[0];o.getWidth(v)===0&&(u++,v--),o.getWidth(y)===2&&(m++,y++);let x=o.getString(y).length;for(x>1&&(_+=x-1,h+=x-1);v>0&&l>0&&!this._isCharWordSeparator(o.loadCell(v-1,this._workCell));){o.loadCell(v-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,v--):k>1&&(f+=k-1,l-=k-1),l--,v--}for(;y<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(y+1,this._workCell));){o.loadCell(y+1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===2?(m++,y++):k>1&&(_+=k-1,h+=k-1),h++,y++}}h++;let p=l+c-u+f,g=Math.min(this._bufferService.cols,h-l+u+m-f-_);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&p===0&&o.getCodePoint(0)!==32){let v=n.lines.get(e[1]-1);if(v&&o.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let x=this._bufferService.cols-y.start;p-=x,g+=x}}}if(i&&p+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let v=n.lines.get(e[1]+1);if(v!=null&&v.isWrapped&&v.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(g+=y.length)}}return{start:p,length:g}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Qa(s,this._bufferService.cols)}};On=we([H(3,We),H(4,ds),H(5,go),H(6,Ue),H(7,Et),H(8,Nt)],On);var el=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},tl=class{constructor(){this._color=new el,this._css=new el}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},De=Object.freeze((()=>{let e=[ye.toColor("#2e3436"),ye.toColor("#cc0000"),ye.toColor("#4e9a06"),ye.toColor("#c4a000"),ye.toColor("#3465a4"),ye.toColor("#75507b"),ye.toColor("#06989a"),ye.toColor("#d3d7cf"),ye.toColor("#555753"),ye.toColor("#ef2929"),ye.toColor("#8ae234"),ye.toColor("#fce94f"),ye.toColor("#729fcf"),ye.toColor("#ad7fa8"),ye.toColor("#34e2e2"),ye.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],n=t[s/6%6|0],o=t[s%6];e.push({css:Ne.toCss(i,n,o),rgba:Ne.toRgba(i,n,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Ne.toCss(i,i,i),rgba:Ne.toRgba(i,i,i)})}return e})()),Yt=ye.toColor("#ffffff"),Qs=ye.toColor("#000000"),sl=ye.toColor("#ffffff"),il=Qs,Us={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Ug=Yt,$n=class extends ne{constructor(e){super(),this._optionsService=e,this._contrastCache=new tl,this._halfContrastCache=new tl,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Yt,background:Qs,cursor:sl,cursorAccent:il,selectionForeground:void 0,selectionBackgroundTransparent:Us,selectionBackgroundOpaque:xe.blend(Qs,Us),selectionInactiveBackgroundTransparent:Us,selectionInactiveBackgroundOpaque:xe.blend(Qs,Us),scrollbarSliderBackground:xe.opacity(Yt,.2),scrollbarSliderHoverBackground:xe.opacity(Yt,.4),scrollbarSliderActiveBackground:xe.opacity(Yt,.5),overviewRulerBorder:Yt,ansi:De.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=me(e.foreground,Yt),t.background=me(e.background,Qs),t.cursor=xe.blend(t.background,me(e.cursor,sl)),t.cursorAccent=xe.blend(t.background,me(e.cursorAccent,il)),t.selectionBackgroundTransparent=me(e.selectionBackground,Us),t.selectionBackgroundOpaque=xe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=me(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=xe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?me(e.selectionForeground,Xa):void 0,t.selectionForeground===Xa&&(t.selectionForeground=void 0),xe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=xe.opacity(t.selectionBackgroundTransparent,.3)),xe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=xe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=me(e.scrollbarSliderBackground,xe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=me(e.scrollbarSliderHoverBackground,xe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=me(e.scrollbarSliderActiveBackground,xe.opacity(t.foreground,.5)),t.overviewRulerBorder=me(e.overviewRulerBorder,Ug),t.ansi=De.slice(),t.ansi[0]=me(e.black,De[0]),t.ansi[1]=me(e.red,De[1]),t.ansi[2]=me(e.green,De[2]),t.ansi[3]=me(e.yellow,De[3]),t.ansi[4]=me(e.blue,De[4]),t.ansi[5]=me(e.magenta,De[5]),t.ansi[6]=me(e.cyan,De[6]),t.ansi[7]=me(e.white,De[7]),t.ansi[8]=me(e.brightBlack,De[8]),t.ansi[9]=me(e.brightRed,De[9]),t.ansi[10]=me(e.brightGreen,De[10]),t.ansi[11]=me(e.brightYellow,De[11]),t.ansi[12]=me(e.brightBlue,De[12]),t.ansi[13]=me(e.brightMagenta,De[13]),t.ansi[14]=me(e.brightCyan,De[14]),t.ansi[15]=me(e.brightWhite,De[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=me(e.extendedAnsi[i],De[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};$n=we([H(0,Ue)],$n);function me(e,t){if(e!==void 0)try{return ye.toColor(e)}catch{}return t}var Kg=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},qg=class{constructor(){this._services=new Kg,this._services.set(po,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=$m(e).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let n=s.length>0?s[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Vg={trace:0,debug:1,info:2,warn:3,error:4,off:5},Gg="xterm.js: ",In=class extends ne{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Vg[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Gg)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};In=we([H(0,Ue)],In);var rl=class extends ne{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},re=3,je=Object.freeze(new gi),Fi=0,Ir=2,ei=class gh{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*re);let n=s||rt.fromCharData([0,Tc,1,0]);for(let o=0;o<t;++o)this.setCell(o,n);this.length=t}get(t){let s=this._data[t*re+0],i=s&2097151;return[this._data[t*re+1],s&2097152?this._combined[t]:i?Tt(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*re+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*re+0]=t|2097152|s[2]<<22):this._data[t*re+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*re+0]>>22}hasWidth(t){return this._data[t*re+0]&12582912}getFg(t){return this._data[t*re+1]}getBg(t){return this._data[t*re+2]}hasContent(t){return this._data[t*re+0]&4194303}getCodePoint(t){let s=this._data[t*re+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*re+0]&2097152}getString(t){let s=this._data[t*re+0];return s&2097152?this._combined[t]:s&2097151?Tt(s&2097151):""}isProtected(t){return this._data[t*re+2]&536870912}loadCell(t,s){return Fi=t*re,s.content=this._data[Fi+0],s.fg=this._data[Fi+1],s.bg=this._data[Fi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*re+0]=s.content,this._data[t*re+1]=s.fg,this._data[t*re+2]=s.bg}setCellFromCodepoint(t,s,i,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*re+0]=s|i<<22,this._data[t*re+1]=n.fg,this._data[t*re+2]=n.bg}addCodepointToCell(t,s,i){let n=this._data[t*re+0];n&2097152?this._combined[t]+=Tt(s):n&2097151?(this._combined[t]=Tt(n&2097151)+Tt(s),n&=-2097152,n|=2097152):n=s|1<<22,i&&(n&=-12582913,n|=i<<22),this._data[t*re+0]=n}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let n=new rt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,n));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let n=new rt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,n));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,n=!1){if(n){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*Ir<this._data.buffer.byteLength;let i=t*re;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let n=new Uint32Array(i);n.set(this._data),this._data=n}for(let n=this.length;n<t;++n)this.setCell(n,s)}else{this._data=this._data.subarray(0,i);let n=Object.keys(this._combined);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*Ir<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ir<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new gh(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303)return t+(this._data[t*re+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*re+0]&4194303||this._data[t*re+2]&50331648)return t+(this._data[t*re+0]>>22);return 0}copyCellsFrom(t,s,i,n,o){let a=t._data;if(o)for(let h=n-1;h>=0;h--){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<n;h++){for(let c=0;c<re;c++)this._data[(i+h)*re+c]=a[(s+h)*re+c];a[(s+h)*re+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=t._combined[c])}}translateToString(t,s,i,n){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),n&&(n.length=0);let o="";for(;s<i;){let a=this._data[s*re+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Tt(l):At;if(o+=h,n)for(let c=0;c<h.length;++c)n.push(s);s+=a>>22||1}return n&&n.push(s),o}};function Yg(e,t,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let u=[e.get(l)];for(;h<e.length&&c.isWrapped;)u.push(c),c=e.get(++h);if(!o&&i>=l&&i<h){l+=u.length-1;continue}let m=0,f=ui(u,m,t),_=1,p=0;for(;_<u.length;){let v=ui(u,_,t),y=v-p,x=s-f,k=Math.min(y,x);u[m].copyCellsFrom(u[_],p,f,k,!1),f+=k,f===s&&(m++,f=0),p+=k,p===v&&(_++,p=0),f===0&&m!==0&&u[m-1].getWidth(s-1)===2&&(u[m].copyCellsFrom(u[m-1],s-1,f++,1,!1),u[m-1].setCell(s-1,n))}u[m].replaceCells(f,s,n);let g=0;for(let v=u.length-1;v>0&&(v>m||u[v].getTrimmedLength()===0);v--)g++;g>0&&(a.push(l+u.length-g),a.push(g)),l+=u.length-1}return a}function Xg(e,t){let s=[],i=0,n=t[i],o=0;for(let a=0;a<e.length;a++)if(n===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,n=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function Jg(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function Zg(e,t,s){let i=[],n=e.map((h,c)=>ui(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let h=ui(e,a,t);o>h&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let u=c?s-1:s;i.push(u),l+=u}return i}function ui(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,n=e[t+1].getWidth(0)===2;return i&&n?s-1:s}var _h=class xh{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=xh._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),os(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};_h._nextId=1;var Qg=_h,Pe={},Xt=Pe.B;Pe[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Pe.A={"#":"£"};Pe.B=void 0;Pe[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Pe.C=Pe[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Pe.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Pe.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Pe.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Pe.E=Pe[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Pe.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Pe.H=Pe[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Pe["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var nl=4294967295,ol=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=je.clone(),this.savedCharset=Xt,this.markers=[],this._nullCell=rt.fromCharData([0,Tc,1,0]),this._whitespaceCell=rt.fromCharData([0,At,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ar,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new rl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new ir),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new ir),this._whitespaceCell}getBlankLine(e,t){return new ei(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>nl?nl:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=je);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new rl(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(je),i=0,n=this._getCorrectBufferLength(t);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ei(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ei(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let a=this.lines.length-n;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=Yg(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(je),s);if(i.length>0){let n=Xg(this.lines,i);Jg(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(je),n=s;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ei(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(je),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let k=this.ybase+this.y;if(k>=a&&k<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),u=Zg(h,this._cols,e),m=u.length-h.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+m):f=Math.max(0,this.lines.length-this.lines.maxLength+m);let _=[];for(let k=0;k<m;k++){let j=this.getBlankLine(je,!0);_.push(j)}_.length>0&&(n.push({start:a+h.length+o,newLines:_}),o+=_.length),h.push(..._);let p=u.length-1,g=u[p];g===0&&(p--,g=u[p]);let v=h.length-m-1,y=c;for(;v>=0;){let k=Math.min(y,g);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[v],y-k,g-k,k,!0),g-=k,g===0&&(p--,g=u[p]),y-=k,y===0){v--;let j=Math.max(v,0);y=ui(h,j,this._cols)}}for(let k=0;k<h.length;k++)u[k]<e&&h[k].setCell(u[k],i);let x=m-f;for(;x-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+t-1)}if(n.length>0){let a=[],l=[];for(let g=0;g<this.lines.length;g++)l.push(this.lines.get(g));let h=this.lines.length,c=h-1,u=0,m=n[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let f=0;for(let g=Math.min(this.lines.maxLength-1,h+o-1);g>=0;g--)if(m&&m.start>c+f){for(let v=m.newLines.length-1;v>=0;v--)this.lines.set(g--,m.newLines[v]);g++,a.push({index:c+1,amount:m.newLines.length}),f+=m.newLines.length,m=n[++u]}else this.lines.set(g,l[c--]);let _=0;for(let g=a.length-1;g>=0;g--)a[g].index+=_,this.lines.onInsertEmitter.fire(a[g]),_+=a[g].amount;let p=Math.max(0,h+o-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,s=0,i){let n=this.lines.get(e);return n?n.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new Qg(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},e_=class extends ne{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new O),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new ol(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ol(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},vh=2,bh=1,Fn=class extends ne{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,vh),this.rows=Math.max(e.rawOptions.rows||0,bh),this.buffers=this._register(new e_(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-n+1;s.lines.shiftElements(n+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Fn=we([H(0,Ue)],Fn);var vs={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:or,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},t_=["normal","bold","100","200","300","400","500","600","700","800","900"],s_=class extends ne{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...vs};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ve(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in vs))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in vs))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=vs[e]),!i_(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=vs[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=t_.includes(t)?t:vs[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function i_(e){return e==="block"||e==="underline"||e==="bar"}function ti(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&ti(e[i],t-1);return s}var al=Object.freeze({insertMode:!1}),ll=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Hn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ti(al),this.decPrivateModes=ti(ll)}reset(){this.modes=ti(al),this.decPrivateModes=ti(ll)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Hn=we([H(0,We),H(1,Ic),H(2,Ue)],Hn);var cl={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Fr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Hr=String.fromCharCode,hl={DEFAULT:e=>{let t=[Fr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Hr(t[0])}${Hr(t[1])}${Hr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Fr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Fr(e,!0)};${e.x};${e.y}${t}`}},Wn=class extends ne{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(cl))this.addProtocol(i,cl[i]);for(let i of Object.keys(hl))this.addEncoding(i,hl[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=i+0,Math.abs(e.deltaY)<50&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Wn=we([H(0,We),H(1,ds),H(2,Ue)],Wn);var Wr=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],r_=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Re;function n_(e,t){let s=0,i=t.length-1,n;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(n=s+i>>1,e>t[n][1])s=n+1;else if(e<t[n][0])i=n-1;else return!0;return!1}var o_=class{constructor(){if(this.version="6",!Re){Re=new Uint8Array(65536),Re.fill(1),Re[0]=0,Re.fill(0,1,32),Re.fill(0,127,160),Re.fill(2,4352,4448),Re[9001]=2,Re[9002]=2,Re.fill(2,11904,42192),Re[12351]=1,Re.fill(2,44032,55204),Re.fill(2,63744,64256),Re.fill(2,65040,65050),Re.fill(2,65072,65136),Re.fill(2,65280,65377),Re.fill(2,65504,65511);for(let e=0;e<Wr.length;++e)Re.fill(0,Wr[e][0],Wr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Re[e]:n_(e,r_)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let n=Jt.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return Jt.createPropertyValue(0,s,i)}},Jt=class Yi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new o_;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,n=t.length;for(let o=0;o<n;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=Yi.extractWidth(l);Yi.extractShouldJoin(l)&&(h-=Yi.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},a_=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function dl(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Ks=2147483647,l_=256,yh=class Un{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>l_)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Un;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let n=t[i];if(Array.isArray(n))for(let o=0;o<n.length;++o)s.addSubParam(n[o]);else s.addParam(n)}return s}clone(){let t=new Un(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,n))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Ks?Ks:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Ks?Ks:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&(t[s]=this._subParams.slice(i,n))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,n=i[s-1];i[s-1]=~n?Math.min(n*10+t,Ks):t}},qs=[],c_=class{constructor(){this._state=0,this._active=qs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=qs}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=qs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||qs,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",_r(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=qs,this._id=-1,this._state=0}}},Ze=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=_r(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Vs=[],h_=class{constructor(){this._handlers=Object.create(null),this._active=Vs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Vs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Vs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",_r(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Vs,this._ident=0}},si=new yh;si.addParam(0);var ul=class{constructor(e){this._handler=e,this._data="",this._params=si,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():si,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=_r(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=si,this._data="",this._hitLimit=!1,s));return this._params=si,this._data="",this._hitLimit=!1,t}},d_=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|i}},it=160,u_=(function(){let e=new d_(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>t.slice(l,h),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(it,0,2,0),e.add(it,8,5,8),e.add(it,6,0,6),e.add(it,11,0,11),e.add(it,13,13,13),e})(),f_=class extends ne{constructor(e=u_){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new yh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ve(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new c_),this._dcsParser=this._register(new h_),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,t,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<t;++l){switch(i=e[l],n=this._transitions.table[this.currentState<<8|(i<160?i:it)],n>>4){case 2:for(let f=l+1;;++f){if(f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(i=e[f])<32||i>126&&i<it){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let u=this._escHandlers[this._collect<<8|i],m=u?u.length-1:-1;for(;m>=0&&(a=u[m](),a!==!0);m--)if(a instanceof Promise)return this._preserveStack(4,u,m,n,l),a;m<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(i=e[f])===24||i===26||i===27||i>127&&i<it){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=l+1;;f++)if(f>=t||(i=e[f])<32||i>127&&i<it){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},m_=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,p_=/^[\da-f]+$/;function fl(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=m_.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),p_.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let n=0;n<3;++n){let o=parseInt(t.slice(s*n,s*n+s),16);i[n]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function Ur(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function g_(e,t=16){let[s,i,n]=e;return`rgb:${Ur(s,t)}/${Ur(i,t)}/${Ur(n,t)}`}var __={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Bt=131072,ml=10;function pl(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var gl=5e3,_l=0,x_=class extends ne{constructor(e,t,s,i,n,o,a,l,h=new f_){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Am,this._utf8Decoder=new Om,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=je.clone(),this._eraseAttrDataInternal=je.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Kn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:u.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,u,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:u,data:m})}),this._parser.setDcsHandlerFallback((c,u,m)=>{u==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:u,payload:m})}),this._parser.setPrintHandler((c,u,m)=>this.print(c,u,m)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(P.BEL,()=>this.bell()),this._parser.setExecuteHandler(P.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(P.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(P.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(P.BS,()=>this.backspace()),this._parser.setExecuteHandler(P.HT,()=>this.tab()),this._parser.setExecuteHandler(P.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(P.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Vi.IND,()=>this.index()),this._parser.setExecuteHandler(Vi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Vi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ze(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Ze(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Ze(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Ze(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Ze(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Ze(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Ze(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Ze(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Ze(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Ze(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Ze(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Ze(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in Pe)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new ul((c,u)=>this.requestStatusString(c,u)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),gl))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${gl} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Bt&&(o=this._parseStack.position+Bt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Bt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Bt))),a||this._dirtyRowTracker.clearRange(),e.length>Bt)for(let c=o;c<e.length;c+=Bt){let u=c+Bt<e.length?c+Bt:e.length,m=typeof e=="string"?this._stringDecoder.decode(e.substring(c,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,u),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,m))return this._preserveStack(i,n,m,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,n,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,u=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let _=t;_<s;++_){if(i=e[_],i<127&&o){let y=o[String.fromCharCode(i)];y&&(i=y.charCodeAt(0))}let p=this._unicodeService.charProperties(i,f);n=Jt.extractWidth(p);let g=Jt.extractShouldJoin(p),v=g?Jt.extractWidth(f):0;if(f=p,a&&this._onA11yChar.fire(Tt(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-v>l){if(h){let y=m,x=this._activeBuffer.x-v;for(this._activeBuffer.x=v,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&m instanceof ei&&m.copyCellsFrom(y,x,0,v,!1);x<l;)y.setCellFromCodepoint(x++,0,1,u)}else if(this._activeBuffer.x=l-1,n===2)continue}if(g&&this._activeBuffer.x){let y=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-y,i,n);for(let x=n-v;--x>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(c&&(m.insertCells(this._activeBuffer.x,n-v,this._activeBuffer.getNullCell(u)),m.getWidth(l-1)===2&&m.setCellFromCodepoint(l-1,0,1,u)),m.setCellFromCodepoint(this._activeBuffer.x++,i,n,u),n>0)for(;--n;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>pl(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new ul(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ze(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(je));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=Jt.extractWidth(t),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let u=o.codePointAt(c)||0;a[l++]=u,c+=u>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(P.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(P.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(P.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(P.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(P.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Xt),this._charsetService.setgCharset(1,Xt),this._charsetService.setgCharset(2,Xt),this._charsetService.setgCharset(3,Xt);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:u}=l,m=this._optionsService.rawOptions,f=(g,v)=>(a.triggerDataEvent(`${P.ESC}[${t?"":"?"}${g};${v}$y`),!0),_=g=>g?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,_(a.modes.insertMode)):p===12?f(p,3):p===20?f(p,_(m.convertEol)):f(p,0):p===1?f(p,_(i.applicationCursorKeys)):p===3?f(p,m.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?f(p,_(i.origin)):p===7?f(p,_(i.wraparound)):p===8?f(p,3):p===9?f(p,_(n==="X10")):p===12?f(p,_(m.cursorBlink)):p===25?f(p,_(!a.isCursorHidden)):p===45?f(p,_(i.reverseWraparound)):p===66?f(p,_(i.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,_(n==="VT200")):p===1002?f(p,_(n==="DRAG")):p===1003?f(p,_(n==="ANY")):p===1004?f(p,_(i.sendFocus)):p===1005?f(p,4):p===1006?f(p,_(o==="SGR")):p===1015?f(p,4):p===1016?f(p,_(o==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,_(c===u)):p===2004?f(p,_(i.bracketedPasteMode)):p===2026?f(p,_(i.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=gi.fromColorRGB([s,i,n])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do i[1]===5&&(n=1),i[o+l+1+n]=a[l];while(++l<a.length&&l+o+1+n<i.length);break}if(i[1]===5&&o+n>=2||i[1]===2&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=je.fg,e.bg=je.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let n=0;n<t;n++)s=e.params[n],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=je.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=je.bg&16777215):s===38||s===48||s===58?n+=this._extractColor(e,n,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=je.fg&16777215,i.bg&=-67108864,i.bg|=je.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${P.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${P.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=je.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!pl(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${P.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ml&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ml&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),n=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(xl(o))if(n==="?")t.push({type:0,index:o});else{let a=fl(n);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(o=>o.startsWith("id="));return n!==-1&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let n=fl(s[i]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let n=parseInt(s[i]);xl(n)&&t.push({type:2,index:n})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Xt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(__[e[0]],Pe[e[1]]||Xt),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=je.clone(),this._eraseAttrDataInternal=je.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new rt;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${P.ESC}${a}${P.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[n.cursorStyle]-(n.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Kn=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(_l=e,e=t,t=_l),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Kn=we([H(0,We)],Kn);function xl(e){return 0<=e&&e<256}var v_=5e7,vl=12,b_=50,y_=class extends ne{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>v_)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],n=this._action(i,t);if(n){let a=l=>performance.now()-s>=vl?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=vl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>b_&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},qn=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),n=this._entriesWithId.get(i);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};qn=we([H(0,We)],qn);var bl=!1,S_=class extends ne{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Ds),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new qg,this.optionsService=this._register(new s_(e)),this._instantiationService.setService(Ue,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Fn)),this._instantiationService.setService(We,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(In)),this._instantiationService.setService(Ic,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Hn)),this._instantiationService.setService(ds,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Wn)),this._instantiationService.setService($c,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Jt)),this._instantiationService.setService(Hm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(a_),this._instantiationService.setService(Fm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(qn),this._instantiationService.setService(Fc,this._oscLinkService),this._inputHandler=this._register(new x_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new y_((t,s)=>this._inputHandler.parse(t,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!bl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),bl=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,vh),t=Math.max(t,bh),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(dl.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(dl(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ve(()=>{for(let t of e)t.dispose()})}}},w_={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function C_(e,t,s,i){var a;let n={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?n.key=P.ESC+"OA":n.key=P.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=P.ESC+"OD":n.key=P.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=P.ESC+"OC":n.key=P.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=P.ESC+"OB":n.key=P.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":P.DEL,e.altKey&&(n.key=P.ESC+n.key);break;case 9:if(e.shiftKey){n.key=P.ESC+"[Z";break}n.key=P.HT,n.cancel=!0;break;case 13:n.key=e.altKey?P.ESC+P.CR:P.CR,n.cancel=!0;break;case 27:n.key=P.ESC,e.altKey&&(n.key=P.ESC+P.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"D":t?n.key=P.ESC+"OD":n.key=P.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"C":t?n.key=P.ESC+"OC":n.key=P.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"A":t?n.key=P.ESC+"OA":n.key=P.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=P.ESC+"[1;"+(o+1)+"B":t?n.key=P.ESC+"OB":n.key=P.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=P.ESC+"[2~");break;case 46:o?n.key=P.ESC+"[3;"+(o+1)+"~":n.key=P.ESC+"[3~";break;case 36:o?n.key=P.ESC+"[1;"+(o+1)+"H":t?n.key=P.ESC+"OH":n.key=P.ESC+"[H";break;case 35:o?n.key=P.ESC+"[1;"+(o+1)+"F":t?n.key=P.ESC+"OF":n.key=P.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=P.ESC+"[5;"+(o+1)+"~":n.key=P.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=P.ESC+"[6;"+(o+1)+"~":n.key=P.ESC+"[6~";break;case 112:o?n.key=P.ESC+"[1;"+(o+1)+"P":n.key=P.ESC+"OP";break;case 113:o?n.key=P.ESC+"[1;"+(o+1)+"Q":n.key=P.ESC+"OQ";break;case 114:o?n.key=P.ESC+"[1;"+(o+1)+"R":n.key=P.ESC+"OR";break;case 115:o?n.key=P.ESC+"[1;"+(o+1)+"S":n.key=P.ESC+"OS";break;case 116:o?n.key=P.ESC+"[15;"+(o+1)+"~":n.key=P.ESC+"[15~";break;case 117:o?n.key=P.ESC+"[17;"+(o+1)+"~":n.key=P.ESC+"[17~";break;case 118:o?n.key=P.ESC+"[18;"+(o+1)+"~":n.key=P.ESC+"[18~";break;case 119:o?n.key=P.ESC+"[19;"+(o+1)+"~":n.key=P.ESC+"[19~";break;case 120:o?n.key=P.ESC+"[20;"+(o+1)+"~":n.key=P.ESC+"[20~";break;case 121:o?n.key=P.ESC+"[21;"+(o+1)+"~":n.key=P.ESC+"[21~";break;case 122:o?n.key=P.ESC+"[23;"+(o+1)+"~":n.key=P.ESC+"[23~";break;case 123:o?n.key=P.ESC+"[24;"+(o+1)+"~":n.key=P.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?n.key=P.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=P.DEL:e.keyCode===219?n.key=P.ESC:e.keyCode===220?n.key=P.FS:e.keyCode===221&&(n.key=P.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=w_[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)n.key=P.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),n.key=P.ESC+c}else if(e.keyCode===32)n.key=P.ESC+(e.ctrlKey?P.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=P.ESC+h,n.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(n.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?n.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(n.key=P.US),e.key==="@"&&(n.key=P.NUL));break}return n}var ke=0,k_=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ar,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ar,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[n]=e[t],t++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ke=this._search(t),ke===-1)||this._getKey(this._array[ke])!==t)return!1;do if(this._array[ke]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ke),!0;while(++ke<this._array.length&&this._getKey(this._array[ke])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do yield this._array[ke];while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do t(this._array[ke]);while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Kr=0,yl=0,j_=class extends ne{constructor(){super(),this._decorations=new k_(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ve(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new N_(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,n=i+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,n=>{Kr=n.options.x??0,yl=Kr+(n.options.width??1),e>=Kr&&e<yl&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},N_=class extends Wt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ye.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ye.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},E_=1e3,D_=class{constructor(e,t=E_){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=i-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Sl=20,lr=class extends ne{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new D_(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
221
196
|
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Y(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ve(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Sl+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
222
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Sl+1&&(this._liveRegion.textContent+=un.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=t;n++){let o=s.lines.get(s.ydisp+n),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+n+1).toString(),c=this._rowElements[n];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],n=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(n===o||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,m=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let _=c<f.length?f[c]:f.slice(-1)[0]+1;return _>=this._terminal.cols&&(++m,_=0),{row:m,column:_}},o=n(t),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var n,o;e.style.transform="";let t=e.getBoundingClientRect().width,s=(o=(n=this._rowColumns.get(e))==null?void 0:n.slice(-1))==null?void 0:o[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};lr=we([H(1,po),H(2,jt),H(3,Et)],lr);var Vn=class extends ne{constructor(e,t,s,i,n){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ve(()=>{var o;os(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Y(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Y(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Y(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Y(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let n=s[i];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,n;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(n=this._activeProviderReplies)!=null&&n.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(m=>({link:m}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let n=t.get(i);if(n)for(let o=0;o<n.length;o++){let a=n[o],l=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){n.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(n=!0);if(!n&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(h=>this._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&T_(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,os(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,n,o;(i=this._currentLink)!=null&&i.state&&((o=(n=this._currentLink)==null?void 0:n.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(i,n),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=t.y*this._bufferService.cols+t.x;return s<=n&&n<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,n){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};Vn=we([H(1,go),H(2,Et),H(3,We),H(4,Wc)],Vn);function T_(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var z_=class extends j_{constructor(e={}){super(e),this._linkifier=this._register(new Ds),this.browser=lh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ds),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(P_),this._instantiationService.setService(_i,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(kg),this._instantiationService.setService(Wc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(mn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ve(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let n=xe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${P.ESC}]${i};${y_(n)}${oh.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=je.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=je.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(lr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(P.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(P.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Y(this.element,"copy",t=>{this.hasSelection()&&Im(t,this._selectionService)}));let e=t=>Fm(t,this.textarea,this.coreService,this.optionsService);this._register(Y(this.textarea,"paste",e)),this._register(Y(this.element,"paste",e)),ch?this._register(Y(this.element,"mousedown",t=>{t.button===2&&Ma(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Y(this.element,"contextmenu",t=>{Ma(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Co&&this._register(Y(this.element,"auxclick",t=>{t.button===1&&Bc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Y(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Y(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Y(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Y(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Y(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Y(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Y(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((n=this.element)==null?void 0:n.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Y(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",dn.get()),uh||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(wg,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(jt,this._coreBrowserService),this._register(Y(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Y(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Tn,this._document,this._helperContainer),this._instantiationService.setService(xr,this._charSizeService),this._themeService=this._instantiationService.createInstance($n),this._instantiationService.setService(Ps,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(nr),this._instantiationService.setService(Hc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(An,this.rows,this.screenElement)),this._instantiationService.setService(Et,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Mn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(zn),this._instantiationService.setService(go,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Vn,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Rn,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(On,this.element,this.screenElement,i)),this._instantiationService.setService(Ym,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Pn,this.screenElement)),this._register(Y(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(lr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(rr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(rr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Bn,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,m,f,_;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let p=o.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(o,(f=(m=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:m.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;h=p<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(t.addEventListener("mousemove",n.mousemove),i.mousemove=n.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),i.wheel=n.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Y(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(Y(t,"wheel",o=>{var a,l,h,c,u;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let m=P.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(m,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Lc(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=D_(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===P.ETX||s.key===P.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(A_(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ne));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(P.ESC+"[I"):this.coreService.triggerDataEvent(P.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${P.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${P.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function A_(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var O_=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},$_=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new rt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},wl=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new $_(t)}getNullCell(){return new rt}},I_=class extends ne{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new wl(this._core.buffers.normal,"normal"),this._alternate=new wl(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},F_=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},H_=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},W_=["cols","rows"],ht=0,U_=class extends ne{constructor(e){super(),this._core=this._register(new z_(e)),this._addonManager=this._register(new O_),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,n)=>{this._checkReadonlyOptions(i),this._core.options[i]=n};for(let i in this._core.options){let n={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,n)}}_checkReadonlyOptions(e){if(W_.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new F_(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new H_(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new I_(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
197
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Sl+1&&(this._liveRegion.textContent+=un.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=t;n++){let o=s.lines.get(s.ydisp+n),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+n+1).toString(),c=this._rowElements[n];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],n=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(n===o||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:h,offset:c})=>{let u=h instanceof Text?h.parentNode:h,m=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let _=c<f.length?f[c]:f.slice(-1)[0]+1;return _>=this._terminal.cols&&(++m,_=0),{row:m,column:_}},o=n(t),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var n,o;e.style.transform="";let t=e.getBoundingClientRect().width,s=(o=(n=this._rowColumns.get(e))==null?void 0:n.slice(-1))==null?void 0:o[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};lr=we([H(1,po),H(2,Nt),H(3,Et)],lr);var Vn=class extends ne{constructor(e,t,s,i,n){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ve(()=>{var o;os(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Y(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Y(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Y(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Y(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let n=s[i];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,n;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(n=this._activeProviderReplies)!=null&&n.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,u;if(this._isMouseOut)return;let h=l==null?void 0:l.map(m=>({link:m}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((u=this._activeProviderReplies)==null?void 0:u.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let n=t.get(i);if(n)for(let o=0;o<n.length;o++){let a=n[o],l=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){n.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(n=!0);if(!n&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(h=>this._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&R_(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,os(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,n,o;(i=this._currentLink)!=null&&i.state&&((o=(n=this._currentLink)==null?void 0:n.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(i,n),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=t.y*this._bufferService.cols+t.x;return s<=n&&n<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,n){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};Vn=we([H(1,go),H(2,Et),H(3,We),H(4,Wc)],Vn);function R_(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var P_=class extends S_{constructor(e={}){super(e),this._linkifier=this._register(new Ds),this.browser=lh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Ds),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(j_),this._instantiationService.setService(_i,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(bg),this._instantiationService.setService(Wc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(mn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ve(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let n=xe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${P.ESC}]${i};${g_(n)}${oh.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ne.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=Ne.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(lr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(P.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(P.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Y(this.element,"copy",t=>{this.hasSelection()&&Tm(t,this._selectionService)}));let e=t=>zm(t,this.textarea,this.coreService,this.optionsService);this._register(Y(this.textarea,"paste",e)),this._register(Y(this.element,"paste",e)),ch?this._register(Y(this.element,"mousedown",t=>{t.button===2&&Ma(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Y(this.element,"contextmenu",t=>{Ma(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Co&&this._register(Y(this.element,"auxclick",t=>{t.button===1&&Bc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Y(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Y(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Y(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Y(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Y(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Y(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Y(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((n=this.element)==null?void 0:n.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Y(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",dn.get()),uh||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(xg,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Nt,this._coreBrowserService),this._register(Y(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Y(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Tn,this._document,this._helperContainer),this._instantiationService.setService(xr,this._charSizeService),this._themeService=this._instantiationService.createInstance($n),this._instantiationService.setService(Ps,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(nr),this._instantiationService.setService(Hc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(An,this.rows,this.screenElement)),this._instantiationService.setService(Et,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Mn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(zn),this._instantiationService.setService(go,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Vn,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Rn,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(On,this.element,this.screenElement,i)),this._instantiationService.setService(Um,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Pn,this.screenElement)),this._register(Y(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(lr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(rr,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(rr,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Bn,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,u,m,f,_;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let p=o.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(o,(f=(m=(u=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:u.device)==null?void 0:m.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return!1;h=p<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(t.addEventListener("mousemove",n.mousemove),i.mousemove=n.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),i.wheel=n.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Y(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(Y(t,"wheel",o=>{var a,l,h,c,u;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(o,!0);let m=P.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(m,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Lc(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=C_(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===P.ETX||s.key===P.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(M_(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(je));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(P.ESC+"[I"):this.coreService.triggerDataEvent(P.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${P.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${P.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function M_(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var L_=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},B_=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new rt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},wl=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new B_(t)}getNullCell(){return new rt}},T_=class extends ne{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new wl(this._core.buffers.normal,"normal"),this._alternate=new wl(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},z_=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},A_=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},O_=["cols","rows"],ht=0,$_=class extends ne{constructor(e){super(),this._core=this._register(new P_(e)),this._addonManager=this._register(new L_),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,n)=>{this._checkReadonlyOptions(i),this._core.options[i]=n};for(let i in this._core.options){let n={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,n)}}_checkReadonlyOptions(e){if(O_.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new z_(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new A_(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new T_(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
223
198
|
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return dn.get()},set promptLabel(e){dn.set(e)},get tooMuchOutput(){return un.get()},set tooMuchOutput(e){un.set(e)}}}_verifyIntegers(...e){for(ht of e)if(ht===1/0||isNaN(ht)||ht%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ht of e)if(ht&&(ht===1/0||isNaN(ht)||ht%1!==0||ht<0))throw new Error("This API only accepts positive integers")}};/**
|
|
224
199
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
225
200
|
* @license MIT
|
|
@@ -231,7 +206,7 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
231
206
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
232
207
|
* http://bellard.org/jslinux/
|
|
233
208
|
* Copyright (c) 2011 Fabrice Bellard
|
|
234
|
-
*/var
|
|
209
|
+
*/var I_=2,F_=1,H_=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,u=n-h-t;return{cols:Math.max(I_,Math.floor(u/e.css.cell.width)),rows:Math.max(F_,Math.floor(c/e.css.cell.height))}}};/**
|
|
235
210
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
236
211
|
* @license MIT
|
|
237
212
|
*
|
|
@@ -242,41 +217,41 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
242
217
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
243
218
|
* http://bellard.org/jslinux/
|
|
244
219
|
* Copyright (c) 2011 Fabrice Bellard
|
|
245
|
-
*/var
|
|
220
|
+
*/var W_=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=K_.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(s))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(s,i)=>{if(this._options.hover){let{range:n}=t;this._options.hover(s,i,n)}},t))}};function U_(e){try{let t=new URL(e),s=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var K_=class Xi{static computeLink(t,s,i,n){let o=new RegExp(s.source,(s.flags||"")+"g"),[a,l]=Xi._getWindowedLineStrings(t-1,i),h=a.join(""),c,u=[];for(;c=o.exec(h);){let m=c[0];if(!U_(m))continue;let[f,_]=Xi._mapStrIdx(i,l,0,c.index),[p,g]=Xi._mapStrIdx(i,f,_,m.length);if(f===-1||_===-1||p===-1||g===-1)continue;let v={start:{x:_+1,y:f+1},end:{x:g,y:p+1}};u.push({range:v,text:m,activate:n})}return u}static _getWindowedLineStrings(t,s){let i,n=t,o=t,a=0,l="",h=[];if(i=s.buffer.active.getLine(t)){let c=i.translateToString(!0);if(i.isWrapped&&c[0]!==" "){for(a=0;(i=s.buffer.active.getLine(--n))&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),!(!i.isWrapped||l.indexOf(" ")!==-1)););h.reverse()}for(h.push(c),a=0;(i=s.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),l.indexOf(" ")===-1););}return[h,n]}static _mapStrIdx(t,s,i,n){let o=t.buffer.active,a=o.getNullCell(),l=i;for(;n;){let h=o.getLine(s);if(!h)return[-1,-1];for(let c=l;c<h.length;++c){h.getCell(c,a);let u=a.getChars();if(a.getWidth()&&(n-=u.length||1,c===h.length-1&&u==="")){let m=o.getLine(s+1);m&&m.isWrapped&&(m.getCell(0,a),a.getWidth()===2&&(n+=1))}if(n<0)return[s,c]}s++,l=0}return[s,l]}},q_=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function V_(e,t){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var G_=class{constructor(e=V_,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,s=t.urlRegex||q_;this._linkProvider=this._terminal.registerLinkProvider(new W_(this._terminal,s,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const Cl=10,Y_=1e3,X_=3e4;function J_({sessionId:e,isActive:t}){const s=d.useRef(null),i=d.useRef(null),n=d.useRef(null),o=d.useRef(null),a=d.useRef(null),l=d.useRef(!0),h=d.useRef(0),c=d.useCallback(()=>{const m=o.current,f=i.current;m&&m.readyState===WebSocket.OPEN&&f&&m.send(JSON.stringify({type:"resize",cols:f.cols,rows:f.rows}))},[]),u=d.useCallback(()=>{if(!l.current)return;o.current&&(o.current.onclose=null,o.current.onerror=null,o.current.close(),o.current=null);const f=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${Zr}/ws/terminal/${e}`,_=new WebSocket(f);o.current=_,_.onopen=()=>{h.current=0;const p=i.current;p&&p.writeln("\x1B[32m-- Terminal connected --\x1B[0m");const g=n.current;if(g&&p){try{g.fit()}catch{}c()}},_.onmessage=p=>{try{const g=JSON.parse(p.data);g.type==="output"&&i.current?i.current.write(g.data):g.type==="error"&&i.current&&i.current.writeln(`\x1B[31m${g.data}\x1B[0m`)}catch{i.current&&i.current.write(p.data)}},_.onclose=p=>{if(!l.current)return;const g=i.current;if(p.code===4e3){g&&g.writeln(`\r
|
|
246
221
|
\x1B[31m-- Terminal unavailable: `+(p.reason||"server rejected connection")+". --\x1B[0m");return}const v=h.current;if(v>=Cl){g&&g.writeln(`\r
|
|
247
|
-
\x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(
|
|
248
|
-
\x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${v+1}/${Cl})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&u()},y)},_.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const m=s.current;if(!m)return;const f=new U_({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),_=new V_,p=new Q_;f.loadAddon(_),f.loadAddon(p),f.open(m),i.current=f,n.current=_;try{_.fit()}catch{}f.onData(y=>{const x=o.current;x&&x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:y}))}),u();let g=null;const v=new ResizeObserver(()=>{g&&clearTimeout(g),g=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return v.observe(m),()=>{l.current=!1,v.disconnect(),g&&clearTimeout(g),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),f.dispose(),i.current=null,n.current=null}},[u,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const m=setTimeout(()=>{var f;try{(f=n.current)==null||f.fit(),c()}catch{}},50);return()=>clearTimeout(m)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const kl={file_created:{icon:fr,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:Z,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:Zl,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:kt,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:er,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:er,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:ql,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:es,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:$t,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:$t,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Ot,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:Kl,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function Nl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function ix({event:e,isLast:t,onFileClick:s}){const i=kl[e.type]||kl.info,n=i.icon,o=e.type==="narration";return r.jsxs("div",{className:"flex gap-3 group",children:[r.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:r.jsx(n,{size:14,className:i.labelColor})}),!t&&r.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),r.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:o?r.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[r.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),r.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&r.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),r.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[r.jsx(nt,{size:10}),Nl(e.timestamp)]})]}):r.jsxs("div",{className:"mt-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&r.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),r.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[r.jsx(nt,{size:10}),Nl(e.timestamp)]})]})})]})}const qr=20,jl=10;function rx({events:e,onFileClick:t,maxHeight:s}){const i=d.useRef(null),[n,o]=d.useState(!0);if(d.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),d.useEffect(()=>{e.length>qr},[e.length,n]),e.length===0)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[r.jsx(Ul,{size:28,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>qr&&n,l=a?e.slice(-jl):e,h=a?e.length-jl:0;return r.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&r.jsxs("button",{onClick:()=>o(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(dr,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>qr&&r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(ls,{size:12}),"Collapse older events"]}),l.map((c,u)=>r.jsx(ix,{event:c,isLast:u===l.length-1,onFileClick:t},c.id))]})}const El=[{id:"terminal",label:"Terminal",icon:es,alwaysShow:!0},{id:"activity",label:"Activity",icon:Md,alwaysShow:!0},{id:"build",label:"Build Log",icon:ju},{id:"agents",label:"Agents",icon:Ld},{id:"quality",label:"Quality",icon:Vl}];function nx({status:e}){switch(e){case"pass":return r.jsx(Ut,{size:14,className:"text-success"});case"fail":return r.jsx(ft,{size:14,className:"text-danger"});default:return r.jsx(nt,{size:14,className:"text-muted"})}}function ox({agents:e}){return!e||e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(_d,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):r.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[r.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),r.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),r.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),r.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function ax({checklist:e}){return!e||!e.items||e.items.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(Vl,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):r.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[r.jsx("span",{children:"Gate"}),r.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[r.jsx(nx,{status:t.status}),r.jsx("span",{className:"text-ink",children:t.label}),t.details&&r.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function lx({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var g;const[c,u]=d.useState("terminal"),m=s&&s.length>0,f=i&&i.items&&i.items.length>0,_=e&&e.length>0,p=El.filter(v=>!!(v.alwaysShow||v.id==="build"&&(_||o)||v.id==="agents"&&(m||o)||v.id==="quality"&&(f||o)));return p.find(v=>v.id===c)||u("terminal"),r.jsxs("div",{className:"h-full flex flex-col bg-card",children:[r.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:p.map(v=>{const y=v.icon,x=c===v.id;return r.jsxs("button",{role:"tab","aria-selected":x,onClick:()=>u(v.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${x?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),v.label,v.id==="agents"&&m&&r.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),v.id==="quality"&&f&&r.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},v.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(g=El.find(v=>v.id===c))==null?void 0:g.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:c==="terminal"?"visible":"hidden",zIndex:c==="terminal"?1:0},children:r.jsx(sx,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Dd,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(ox,{agents:s}),c==="activity"&&r.jsx(rx,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(ax,{checklist:i})]})]})}const Dl={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Setting things up...","Installing dependencies...","Compiling your project...","Running the build pipeline...","Finishing touches..."],deploy:["Preparing containers...","Pushing to the cloud...","Configuring services...","Running health checks...","Almost live..."],general:["Loading...","Getting things ready...","Just a moment...","Fetching data...","Almost there..."]};function cx({context:e="general",className:t=""}){const s=Dl[e]||Dl.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{const l=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(l)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(mi,{size:14,className:"animate-spin text-primary/60"}),r.jsx("span",{className:`text-xs text-muted transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:s[i]})]})}const Vr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:Jd},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Bd},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ri},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:ts},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:kt}];function hx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(0),[h,c]=d.useState(e),[u,m]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{l(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){m(!0);const x=setTimeout(()=>{c(e),m(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const f=Vr.findIndex(x=>x.id===e),_=s>0?Math.min(t/s*100,100):0,p=t>0?a/t:60,g=Math.max(0,s-t),v=Math.ceil(p*g),y=x=>x<60?`${x}s`:`${Math.floor(x/60)}m ${x%60}s`;return r.jsxs("div",{className:"flex-shrink-0 build-progress-container",children:[r.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal build-progress-bar",style:{width:`${_}%`}}),o&&r.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),r.jsxs("div",{className:`px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs ${u?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:Vr.map((x,k)=>{const N=k<f,w=k===f,D=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${w?"phase-indicator-active":""} ${N?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${w?"phase-icon-active":""} ${N?"phase-icon-complete":""}`,children:N?r.jsx(kt,{size:14,className:"text-success phase-check-enter"}):w?r.jsx(D,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(D,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${w?"text-ink":N?"text-success":"text-muted/50"}`,children:x.label}),k<Vr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${N?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(cx,{context:"build"}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Zt,{size:12}),"Iter ",t,"/",s]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(nt,{size:12}),y(a),o&&v>0&&r.jsxs("span",{className:"text-muted/60",children:["(",y(v)," left)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ql,{size:12}),"$",i.toFixed(2)]})]})]})]})}const Gr=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites with global CDN.",initial:"V",color:"text-ink",bgColor:"bg-ink/10",borderColor:"border-ink/20",tokenUrl:"https://vercel.com/account/tokens",tokenUrlLabel:"Get your token from vercel.com/account/tokens",hasTokenAuth:!0},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling.",initial:"N",color:"text-teal-600",bgColor:"bg-teal-500/10",borderColor:"border-teal-500/20",tokenUrl:"https://app.netlify.com/user/applications#personal-access-tokens",tokenUrlLabel:"Get your token from app.netlify.com/user/applications",hasTokenAuth:!0},{id:"github",name:"GitHub",description:"Free hosting for static sites directly from a GitHub repository.",initial:"G",color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/20",tokenUrl:"https://cli.github.com/",tokenUrlLabel:"Install GitHub CLI",hasTokenAuth:!1}];function dx({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){o(!0),l(null);try{await t(s.trim()),i("")}catch(u){l(u instanceof Error?u.message:"Connection failed")}finally{o(!1)}}},[s,t]);return r.jsxs("form",{onSubmit:h,className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsxs("label",{htmlFor:`token-${e.id}`,className:"sr-only",children:[e.name," Token"]}),r.jsx("input",{id:`token-${e.id}`,type:"password",value:s,onChange:c=>i(c.target.value),placeholder:`${e.name} access token`,disabled:n,className:`w-full px-3 py-2 text-sm border border-border rounded-lg bg-card text-ink
|
|
222
|
+
\x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(Y_*Math.pow(2,v),X_);h.current=v+1,g&&g.writeln(`\r
|
|
223
|
+
\x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${v+1}/${Cl})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&u()},y)},_.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const m=s.current;if(!m)return;const f=new $_({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),_=new H_,p=new G_;f.loadAddon(_),f.loadAddon(p),f.open(m),i.current=f,n.current=_;try{_.fit()}catch{}f.onData(y=>{const x=o.current;x&&x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"input",data:y}))}),u();let g=null;const v=new ResizeObserver(()=>{g&&clearTimeout(g),g=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return v.observe(m),()=>{l.current=!1,v.disconnect(),g&&clearTimeout(g),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),f.dispose(),i.current=null,n.current=null}},[u,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const m=setTimeout(()=>{var f;try{(f=n.current)==null||f.fit(),c()}catch{}},50);return()=>clearTimeout(m)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const kl={file_created:{icon:fr,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:Z,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:Zl,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:kt,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:er,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:er,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:ql,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:es,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:$t,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:$t,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Ot,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:Kl,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function jl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function Z_({event:e,isLast:t,onFileClick:s}){const i=kl[e.type]||kl.info,n=i.icon,o=e.type==="narration";return r.jsxs("div",{className:"flex gap-3 group",children:[r.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:r.jsx(n,{size:14,className:i.labelColor})}),!t&&r.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),r.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:o?r.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[r.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),r.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&r.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),r.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[r.jsx(nt,{size:10}),jl(e.timestamp)]})]}):r.jsxs("div",{className:"mt-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&r.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),r.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[r.jsx(nt,{size:10}),jl(e.timestamp)]})]})})]})}const qr=20,Nl=10;function Q_({events:e,onFileClick:t,maxHeight:s}){const i=d.useRef(null),[n,o]=d.useState(!0);if(d.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),d.useEffect(()=>{e.length>qr},[e.length,n]),e.length===0)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[r.jsx(Ul,{size:28,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>qr&&n,l=a?e.slice(-Nl):e,h=a?e.length-Nl:0;return r.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&r.jsxs("button",{onClick:()=>o(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(dr,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>qr&&r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(ls,{size:12}),"Collapse older events"]}),l.map((c,u)=>r.jsx(Z_,{event:c,isLast:u===l.length-1,onFileClick:t},c.id))]})}const El=[{id:"terminal",label:"Terminal",icon:es,alwaysShow:!0},{id:"activity",label:"Activity",icon:Md,alwaysShow:!0},{id:"build",label:"Build Log",icon:Cu},{id:"agents",label:"Agents",icon:Ld},{id:"quality",label:"Quality",icon:Vl}];function ex({status:e}){switch(e){case"pass":return r.jsx(Ut,{size:14,className:"text-success"});case"fail":return r.jsx(ft,{size:14,className:"text-danger"});default:return r.jsx(nt,{size:14,className:"text-muted"})}}function tx({agents:e}){return!e||e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(_d,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):r.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[r.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),r.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),r.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),r.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function sx({checklist:e}){return!e||!e.items||e.items.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(Vl,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):r.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[r.jsx("span",{children:"Gate"}),r.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[r.jsx(ex,{status:t.status}),r.jsx("span",{className:"text-ink",children:t.label}),t.details&&r.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function ix({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var g;const[c,u]=d.useState("terminal"),m=s&&s.length>0,f=i&&i.items&&i.items.length>0,_=e&&e.length>0,p=El.filter(v=>!!(v.alwaysShow||v.id==="build"&&(_||o)||v.id==="agents"&&(m||o)||v.id==="quality"&&(f||o)));return p.find(v=>v.id===c)||u("terminal"),r.jsxs("div",{className:"h-full flex flex-col bg-card",children:[r.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:p.map(v=>{const y=v.icon,x=c===v.id;return r.jsxs("button",{role:"tab","aria-selected":x,onClick:()=>u(v.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${x?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),v.label,v.id==="agents"&&m&&r.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),v.id==="quality"&&f&&r.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},v.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(g=El.find(v=>v.id===c))==null?void 0:g.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:c==="terminal"?"visible":"hidden",zIndex:c==="terminal"?1:0},children:r.jsx(J_,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Rd,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(tx,{agents:s}),c==="activity"&&r.jsx(Q_,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(sx,{checklist:i})]})]})}const Dl={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Setting things up...","Installing dependencies...","Compiling your project...","Running the build pipeline...","Finishing touches..."],deploy:["Preparing containers...","Pushing to the cloud...","Configuring services...","Running health checks...","Almost live..."],general:["Loading...","Getting things ready...","Just a moment...","Fetching data...","Almost there..."]};function rx({context:e="general",className:t=""}){const s=Dl[e]||Dl.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{const l=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(l)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(mi,{size:14,className:"animate-spin text-primary/60"}),r.jsx("span",{className:`text-xs text-muted transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:s[i]})]})}const Vr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:Jd},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Bd},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ri},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:ts},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:kt}];function nx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(0),[h,c]=d.useState(e),[u,m]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{l(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){m(!0);const x=setTimeout(()=>{c(e),m(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const f=Vr.findIndex(x=>x.id===e),_=s>0?Math.min(t/s*100,100):0,p=t>0?a/t:60,g=Math.max(0,s-t),v=Math.ceil(p*g),y=x=>x<60?`${x}s`:`${Math.floor(x/60)}m ${x%60}s`;return r.jsxs("div",{className:"flex-shrink-0 build-progress-container",children:[r.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal build-progress-bar",style:{width:`${_}%`}}),o&&r.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),r.jsxs("div",{className:`px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs ${u?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:Vr.map((x,k)=>{const j=k<f,w=k===f,D=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${w?"phase-indicator-active":""} ${j?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${w?"phase-icon-active":""} ${j?"phase-icon-complete":""}`,children:j?r.jsx(kt,{size:14,className:"text-success phase-check-enter"}):w?r.jsx(D,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(D,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${w?"text-ink":j?"text-success":"text-muted/50"}`,children:x.label}),k<Vr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${j?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(rx,{context:"build"}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Zt,{size:12}),"Iter ",t,"/",s]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(nt,{size:12}),y(a),o&&v>0&&r.jsxs("span",{className:"text-muted/60",children:["(",y(v)," left)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ql,{size:12}),"$",i.toFixed(2)]})]})]})]})}const Gr=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites with global CDN.",initial:"V",color:"text-ink",bgColor:"bg-ink/10",borderColor:"border-ink/20",tokenUrl:"https://vercel.com/account/tokens",tokenUrlLabel:"Get your token from vercel.com/account/tokens",hasTokenAuth:!0},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling.",initial:"N",color:"text-teal-600",bgColor:"bg-teal-500/10",borderColor:"border-teal-500/20",tokenUrl:"https://app.netlify.com/user/applications#personal-access-tokens",tokenUrlLabel:"Get your token from app.netlify.com/user/applications",hasTokenAuth:!0},{id:"github",name:"GitHub",description:"Free hosting for static sites directly from a GitHub repository.",initial:"G",color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/20",tokenUrl:"https://cli.github.com/",tokenUrlLabel:"Install GitHub CLI",hasTokenAuth:!1}];function ox({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){o(!0),l(null);try{await t(s.trim()),i("")}catch(u){l(u instanceof Error?u.message:"Connection failed")}finally{o(!1)}}},[s,t]);return r.jsxs("form",{onSubmit:h,className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsxs("label",{htmlFor:`token-${e.id}`,className:"sr-only",children:[e.name," Token"]}),r.jsx("input",{id:`token-${e.id}`,type:"password",value:s,onChange:c=>i(c.target.value),placeholder:`${e.name} access token`,disabled:n,className:`w-full px-3 py-2 text-sm border border-border rounded-lg bg-card text-ink
|
|
249
224
|
focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary
|
|
250
|
-
placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(ss,{size:10})]}),r.jsx(he,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(Rs,{size:12}),a]})]})}function ux(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(es,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(ss,{size:10})]})]})}function fx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async u=>{await s(u),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(he,{variant:"danger",size:"sm",icon:Hu,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsx(r.Fragment,{children:e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsxs(he,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:["Connect ",e.name]})}),n&&r.jsx(dx,{platform:e,onConnect:c})]}):r.jsx(ux,{})})]})}function mx({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const p=await W.getDeployStatus();i(p),t==null||t(p),l(null)}catch(p){l(p instanceof Error?p.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const p=setInterval(h,3e4);return()=>clearInterval(p)},[h]);const c=d.useCallback(async p=>{const g=await W.connectVercel(p);g.success&&(i(v=>({...v,vercel:{connected:!0,user:g.user}})),t==null||t({...s,vercel:{connected:!0,user:g.user}}))},[s,t]),u=d.useCallback(async p=>{const g=await W.connectNetlify(p);g.success&&(i(v=>({...v,netlify:{connected:!0,user:g.user}})),t==null||t({...s,netlify:{connected:!0,user:g.user}}))},[s,t]),m=d.useCallback(async p=>{await W.disconnectPlatform(p),i(v=>({...v,[p]:{connected:!1}}));const g={...s,[p]:{connected:!1}};t==null||t(g)},[s,t]),f={vercel:c,netlify:u,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(mi,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const _=[s.vercel,s.netlify,s.github].filter(p=>p.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[_," of ",Gr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(gt,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Gr.map(p=>{const g=s[p.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${p.name}: ${g.connected?`Connected as ${g.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${g.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:p.name})]},p.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(gt,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(Rs,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Gr.map(p=>r.jsx(fx,{platform:p,status:s[p.id],onConnect:f[p.id],onDisconnect:()=>m(p.id)},p.id))})]})}const px=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:en,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:en,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:ze,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function gx({platform:e,deployState:t,onDeploy:s,disabled:i,connected:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=i||!n;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n?"hover:border-primary/30 hover:bg-hover":"opacity-60"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${n?"bg-green-500":"bg-gray-300"}`,title:n?"Connected":"Not connected"})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(he,{variant:"secondary",size:"sm",icon:$t,onClick:s,disabled:c,className:"w-full",children:["Deploy to ",e.name]}),!n&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(mi,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(en,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Ut,{size:12,className:"text-green-500"}):r.jsx(Qn,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(ss,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Rs,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(he,{variant:"secondary",size:"sm",icon:$t,onClick:s,disabled:c,className:"w-full",children:"Retry"})]})]})}function _x({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await W.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(ze,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(he,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(mi,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(ze,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Ut,{size:12,className:"text-green-500"}):r.jsx(Qn,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Rs,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(he,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function xx({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[o,a]=d.useState(!1),l=Object.values(t).some(u=>u.status==="deploying"),h=d.useCallback(async u=>{s(m=>({...m,[u]:{status:"deploying"}}));try{const m=await W.deployProject(e,u);m.url?s(f=>({...f,[u]:{status:"success",url:m.url}})):s(f=>({...f,[u]:{status:"error",error:m.error||"Deploy failed"}}))}catch(m){s(f=>({...f,[u]:{status:"error",error:m instanceof Error?m.message:"Deploy failed"}}))}},[e]),c=u=>{var m;return((m=i[u.connectionKey])==null?void 0:m.connected)??!1};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx($t,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(!o),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ac,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:["vercel","netlify","github"].map(u=>{var m,f;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(m=i[u])!=null&&m.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(f=i[u])!=null&&f.connected?"Connected":"Not connected"}`},u)})})]}),r.jsx("span",{className:"text-xs text-muted",children:o?"Hide":"Manage"})]}),o&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(mx,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:px.map(u=>r.jsx(gx,{platform:u,deployState:t[u.id],onDeploy:()=>h(u.id),disabled:l,connected:c(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(_x,{sessionId:e,disabled:l})]})})}const Sh=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),wt=Sh?"Cmd":"Ctrl",Rl=[{keys:[`${wt}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${wt}+P`],label:"Quick open file",category:"navigation"},{keys:[`${wt}+,`],label:"Open settings",category:"navigation"},{keys:[`${wt}+S`],label:"Save file",category:"editor"},{keys:[`${wt}+Z`],label:"Undo",category:"editor"},{keys:[`${wt}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${wt}+B`],label:"Start / stop build",category:"build"},{keys:[`${wt}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${wt}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],vx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},bx=["navigation","editor","build","general"];function yx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,u;const a=Sh?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((u=o.target)==null?void 0:u.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(m=>!m);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(m=>!m);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function Sx({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Rl;const a=s.toLowerCase();return Rl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(xd,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(ft,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(ts,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[bx.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:vx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Escape"})," to close"]})})]})}):null}function wx({onClick:e}){return r.jsx("button",{onClick:e,title:"Keyboard shortcuts",className:"inline-flex items-center justify-center w-7 h-7 rounded-btn text-muted hover:text-ink hover:bg-hover transition-colors text-xs font-bold",children:"?"})}const wh="pl_recent_commands",Cx=5;function Ch(){try{const e=localStorage.getItem(wh);return e?JSON.parse(e):[]}catch{return[]}}function Yr(e){try{const t=Ch().filter(s=>s!==e);t.unshift(e),localStorage.setItem(wh,JSON.stringify(t.slice(0,Cx)))}catch{}}function kx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:Z,ts:Z,tsx:Z,jsx:Z,py:Z,go:Z,rs:Z,rb:Z,sh:Z,html:nc,css:so,json:to,md:fi}[t]||io}function Nx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Pl({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function jx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,u]=d.useState([]),[m,f]=d.useState(!1),_=d.useRef(null),p=d.useRef(null),g=vd(e);bd(e,t),d.useEffect(()=>{e&&(a(""),h(0),u([]),f(!1),setTimeout(()=>{var S;return(S=_.current)==null?void 0:S.focus()},50))},[e]);const v=d.useMemo(()=>Ch().map(j=>s.find(C=>C.id===j)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(j=>({cmd:j,indices:[]}));const S=[];for(const j of s){const C=Nx(o,j.label);if(C){const B=C[0]*10+(C[C.length-1]-C[0]);S.push({cmd:j,indices:C,score:B})}}return S.sort((j,C)=>j.score-C.score),S.map(j=>({cmd:j.cmd,indices:j.indices}))},[s,o]),x=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),k=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){u([]),f(!1);return}return f(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(async()=>{try{const S=await W.searchFiles(i,o);u(S.filter(j=>j.type==="file"))}catch{u([])}f(!1)},200),()=>{p.current&&clearTimeout(p.current)}},[o,i]);const N=!o.trim()&&v.length>0,w=d.useMemo(()=>{const S=[];return N&&v.forEach((j,C)=>S.push({type:"recent",index:C})),k.forEach((j,C)=>S.push({type:"command",index:C})),x.length>0&&x.forEach((j,C)=>S.push({type:"setting",index:C})),c.forEach((j,C)=>S.push({type:"file",index:C})),S},[N,v,k,x,c]),D=w.length;d.useEffect(()=>{h(0)},[o]);const T=d.useCallback(S=>{const j=w[S];if(j){if(j.type==="recent"){const C=v[j.index];C&&(Yr(C.id),C.action(),t())}else if(j.type==="command"){const C=k[j.index];C&&(Yr(C.cmd.id),C.cmd.action(),t())}else if(j.type==="setting"){const C=x[j.index];C&&(Yr(C.cmd.id),C.cmd.action(),t())}else if(j.type==="file"){const C=c[j.index];C&&n&&(n(C.path,C.name),t())}}},[w,v,k,x,c,n,t]),U=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(j=>Math.min(j+1,D-1))):S.key==="ArrowUp"?(S.preventDefault(),h(j=>Math.max(j-1,0))):S.key==="Enter"&&D>0?T(l):S.key==="Escape"&&t()},[D,l,T,t]);if(!e)return null;let G=0;const K=()=>G++,A=k.length>0,M=x.length>0,E=c.length>0,L=m&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:g,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(ts,{size:18,className:"text-muted"}),r.jsx("input",{ref:_,value:o,onChange:S=>a(S.target.value),onKeyDown:U,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[N&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(nt,{size:10})," Recent"]}),v.map((S,j)=>{const C=K(),B=S.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),A&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),k.map((S,j)=>{const C=K(),B=S.cmd.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Pl,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),M&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),x.map((S,j)=>{const C=K(),B=S.cmd.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Pl,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,j)=>{const C=K(),B=S.type==="directory"?ro:kx(S.name);return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),L&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),D===0&&!L&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const Ex=d.lazy(()=>Jn(()=>import("./GitHubIssuesPanel-5XLYWzWH.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32])).then(e=>({default:e.GitHubIssuesPanel}))),Dx=d.lazy(()=>Jn(()=>import("./GitHubPRsPanel-DUfmFYeu.js"),__vite__mapDeps([33,1,2,3,34,4,5,35,12,14,17,9,10,11,13,15,16,8,18,19,20,21,22,23,24,25,7,26,27,28,29,30,31,32])).then(e=>({default:e.GitHubPRsPanel}))),Rx=d.lazy(()=>Jn(()=>Promise.resolve().then(()=>Gx),void 0).then(e=>({default:e.CICDPanel}))),Px=3e4,Mx={modified:r.jsx(Z,{size:13,className:"text-yellow-500"}),added:r.jsx(fr,{size:13,className:"text-green-500"}),deleted:r.jsx(eo,{size:13,className:"text-red-400"}),renamed:r.jsx(Z,{size:13,className:"text-blue-400"}),untracked:r.jsx(oc,{size:13,className:"text-muted"})},Lx={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Bx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(ec,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(ze,{size:9}),t]},s))})]})]})})}function Ml({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Mx[e.status]||r.jsx(oc,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Lx[e.status]||"?"})]})}function Tx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,u]=d.useState(!0),[m,f]=d.useState(null),[_,p]=d.useState(""),[g,v]=d.useState(!1),[y,x]=d.useState(null),[k,N]=d.useState(!1),[w,D]=d.useState(""),[T,U]=d.useState(!1),[G,K]=d.useState(!1),[A,M]=d.useState(""),[E,L]=d.useState(""),[S,j]=d.useState(!1),[C,B]=d.useState(null),[X,oe]=d.useState(!1),q=d.useCallback(async()=>{u(!0),f(null);try{const[R,le,_e]=await Promise.all([W.git.status(e),W.git.log(e),W.git.branches(e)]);n(R),a(le),h(_e)}catch(R){f(R instanceof Error?R.message:"Failed to load git data")}u(!1)},[e]);d.useEffect(()=>{q()},[q]);const Q=async()=>{if(!(!_.trim()||g)){v(!0),x(null);try{const R=await W.git.commit(e,_.trim());x(`Committed: ${R.hash}`),p(""),await q()}catch(R){x(`Error: ${R instanceof Error?R.message:"Commit failed"}`)}v(!1)}},ie=async()=>{if(!(!w.trim()||T)){U(!0);try{await W.git.createBranch(e,w.trim()),D(""),N(!1),await q()}catch(R){f(R instanceof Error?R.message:"Branch creation failed")}U(!1)}},de=async R=>{try{await W.git.checkoutBranch(e,R),await q()}catch(le){f(le instanceof Error?le.message:"Checkout failed")}},ue=async()=>{oe(!0);try{await W.git.push(e),await q()}catch(R){f(R instanceof Error?R.message:"Push failed")}oe(!1)},z=async()=>{if(!(!A.trim()||S)){j(!0),B(null);try{const R=await W.git.pr(e,A.trim(),E.trim());B(R.url),M(""),L(""),K(!1)}catch(R){B(`Error: ${R instanceof Error?R.message:"PR creation failed"}`)}j(!1)}},V=(i==null?void 0:i.files.filter(R=>R.staged))||[],J=(i==null?void 0:i.files.filter(R=>!R.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(gt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):m&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(Rs,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:m}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(he,{size:"sm",variant:"secondary",icon:gt,onClick:q,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(ze,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Ut,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:q,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(gt,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:Z,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:nt},{id:"branches",label:"Branches",icon:ze,count:l.length}].map(R=>r.jsxs("button",{onClick:()=>s(R.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===R.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(R.icon,{size:12}),R.label,R.count!==void 0&&R.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:R.count})]},R.id))}),m&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:m}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Ut,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[V.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",V.length,")"]}),V.map((R,le)=>r.jsx(Ml,{file:R},`s-${le}`))]}),J.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",J.length,")"]}),J.map((R,le)=>r.jsx(Ml,{file:R},`u-${le}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:_,onChange:R=>p(R.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(he,{size:"sm",icon:ec,onClick:Q,disabled:!_.trim()||g,loading:g,children:"Commit"}),r.jsx(he,{size:"sm",variant:"secondary",icon:tc,onClick:ue,loading:X,disabled:X,children:"Push"}),r.jsx(he,{size:"sm",variant:"ghost",icon:rn,onClick:()=>K(!G),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),C&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:C.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:C}):r.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:C})})]}),G&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:A,onChange:R=>M(R.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:R=>L(R.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(he,{size:"sm",icon:rn,onClick:z,disabled:!A.trim()||S,loading:S,children:"Create PR"}),r.jsx(he,{size:"sm",variant:"ghost",onClick:()=>K(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(nt,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((R,le)=>r.jsx(Bx,{commit:R},le))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>N(!k),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(mr,{size:12}),"New Branch"]})}),k&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:R=>D(R.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:R=>{R.key==="Enter"&&ie()}}),r.jsx(he,{size:"sm",onClick:ie,disabled:!w.trim()||T,loading:T,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ze,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(R=>!R.remote).map((R,le)=>r.jsxs("button",{onClick:()=>!R.current&&de(R.name),disabled:R.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${R.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(ze,{size:13,className:R.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${R.current?"text-primary font-semibold":"text-ink"}`,children:R.name}),R.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${le}`)),l.filter(R=>R.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(R=>R.remote).map((R,le)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(ze,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:R.name})]},`r-${le}`))]})]})]})]})]})}function Xr(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(gt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function Jr({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await W.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(lu,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(he,{size:"sm",icon:tc,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function zx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({issues:0,prs:0,actions:0,fetchedAt:0}),c=d.useRef(!1),u=d.useCallback(async()=>{n(!0);try{const g=await W.getStatus();a({has_remote:!0,repo:"",owner:""})}catch{a({has_remote:!1})}n(!1)},[e]);d.useEffect(()=>{u()},[u]);const m=d.useCallback(async()=>{if(!(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<Px)&&!c.current){c.current=!0;try{const[v,y,x]=await Promise.allSettled([W.getGitHubIssues(e,"open",1),W.getGitHubPRs(e,"open",1),W.getWorkflowRuns(e,5)]);h({issues:v.status==="fulfilled"?v.value.length:0,prs:y.status==="fulfilled"?y.value.length:0,actions:x.status==="fulfilled"?x.value.filter(k=>k.status==="in_progress").length:0,fetchedAt:Date.now()})}catch{}c.current=!1}},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&m()},[o==null?void 0:o.has_remote,m]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&m()},[t,o==null?void 0:o.has_remote,m]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(gt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const f=(o==null?void 0:o.has_remote)??!1,_=[{id:"changes",label:"Changes",icon:Z,requiresRemote:!1},{id:"issues",label:"Issues",icon:Yd,count:l.issues,requiresRemote:!0},{id:"prs",label:"PRs",icon:rn,count:l.prs,requiresRemote:!0},{id:"actions",label:"Actions",icon:It,count:l.actions,requiresRemote:!0}],p=_;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[p.map(g=>{const v=g.requiresRemote&&!f;return r.jsxs("button",{onClick:()=>s(g.id),disabled:v,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===g.id?"bg-primary/10 text-primary":v?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:v?"Connect to GitHub to access this tab":void 0,children:[r.jsx(g.icon,{size:12}),g.label,g.count!==void 0&&g.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:g.count})]},g.id)}),f&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(ac,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Tx,{sessionId:e}),t==="issues"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Xr,{}),children:r.jsx(Ex,{sessionId:e})}):r.jsx(Jr,{sessionId:e,onPushed:u})),t==="prs"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Xr,{}),children:r.jsx(Dx,{sessionId:e})}):r.jsx(Jr,{sessionId:e,onPushed:u})),t==="actions"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Xr,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Rx,{sessionId:e})})}):r.jsx(Jr,{sessionId:e,onPushed:u}))]})]})}function Ax({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(null),f=d.useCallback(async()=>{try{const g=await W.getCheckpoints(e);i(g),m(null)}catch{m("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{f();const g=setInterval(f,15e3);return()=>clearInterval(g)},[f]);const _=d.useCallback(async g=>{if(a)return;const v=s.find(x=>x.id===g);if(!(!v||!window.confirm(`Restore to checkpoint "${v.description}"?
|
|
225
|
+
placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(ss,{size:10})]}),r.jsx(he,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(Rs,{size:12}),a]})]})}function ax(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(es,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(ss,{size:10})]})]})}function lx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async u=>{await s(u),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(he,{variant:"danger",size:"sm",icon:Au,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsx(r.Fragment,{children:e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsxs(he,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:["Connect ",e.name]})}),n&&r.jsx(ox,{platform:e,onConnect:c})]}):r.jsx(ax,{})})]})}function cx({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const p=await W.getDeployStatus();i(p),t==null||t(p),l(null)}catch(p){l(p instanceof Error?p.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const p=setInterval(h,3e4);return()=>clearInterval(p)},[h]);const c=d.useCallback(async p=>{const g=await W.connectVercel(p);g.success&&(i(v=>({...v,vercel:{connected:!0,user:g.user}})),t==null||t({...s,vercel:{connected:!0,user:g.user}}))},[s,t]),u=d.useCallback(async p=>{const g=await W.connectNetlify(p);g.success&&(i(v=>({...v,netlify:{connected:!0,user:g.user}})),t==null||t({...s,netlify:{connected:!0,user:g.user}}))},[s,t]),m=d.useCallback(async p=>{await W.disconnectPlatform(p),i(v=>({...v,[p]:{connected:!1}}));const g={...s,[p]:{connected:!1}};t==null||t(g)},[s,t]),f={vercel:c,netlify:u,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(mi,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const _=[s.vercel,s.netlify,s.github].filter(p=>p.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[_," of ",Gr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(gt,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Gr.map(p=>{const g=s[p.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${p.name}: ${g.connected?`Connected as ${g.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${g.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:p.name})]},p.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(gt,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(Rs,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Gr.map(p=>r.jsx(lx,{platform:p,status:s[p.id],onConnect:f[p.id],onDisconnect:()=>m(p.id)},p.id))})]})}const hx=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:en,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:en,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:ze,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function dx({platform:e,deployState:t,onDeploy:s,disabled:i,connected:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=i||!n;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n?"hover:border-primary/30 hover:bg-hover":"opacity-60"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${n?"bg-green-500":"bg-gray-300"}`,title:n?"Connected":"Not connected"})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(he,{variant:"secondary",size:"sm",icon:$t,onClick:s,disabled:c,className:"w-full",children:["Deploy to ",e.name]}),!n&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(mi,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(en,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Ut,{size:12,className:"text-green-500"}):r.jsx(Qn,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(ss,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Rs,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(he,{variant:"secondary",size:"sm",icon:$t,onClick:s,disabled:c,className:"w-full",children:"Retry"})]})]})}function ux({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await W.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(ze,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(he,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(mi,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(kt,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(ze,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Ut,{size:12,className:"text-green-500"}):r.jsx(Qn,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(Rs,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(he,{variant:"secondary",size:"sm",icon:ze,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function fx({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[o,a]=d.useState(!1),l=Object.values(t).some(u=>u.status==="deploying"),h=d.useCallback(async u=>{s(m=>({...m,[u]:{status:"deploying"}}));try{const m=await W.deployProject(e,u);m.url?s(f=>({...f,[u]:{status:"success",url:m.url}})):s(f=>({...f,[u]:{status:"error",error:m.error||"Deploy failed"}}))}catch(m){s(f=>({...f,[u]:{status:"error",error:m instanceof Error?m.message:"Deploy failed"}}))}},[e]),c=u=>{var m;return((m=i[u.connectionKey])==null?void 0:m.connected)??!1};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx($t,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>a(!o),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ac,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:["vercel","netlify","github"].map(u=>{var m,f;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(m=i[u])!=null&&m.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(f=i[u])!=null&&f.connected?"Connected":"Not connected"}`},u)})})]}),r.jsx("span",{className:"text-xs text-muted",children:o?"Hide":"Manage"})]}),o&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(cx,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:hx.map(u=>r.jsx(dx,{platform:u,deployState:t[u.id],onDeploy:()=>h(u.id),disabled:l,connected:c(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(ux,{sessionId:e,disabled:l})]})})}const Sh=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),wt=Sh?"Cmd":"Ctrl",Rl=[{keys:[`${wt}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${wt}+P`],label:"Quick open file",category:"navigation"},{keys:[`${wt}+,`],label:"Open settings",category:"navigation"},{keys:[`${wt}+S`],label:"Save file",category:"editor"},{keys:[`${wt}+Z`],label:"Undo",category:"editor"},{keys:[`${wt}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${wt}+B`],label:"Start / stop build",category:"build"},{keys:[`${wt}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${wt}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],mx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},px=["navigation","editor","build","general"];function gx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,u;const a=Sh?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((u=o.target)==null?void 0:u.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(m=>!m);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(m=>!m);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function _x({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Rl;const a=s.toLowerCase();return Rl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(xd,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(ft,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(ts,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[px.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:mx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Escape"})," to close"]})})]})}):null}function xx({onClick:e}){return r.jsx("button",{onClick:e,title:"Keyboard shortcuts",className:"inline-flex items-center justify-center w-7 h-7 rounded-btn text-muted hover:text-ink hover:bg-hover transition-colors text-xs font-bold",children:"?"})}const wh="pl_recent_commands",vx=5;function Ch(){try{const e=localStorage.getItem(wh);return e?JSON.parse(e):[]}catch{return[]}}function Yr(e){try{const t=Ch().filter(s=>s!==e);t.unshift(e),localStorage.setItem(wh,JSON.stringify(t.slice(0,vx)))}catch{}}function bx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:Z,ts:Z,tsx:Z,jsx:Z,py:Z,go:Z,rs:Z,rb:Z,sh:Z,html:oc,css:so,json:to,md:fi}[t]||io}function yx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Pl({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function Sx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,u]=d.useState([]),[m,f]=d.useState(!1),_=d.useRef(null),p=d.useRef(null),g=vd(e);bd(e,t),d.useEffect(()=>{e&&(a(""),h(0),u([]),f(!1),setTimeout(()=>{var S;return(S=_.current)==null?void 0:S.focus()},50))},[e]);const v=d.useMemo(()=>Ch().map(N=>s.find(C=>C.id===N)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(N=>({cmd:N,indices:[]}));const S=[];for(const N of s){const C=yx(o,N.label);if(C){const B=C[0]*10+(C[C.length-1]-C[0]);S.push({cmd:N,indices:C,score:B})}}return S.sort((N,C)=>N.score-C.score),S.map(N=>({cmd:N.cmd,indices:N.indices}))},[s,o]),x=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),k=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){u([]),f(!1);return}return f(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(async()=>{try{const S=await W.searchFiles(i,o);u(S.filter(N=>N.type==="file"))}catch{u([])}f(!1)},200),()=>{p.current&&clearTimeout(p.current)}},[o,i]);const j=!o.trim()&&v.length>0,w=d.useMemo(()=>{const S=[];return j&&v.forEach((N,C)=>S.push({type:"recent",index:C})),k.forEach((N,C)=>S.push({type:"command",index:C})),x.length>0&&x.forEach((N,C)=>S.push({type:"setting",index:C})),c.forEach((N,C)=>S.push({type:"file",index:C})),S},[j,v,k,x,c]),D=w.length;d.useEffect(()=>{h(0)},[o]);const T=d.useCallback(S=>{const N=w[S];if(N){if(N.type==="recent"){const C=v[N.index];C&&(Yr(C.id),C.action(),t())}else if(N.type==="command"){const C=k[N.index];C&&(Yr(C.cmd.id),C.cmd.action(),t())}else if(N.type==="setting"){const C=x[N.index];C&&(Yr(C.cmd.id),C.cmd.action(),t())}else if(N.type==="file"){const C=c[N.index];C&&n&&(n(C.path,C.name),t())}}},[w,v,k,x,c,n,t]),U=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(N=>Math.min(N+1,D-1))):S.key==="ArrowUp"?(S.preventDefault(),h(N=>Math.max(N-1,0))):S.key==="Enter"&&D>0?T(l):S.key==="Escape"&&t()},[D,l,T,t]);if(!e)return null;let G=0;const K=()=>G++,A=k.length>0,M=x.length>0,E=c.length>0,L=m&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:g,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(ts,{size:18,className:"text-muted"}),r.jsx("input",{ref:_,value:o,onChange:S=>a(S.target.value),onKeyDown:U,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[j&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(nt,{size:10})," Recent"]}),v.map((S,N)=>{const C=K(),B=S.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),A&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),k.map((S,N)=>{const C=K(),B=S.cmd.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Pl,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),M&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),x.map((S,N)=>{const C=K(),B=S.cmd.icon;return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Pl,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,N)=>{const C=K(),B=S.type==="directory"?ro:bx(S.name);return r.jsxs("button",{onClick:()=>T(C),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${C===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(B,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),L&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),D===0&&!L&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const wx=d.lazy(()=>Jn(()=>import("./GitHubIssuesPanel-CsXVKuyJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GitHubIssuesPanel}))),Cx=d.lazy(()=>Jn(()=>import("./GitHubPRsPanel-CYRp1eKS.js"),__vite__mapDeps([10,1,2,3,11,4,5,6,12,13,14,15,16,17,18,19,20,21,22,9,23,24,25,26,27,28,29,30,8,31,32,33,34,35,36,37,38])).then(e=>({default:e.GitHubPRsPanel}))),kx=d.lazy(()=>Jn(()=>Promise.resolve().then(()=>Wx),void 0).then(e=>({default:e.CICDPanel}))),jx=3e4,Nx={modified:r.jsx(Z,{size:13,className:"text-yellow-500"}),added:r.jsx(fr,{size:13,className:"text-green-500"}),deleted:r.jsx(eo,{size:13,className:"text-red-400"}),renamed:r.jsx(Z,{size:13,className:"text-blue-400"}),untracked:r.jsx(ec,{size:13,className:"text-muted"})},Ex={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Dx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(tc,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(ze,{size:9}),t]},s))})]})]})})}function Ml({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Nx[e.status]||r.jsx(ec,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Ex[e.status]||"?"})]})}function Rx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,u]=d.useState(!0),[m,f]=d.useState(null),[_,p]=d.useState(""),[g,v]=d.useState(!1),[y,x]=d.useState(null),[k,j]=d.useState(!1),[w,D]=d.useState(""),[T,U]=d.useState(!1),[G,K]=d.useState(!1),[A,M]=d.useState(""),[E,L]=d.useState(""),[S,N]=d.useState(!1),[C,B]=d.useState(null),[X,oe]=d.useState(!1),q=d.useCallback(async()=>{u(!0),f(null);try{const[R,ae,_e]=await Promise.all([W.git.status(e),W.git.log(e),W.git.branches(e)]);n(R),a(ae),h(_e)}catch(R){f(R instanceof Error?R.message:"Failed to load git data")}u(!1)},[e]);d.useEffect(()=>{q()},[q]);const Q=async()=>{if(!(!_.trim()||g)){v(!0),x(null);try{const R=await W.git.commit(e,_.trim());x(`Committed: ${R.hash}`),p(""),await q()}catch(R){x(`Error: ${R instanceof Error?R.message:"Commit failed"}`)}v(!1)}},ie=async()=>{if(!(!w.trim()||T)){U(!0);try{await W.git.createBranch(e,w.trim()),D(""),j(!1),await q()}catch(R){f(R instanceof Error?R.message:"Branch creation failed")}U(!1)}},de=async R=>{try{await W.git.checkoutBranch(e,R),await q()}catch(ae){f(ae instanceof Error?ae.message:"Checkout failed")}},ue=async()=>{oe(!0);try{await W.git.push(e),await q()}catch(R){f(R instanceof Error?R.message:"Push failed")}oe(!1)},z=async()=>{if(!(!A.trim()||S)){N(!0),B(null);try{const R=await W.git.pr(e,A.trim(),E.trim());B(R.url),M(""),L(""),K(!1)}catch(R){B(`Error: ${R instanceof Error?R.message:"PR creation failed"}`)}N(!1)}},V=(i==null?void 0:i.files.filter(R=>R.staged))||[],J=(i==null?void 0:i.files.filter(R=>!R.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(gt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):m&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(Rs,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:m}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(he,{size:"sm",variant:"secondary",icon:gt,onClick:q,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(ze,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Ut,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:q,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(gt,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:Z,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:nt},{id:"branches",label:"Branches",icon:ze,count:l.length}].map(R=>r.jsxs("button",{onClick:()=>s(R.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===R.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(R.icon,{size:12}),R.label,R.count!==void 0&&R.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:R.count})]},R.id))}),m&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:m}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Ut,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[V.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",V.length,")"]}),V.map((R,ae)=>r.jsx(Ml,{file:R},`s-${ae}`))]}),J.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",J.length,")"]}),J.map((R,ae)=>r.jsx(Ml,{file:R},`u-${ae}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:_,onChange:R=>p(R.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(he,{size:"sm",icon:tc,onClick:Q,disabled:!_.trim()||g,loading:g,children:"Commit"}),r.jsx(he,{size:"sm",variant:"secondary",icon:sc,onClick:ue,loading:X,disabled:X,children:"Push"}),r.jsx(he,{size:"sm",variant:"ghost",icon:tn,onClick:()=>K(!G),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),C&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:C.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:C}):r.jsx("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:C})})]}),G&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:A,onChange:R=>M(R.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:R=>L(R.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(he,{size:"sm",icon:tn,onClick:z,disabled:!A.trim()||S,loading:S,children:"Create PR"}),r.jsx(he,{size:"sm",variant:"ghost",onClick:()=>K(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(nt,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((R,ae)=>r.jsx(Dx,{commit:R},ae))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>j(!k),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(mr,{size:12}),"New Branch"]})}),k&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:R=>D(R.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:R=>{R.key==="Enter"&&ie()}}),r.jsx(he,{size:"sm",onClick:ie,disabled:!w.trim()||T,loading:T,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ze,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(R=>!R.remote).map((R,ae)=>r.jsxs("button",{onClick:()=>!R.current&&de(R.name),disabled:R.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${R.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(ze,{size:13,className:R.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${R.current?"text-primary font-semibold":"text-ink"}`,children:R.name}),R.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${ae}`)),l.filter(R=>R.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(R=>R.remote).map((R,ae)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(ze,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:R.name})]},`r-${ae}`))]})]})]})]})]})}function Xr(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(gt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function Jr({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await W.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(ou,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(he,{size:"sm",icon:sc,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function Px({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({issues:0,prs:0,actions:0,fetchedAt:0}),c=d.useRef(!1),u=d.useCallback(async()=>{n(!0);try{const g=await W.getStatus();a({has_remote:!0,repo:"",owner:""})}catch{a({has_remote:!1})}n(!1)},[e]);d.useEffect(()=>{u()},[u]);const m=d.useCallback(async()=>{if(!(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<jx)&&!c.current){c.current=!0;try{const[v,y,x]=await Promise.allSettled([W.getGitHubIssues(e,"open",1),W.getGitHubPRs(e,"open",1),W.getWorkflowRuns(e,5)]);h({issues:v.status==="fulfilled"?v.value.length:0,prs:y.status==="fulfilled"?y.value.length:0,actions:x.status==="fulfilled"?x.value.filter(k=>k.status==="in_progress").length:0,fetchedAt:Date.now()})}catch{}c.current=!1}},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&m()},[o==null?void 0:o.has_remote,m]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&m()},[t,o==null?void 0:o.has_remote,m]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(gt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const f=(o==null?void 0:o.has_remote)??!1,_=[{id:"changes",label:"Changes",icon:Z,requiresRemote:!1},{id:"issues",label:"Issues",icon:Td,count:l.issues,requiresRemote:!0},{id:"prs",label:"PRs",icon:tn,count:l.prs,requiresRemote:!0},{id:"actions",label:"Actions",icon:It,count:l.actions,requiresRemote:!0}],p=_;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[p.map(g=>{const v=g.requiresRemote&&!f;return r.jsxs("button",{onClick:()=>s(g.id),disabled:v,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===g.id?"bg-primary/10 text-primary":v?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:v?"Connect to GitHub to access this tab":void 0,children:[r.jsx(g.icon,{size:12}),g.label,g.count!==void 0&&g.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:g.count})]},g.id)}),f&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(ac,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Rx,{sessionId:e}),t==="issues"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Xr,{}),children:r.jsx(wx,{sessionId:e})}):r.jsx(Jr,{sessionId:e,onPushed:u})),t==="prs"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Xr,{}),children:r.jsx(Cx,{sessionId:e})}):r.jsx(Jr,{sessionId:e,onPushed:u})),t==="actions"&&(f?r.jsx(d.Suspense,{fallback:r.jsx(Xr,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(kx,{sessionId:e})})}):r.jsx(Jr,{sessionId:e,onPushed:u}))]})]})}function Mx({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(null),f=d.useCallback(async()=>{try{const g=await W.getCheckpoints(e);i(g),m(null)}catch{m("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{f();const g=setInterval(f,15e3);return()=>clearInterval(g)},[f]);const _=d.useCallback(async g=>{if(a)return;const v=s.find(x=>x.id===g);if(!(!v||!window.confirm(`Restore to checkpoint "${v.description}"?
|
|
251
226
|
|
|
252
|
-
This will revert files to this checkpoint state.`))){l(g);try{await W.restoreCheckpoint(e,g),await f(),t==null||t()}catch{m("Failed to restore checkpoint")}l(null)}},[e,s,a,f,t]);if(n)return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[r.jsx(nn,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(u&&s.length===0||s.length===0)return null;const p=g=>{if(!g)return"";try{return new Date(g).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[r.jsx(nn,{size:14,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),r.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((g,v)=>r.jsxs("div",{className:"flex items-center gap-1",children:[v>0&&r.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx("button",{onClick:()=>_(g.id),onMouseEnter:()=>c(g.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${g.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===g.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==g.id?"opacity-50":""}`,title:`${g.description} -- Click to restore`}),h===g.id&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[r.jsx("p",{className:"text-xs font-medium text-ink",children:g.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[g.timestamp&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(nt,{size:10}),p(g.timestamp)]}),g.files_changed>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(Z,{size:10}),g.files_changed," file",g.files_changed!==1?"s":""]}),g.iteration>0&&r.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",g.iteration]})]}),!g.is_current&&r.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[r.jsx(sc,{size:10}),"Click to restore"]}),g.is_current&&r.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},g.id))}),u&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:u})]})}function Ox({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",n=e.type==="delete"?e.old_line:e.new_line;return r.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[r.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:n||""}),r.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),r.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function $x({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(fr,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(iu,{size:14,className:"text-danger"}):r.jsx(Z,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),r.jsxs("button",{onClick:()=>n(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(ur,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),o,r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),r.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[r.jsx(mr,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(ic,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&r.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>r.jsxs("div",{children:[h>0&&r.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,u)=>r.jsx(Ox,{line:c},`${h}-${u}`))]},h))})]})}function Ix({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(f=>f.path))),[l,h]=d.useState(0),c=d.useCallback(f=>{a(_=>{const p=new Set(_);return p.has(f)?p.delete(f):p.add(f),p})},[]),u=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(f=>f.path)))},[o.size,e.files]),m=d.useCallback(()=>{s(Array.from(o))},[o,s]);return e.files.length===0?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:f=>f.stopPropagation(),children:[r.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),r.jsx("button",{onClick:n,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[r.jsx(Z,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(mr,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(ic,{size:12}),e.total_deletions]}),r.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),r.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[r.jsx("div",{className:"px-3 py-2 border-b border-border",children:r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.size===e.files.length,onChange:u,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),r.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((f,_)=>{const p=f.action==="add"?"text-success":f.action==="delete"?"text-danger":"text-blue-500";return r.jsxs("button",{onClick:()=>h(_),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${_===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(f.path),onChange:()=>c(f.path),onClick:g=>g.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono truncate flex-1",children:f.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${p}`,children:f.action==="add"?"+":f.action==="delete"?"-":"M"})]},f.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx($x,{file:e.files[l],isSelected:o.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[r.jsx(rc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:m,disabled:o.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(Ut,{size:14}),"Accept Selected (",o.size,")"]}),r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[r.jsx(Vd,{size:14}),"Accept All"]})]})]})]})}function Ji(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";case"timed_out":return"failed";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"||e.status==="requested"||e.status==="pending"?"pending":"running"}function Fx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"?"pending":"running"}function Hx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":"pending"}const ko={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:nt,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:pr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Gl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:er,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:rc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Yl,label:"Skipped"}};function kh(e){const t=new Date(e),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return`${i}s ago`;const n=Math.floor(i/60);if(n<60)return`${n}m ago`;const o=Math.floor(n/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Nh(e,t){if(!t)return"--";const s=new Date(t).getTime()-new Date(e).getTime();if(s<0)return"--";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60),o=i%60;if(n<60)return`${n}m ${o}s`;const a=Math.floor(n/60),l=n%60;return`${a}h ${l}m`}function No({status:e}){const t=ko[e];return r.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[r.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function Wx({step:e}){const t=Hx(e),s=ko[t];return r.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 text-xs",children:[r.jsx(s.Icon,{size:12,className:`${s.color} flex-shrink-0 ${t==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&e.completedAt&&r.jsx("span",{className:"text-[#939084] font-mono flex-shrink-0",children:Nh(e.startedAt,e.completedAt)}),r.jsx(No,{status:t})]})}function Ux({job:e}){const[t,s]=d.useState(!1),i=Fx(e),n=ko[i];return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?r.jsx(ls,{size:14,className:"text-[#939084]"}):r.jsx(ur,{size:14,className:"text-[#939084]"}),r.jsx(n.Icon,{size:14,className:`${n.color} ${i==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&r.jsx("span",{className:"text-xs text-[#939084] font-mono flex-shrink-0",children:Nh(e.startedAt,e.completedAt)}),r.jsx(No,{status:i})]}),t&&e.steps&&e.steps.length>0&&r.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAFAF8] dark:bg-[#1A1A1F] divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:e.steps.map(o=>r.jsx(Wx,{step:o},o.number))})]})}function Kx({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async()=>{o(!0),l(null);try{const c=await W.getWorkflowRunLogs(e,t);i(c)}catch(c){l(c instanceof Error?c.message:"Failed to fetch logs")}finally{o(!1)}},[e,t]);return d.useEffect(()=>{h()},[h]),n?r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg p-4 text-center",children:[r.jsx(pr,{size:16,className:"animate-spin text-[#939084] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading logs..."})]}):a?r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-4",children:r.jsx("p",{className:"text-xs text-[#C45B5B] font-mono",children:a})}):r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-3 max-h-80 overflow-y-auto terminal-scroll",children:r.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap text-[#E8E6E3]",children:s||"(No log output)"})})}function qx({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,l]=d.useState(!1),[h,c]=d.useState(null),[u,m]=d.useState(!1),f=Ji(e),_=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const g=await W.getWorkflowRunDetail(t,e.databaseId);o(g)}catch(g){c(g instanceof Error?g.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),p=()=>{const g=!s;i(g),g&&_()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:p,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[s?r.jsx(ls,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(ur,{size:14,className:"text-[#939084] flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:e.name}),r.jsx(No,{status:f})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[r.jsx(ze,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:kh(e.createdAt)})]})]}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:g=>g.stopPropagation(),className:"text-[#939084] hover:text-[#553DE9] transition-colors flex-shrink-0",title:"Open on GitHub",children:r.jsx(ss,{size:14})})]}),s&&r.jsxs("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] px-4 pb-4 pt-3 space-y-3",children:[a&&r.jsxs("div",{className:"text-center py-4",children:[r.jsx(pr,{size:16,className:"animate-spin text-[#553DE9] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading jobs..."})]}),h&&r.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ot,{size:14}),r.jsx("span",{className:"text-xs",children:h})]}),n&&n.jobs&&n.jobs.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold text-[#939084] uppercase tracking-wider",children:"Jobs"}),n.jobs.map(g=>r.jsx(Ux,{job:g},g.databaseId))]}),n&&(!n.jobs||n.jobs.length===0)&&!a&&r.jsx("p",{className:"text-xs text-[#939084]",children:"No jobs found for this run."}),n&&r.jsxs("div",{className:"pt-1",children:[r.jsxs("button",{onClick:()=>m(!u),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(es,{size:12}),u?"Hide full logs":"View full logs"]}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(Kx,{sessionId:t,runId:e.databaseId})})]})]})]})}function Vx({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var _;const[n,o]=d.useState(((_=t[0])==null?void 0:_.name)||""),[a,l]=d.useState(""),[h,c]=d.useState(!1),[u,m]=d.useState(null),f=async()=>{if(n){c(!0),m(null);try{await W.dispatchWorkflow(e,n,a),i(),s()}catch(p){m(p instanceof Error?p.message:"Dispatch failed")}finally{c(!1)}}};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 bg-[#FAFAF8] dark:bg-[#1A1A1F] space-y-3",children:[r.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Run Workflow"}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Workflow"}),r.jsx("select",{value:n,onChange:p=>o(p.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:t.map(p=>r.jsxs("option",{value:p.name,children:[p.name," (",p.name,")"]},p.id))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Branch / ref (leave empty for default)"}),r.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),placeholder:"main",className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40"})]}),u&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ot,{size:12}),r.jsx("span",{className:"text-xs",children:u})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(he,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(he,{size:"sm",icon:It,onClick:f,loading:h,children:"Dispatch"})]})]})}function jh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,u]=d.useState(null),[m,f]=d.useState(!1),[_,p]=d.useState(null),g=d.useRef(null),v=t.some(D=>D.status==="in_progress"||D.status==="queued"||D.status==="waiting"||D.status==="requested"||D.status==="pending"),y=d.useCallback(async(D=!1)=>{if(e){D&&h(!0),u(null);try{const T=await W.getWorkflowRuns(e);s(T),a(""),p(new Date)}catch(T){const U=T instanceof Error?T.message:String(T);U.includes("gh CLI not found")?u({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):U.includes("not authenticated")||U.includes("401")?u({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):U.includes("Could not detect")?u({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):u({type:"generic",message:U})}finally{h(!1)}}},[e]),x=d.useCallback(async()=>{if(e)try{const D=await W.getWorkflows(e);n(D.filter(T=>T.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),x()},[y,x]),d.useEffect(()=>(v&&e?g.current=setInterval(()=>y(!1),1e4):g.current&&(clearInterval(g.current),g.current=null),()=>{g.current&&clearInterval(g.current)}),[v,e,y]);const k=t.filter(D=>Ji(D)==="success").length,N=t.filter(D=>Ji(D)==="failed").length,w=t.filter(D=>{const T=Ji(D);return T==="running"||T==="pending"}).length;return r.jsxs("div",{className:"card p-6",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(ze,{size:18,className:"text-[#553DE9]"}),r.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"}),o&&r.jsx("span",{className:"text-xs text-[#939084] font-mono",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[_&&r.jsxs("span",{className:"text-[10px] text-[#939084] flex items-center gap-1",children:[r.jsx(cc,{size:10}),kh(_.toISOString())]}),r.jsx(he,{size:"sm",variant:"ghost",icon:gt,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(he,{size:"sm",icon:It,onClick:()=>f(!m),children:"Run Workflow"})]})]}),m&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Vx,{sessionId:e,workflows:i,onClose:()=>f(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),c&&r.jsxs("div",{className:"mb-4",children:[c.type==="gh_not_found"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Ot,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"GitHub CLI not installed"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:text-[#4432c4] mt-2",children:["Install GitHub CLI ",r.jsx(ss,{size:10})]})]})]}),c.type==="not_authenticated"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ot,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Not authenticated"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsx("code",{className:"inline-block text-xs bg-[#0F0F11] text-[#E8E6E3] px-2 py-1 rounded mt-2 font-mono",children:"gh auth login"})]})]}),c.type==="no_repo"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(ze,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"No GitHub repository"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]}),c.type==="generic"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ot,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Failed to load workflow runs"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]})]}),!l&&!c&&t.length>0&&r.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[r.jsx(Gl,{size:12}),k," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(er,{size:12}),N," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(pr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),v&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),l&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(D=>r.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 animate-pulse",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-48"}),r.jsx("div",{className:"h-3 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-32 mt-2"})]}),r.jsx("div",{className:"h-5 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded-full w-16"})]})},D))}),!l&&!c&&t.length===0&&r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-[#939084] text-sm",children:"No workflow runs found"}),r.jsx("p",{className:"text-[#939084]/60 text-xs mt-1",children:"Push commits or trigger a workflow to see runs here"})]}),!l&&!c&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(D=>r.jsx(qx,{run:D,sessionId:e},D.databaseId))})]})}const Gx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:jh},Symbol.toStringTag,{value:"Module"}));function Yx({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),l=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&l.current!=="complete"){n(!0),a(!1);const c=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(c)}e!=="complete"&&a(!1),l.current=e},[e,s]),!i||o)return null;const h=c=>{if(c<60)return`${c}s`;const u=Math.floor(c/60),m=c%60;return`${u}m ${m}s`};return r.jsx("div",{className:"build-celebration-overlay",onClick:()=>{n(!1),a(!0),s==null||s()},children:r.jsxs("div",{className:"build-celebration-content",onClick:c=>c.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(kt,{size:48,className:"text-success"})}),r.jsx("div",{className:"build-celebration-burst"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink mt-4",children:"Your app is ready!"}),r.jsx("p",{className:"text-sm text-muted mt-1",children:t?`Built in ${h(t)}. Time to see it in action.`:"Everything looks great. Go take a look."})]})})}function Xx({tokenHistory:e,budget:t=1e5,className:s=""}){const i=e.slice(-10);if(i.length<2)return null;const n=64,o=20,a=2,l=Math.max(...i,1),h=Math.min(...i,0),c=l-h||1,u=i.map((y,x)=>({x:a+x/(i.length-1)*(n-a*2),y:a+(1-(y-h)/c)*(o-a*2)})),m=u.map((y,x)=>`${x===0?"M":"L"} ${y.x.toFixed(1)} ${y.y.toFixed(1)}`).join(" "),f=`${m} L ${u[u.length-1].x.toFixed(1)} ${o-a} L ${u[0].x.toFixed(1)} ${o-a} Z`,p=i[i.length-1]/t;let g="#1FC5A8",v="rgba(31, 197, 168, 0.15)";return p>1?(g="#C45B5B",v="rgba(196, 91, 91, 0.15)"):p>.75&&(g="#D4A03C",v="rgba(212, 160, 60, 0.15)"),r.jsxs("svg",{width:n,height:o,viewBox:`0 0 ${n} ${o}`,className:`inline-block align-middle ${s}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:f,fill:v}),r.jsx("path",{d:m,fill:"none",stroke:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:"2",fill:g})]})}function Jx(){const[e,t]=d.useState([]),s=d.useRef(0);return{history:e,recordTokens:n=>{n!==s.current&&(s.current=n,t(o=>{const a=[...o,n];return a.length>20?a.slice(-20):a}))}}}function Zx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:Z,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:Z,color:"text-yellow-500",label:"JSX"},ts:{icon:Z,color:"text-blue-500",label:"TypeScript"},tsx:{icon:Z,color:"text-blue-400",label:"TSX"},py:{icon:Z,color:"text-green-600",label:"Python"},html:{icon:Z,color:"text-orange-500",label:"HTML"},css:{icon:so,color:"text-purple-500",label:"CSS"},json:{icon:to,color:"text-green-500",label:"JSON"},md:{icon:fi,color:"text-muted",label:"Markdown"},go:{icon:Z,color:"text-cyan-600",label:"Go"},rs:{icon:Z,color:"text-orange-600",label:"Rust"}}[t]||{icon:io,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function Qx(e){const t=Math.floor((Date.now()-e)/1e3);return t<2?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ago`}function Ll(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function ev({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:u}){const[m,f]=d.useState(""),[_,p]=d.useState(!1);d.useEffect(()=>{if(!n)return;const N=()=>f(Qx(n));N();const w=setInterval(N,5e3);return()=>clearInterval(w)},[n]);const g=d.useCallback(async()=>{const N=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Ll(h)}`:"",u?`
|
|
227
|
+
This will revert files to this checkpoint state.`))){l(g);try{await W.restoreCheckpoint(e,g),await f(),t==null||t()}catch{m("Failed to restore checkpoint")}l(null)}},[e,s,a,f,t]);if(n)return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[r.jsx(sn,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(u&&s.length===0||s.length===0)return null;const p=g=>{if(!g)return"";try{return new Date(g).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[r.jsx(sn,{size:14,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),r.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((g,v)=>r.jsxs("div",{className:"flex items-center gap-1",children:[v>0&&r.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx("button",{onClick:()=>_(g.id),onMouseEnter:()=>c(g.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${g.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===g.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==g.id?"opacity-50":""}`,title:`${g.description} -- Click to restore`}),h===g.id&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[r.jsx("p",{className:"text-xs font-medium text-ink",children:g.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[g.timestamp&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(nt,{size:10}),p(g.timestamp)]}),g.files_changed>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(Z,{size:10}),g.files_changed," file",g.files_changed!==1?"s":""]}),g.iteration>0&&r.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",g.iteration]})]}),!g.is_current&&r.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[r.jsx(ic,{size:10}),"Click to restore"]}),g.is_current&&r.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},g.id))}),u&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:u})]})}function Lx({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",n=e.type==="delete"?e.old_line:e.new_line;return r.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[r.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:n||""}),r.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),r.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function Bx({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(fr,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(su,{size:14,className:"text-danger"}):r.jsx(Z,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),r.jsxs("button",{onClick:()=>n(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(ur,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),o,r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),r.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[r.jsx(mr,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(rc,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&r.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>r.jsxs("div",{children:[h>0&&r.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,u)=>r.jsx(Lx,{line:c},`${h}-${u}`))]},h))})]})}function Tx({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(f=>f.path))),[l,h]=d.useState(0),c=d.useCallback(f=>{a(_=>{const p=new Set(_);return p.has(f)?p.delete(f):p.add(f),p})},[]),u=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(f=>f.path)))},[o.size,e.files]),m=d.useCallback(()=>{s(Array.from(o))},[o,s]);return e.files.length===0?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:f=>f.stopPropagation(),children:[r.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),r.jsx("button",{onClick:n,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:f=>f.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[r.jsx(Z,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(mr,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(rc,{size:12}),e.total_deletions]}),r.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),r.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[r.jsx("div",{className:"px-3 py-2 border-b border-border",children:r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.size===e.files.length,onChange:u,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),r.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((f,_)=>{const p=f.action==="add"?"text-success":f.action==="delete"?"text-danger":"text-blue-500";return r.jsxs("button",{onClick:()=>h(_),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${_===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(f.path),onChange:()=>c(f.path),onClick:g=>g.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono truncate flex-1",children:f.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${p}`,children:f.action==="add"?"+":f.action==="delete"?"-":"M"})]},f.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx(Bx,{file:e.files[l],isSelected:o.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[r.jsx(nc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:m,disabled:o.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(Ut,{size:14}),"Accept Selected (",o.size,")"]}),r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[r.jsx(Yd,{size:14}),"Accept All"]})]})]})]})}function Ji(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";case"timed_out":return"failed";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"||e.status==="requested"||e.status==="pending"?"pending":"running"}function zx(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"?"pending":"running"}function Ax(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":"pending"}const ko={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:nt,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:pr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Gl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:er,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:nc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:Yl,label:"Skipped"}};function kh(e){const t=new Date(e),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return`${i}s ago`;const n=Math.floor(i/60);if(n<60)return`${n}m ago`;const o=Math.floor(n/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function jh(e,t){if(!t)return"--";const s=new Date(t).getTime()-new Date(e).getTime();if(s<0)return"--";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60),o=i%60;if(n<60)return`${n}m ${o}s`;const a=Math.floor(n/60),l=n%60;return`${a}h ${l}m`}function jo({status:e}){const t=ko[e];return r.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[r.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function Ox({step:e}){const t=Ax(e),s=ko[t];return r.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 text-xs",children:[r.jsx(s.Icon,{size:12,className:`${s.color} flex-shrink-0 ${t==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&e.completedAt&&r.jsx("span",{className:"text-[#939084] font-mono flex-shrink-0",children:jh(e.startedAt,e.completedAt)}),r.jsx(jo,{status:t})]})}function $x({job:e}){const[t,s]=d.useState(!1),i=zx(e),n=ko[i];return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?r.jsx(ls,{size:14,className:"text-[#939084]"}):r.jsx(ur,{size:14,className:"text-[#939084]"}),r.jsx(n.Icon,{size:14,className:`${n.color} ${i==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&r.jsx("span",{className:"text-xs text-[#939084] font-mono flex-shrink-0",children:jh(e.startedAt,e.completedAt)}),r.jsx(jo,{status:i})]}),t&&e.steps&&e.steps.length>0&&r.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAFAF8] dark:bg-[#1A1A1F] divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:e.steps.map(o=>r.jsx(Ox,{step:o},o.number))})]})}function Ix({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async()=>{o(!0),l(null);try{const c=await W.getWorkflowRunLogs(e,t);i(c)}catch(c){l(c instanceof Error?c.message:"Failed to fetch logs")}finally{o(!1)}},[e,t]);return d.useEffect(()=>{h()},[h]),n?r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg p-4 text-center",children:[r.jsx(pr,{size:16,className:"animate-spin text-[#939084] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading logs..."})]}):a?r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-4",children:r.jsx("p",{className:"text-xs text-[#C45B5B] font-mono",children:a})}):r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-3 max-h-80 overflow-y-auto terminal-scroll",children:r.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap text-[#E8E6E3]",children:s||"(No log output)"})})}function Fx({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,l]=d.useState(!1),[h,c]=d.useState(null),[u,m]=d.useState(!1),f=Ji(e),_=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const g=await W.getWorkflowRunDetail(t,e.databaseId);o(g)}catch(g){c(g instanceof Error?g.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),p=()=>{const g=!s;i(g),g&&_()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:p,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[s?r.jsx(ls,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(ur,{size:14,className:"text-[#939084] flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:e.name}),r.jsx(jo,{status:f})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[r.jsx(ze,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:kh(e.createdAt)})]})]}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:g=>g.stopPropagation(),className:"text-[#939084] hover:text-[#553DE9] transition-colors flex-shrink-0",title:"Open on GitHub",children:r.jsx(ss,{size:14})})]}),s&&r.jsxs("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] px-4 pb-4 pt-3 space-y-3",children:[a&&r.jsxs("div",{className:"text-center py-4",children:[r.jsx(pr,{size:16,className:"animate-spin text-[#553DE9] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading jobs..."})]}),h&&r.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ot,{size:14}),r.jsx("span",{className:"text-xs",children:h})]}),n&&n.jobs&&n.jobs.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold text-[#939084] uppercase tracking-wider",children:"Jobs"}),n.jobs.map(g=>r.jsx($x,{job:g},g.databaseId))]}),n&&(!n.jobs||n.jobs.length===0)&&!a&&r.jsx("p",{className:"text-xs text-[#939084]",children:"No jobs found for this run."}),n&&r.jsxs("div",{className:"pt-1",children:[r.jsxs("button",{onClick:()=>m(!u),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(es,{size:12}),u?"Hide full logs":"View full logs"]}),u&&r.jsx("div",{className:"mt-2",children:r.jsx(Ix,{sessionId:t,runId:e.databaseId})})]})]})]})}function Hx({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var _;const[n,o]=d.useState(((_=t[0])==null?void 0:_.name)||""),[a,l]=d.useState(""),[h,c]=d.useState(!1),[u,m]=d.useState(null),f=async()=>{if(n){c(!0),m(null);try{await W.dispatchWorkflow(e,n,a),i(),s()}catch(p){m(p instanceof Error?p.message:"Dispatch failed")}finally{c(!1)}}};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 bg-[#FAFAF8] dark:bg-[#1A1A1F] space-y-3",children:[r.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Run Workflow"}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Workflow"}),r.jsx("select",{value:n,onChange:p=>o(p.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:t.map(p=>r.jsxs("option",{value:p.name,children:[p.name," (",p.name,")"]},p.id))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Branch / ref (leave empty for default)"}),r.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),placeholder:"main",className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40"})]}),u&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ot,{size:12}),r.jsx("span",{className:"text-xs",children:u})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(he,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(he,{size:"sm",icon:It,onClick:f,loading:h,children:"Dispatch"})]})]})}function Nh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,u]=d.useState(null),[m,f]=d.useState(!1),[_,p]=d.useState(null),g=d.useRef(null),v=t.some(D=>D.status==="in_progress"||D.status==="queued"||D.status==="waiting"||D.status==="requested"||D.status==="pending"),y=d.useCallback(async(D=!1)=>{if(e){D&&h(!0),u(null);try{const T=await W.getWorkflowRuns(e);s(T),a(""),p(new Date)}catch(T){const U=T instanceof Error?T.message:String(T);U.includes("gh CLI not found")?u({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):U.includes("not authenticated")||U.includes("401")?u({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):U.includes("Could not detect")?u({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):u({type:"generic",message:U})}finally{h(!1)}}},[e]),x=d.useCallback(async()=>{if(e)try{const D=await W.getWorkflows(e);n(D.filter(T=>T.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),x()},[y,x]),d.useEffect(()=>(v&&e?g.current=setInterval(()=>y(!1),1e4):g.current&&(clearInterval(g.current),g.current=null),()=>{g.current&&clearInterval(g.current)}),[v,e,y]);const k=t.filter(D=>Ji(D)==="success").length,j=t.filter(D=>Ji(D)==="failed").length,w=t.filter(D=>{const T=Ji(D);return T==="running"||T==="pending"}).length;return r.jsxs("div",{className:"card p-6",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(ze,{size:18,className:"text-[#553DE9]"}),r.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"}),o&&r.jsx("span",{className:"text-xs text-[#939084] font-mono",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[_&&r.jsxs("span",{className:"text-[10px] text-[#939084] flex items-center gap-1",children:[r.jsx(cc,{size:10}),kh(_.toISOString())]}),r.jsx(he,{size:"sm",variant:"ghost",icon:gt,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(he,{size:"sm",icon:It,onClick:()=>f(!m),children:"Run Workflow"})]})]}),m&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Hx,{sessionId:e,workflows:i,onClose:()=>f(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),c&&r.jsxs("div",{className:"mb-4",children:[c.type==="gh_not_found"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Ot,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"GitHub CLI not installed"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:text-[#4432c4] mt-2",children:["Install GitHub CLI ",r.jsx(ss,{size:10})]})]})]}),c.type==="not_authenticated"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ot,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Not authenticated"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsx("code",{className:"inline-block text-xs bg-[#0F0F11] text-[#E8E6E3] px-2 py-1 rounded mt-2 font-mono",children:"gh auth login"})]})]}),c.type==="no_repo"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(ze,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"No GitHub repository"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]}),c.type==="generic"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ot,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Failed to load workflow runs"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]})]}),!l&&!c&&t.length>0&&r.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[r.jsx(Gl,{size:12}),k," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(er,{size:12}),j," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(pr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),v&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),l&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(D=>r.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 animate-pulse",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-48"}),r.jsx("div",{className:"h-3 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-32 mt-2"})]}),r.jsx("div",{className:"h-5 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded-full w-16"})]})},D))}),!l&&!c&&t.length===0&&r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-[#939084] text-sm",children:"No workflow runs found"}),r.jsx("p",{className:"text-[#939084]/60 text-xs mt-1",children:"Push commits or trigger a workflow to see runs here"})]}),!l&&!c&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(D=>r.jsx(Fx,{run:D,sessionId:e},D.databaseId))})]})}const Wx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:Nh},Symbol.toStringTag,{value:"Module"}));function Ux({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),l=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&l.current!=="complete"){n(!0),a(!1);const c=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(c)}e!=="complete"&&a(!1),l.current=e},[e,s]),!i||o)return null;const h=c=>{if(c<60)return`${c}s`;const u=Math.floor(c/60),m=c%60;return`${u}m ${m}s`};return r.jsx("div",{className:"build-celebration-overlay",onClick:()=>{n(!1),a(!0),s==null||s()},children:r.jsxs("div",{className:"build-celebration-content",onClick:c=>c.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(kt,{size:48,className:"text-success"})}),r.jsx("div",{className:"build-celebration-burst"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink mt-4",children:"Your app is ready!"}),r.jsx("p",{className:"text-sm text-muted mt-1",children:t?`Built in ${h(t)}. Time to see it in action.`:"Everything looks great. Go take a look."})]})})}function Kx({tokenHistory:e,budget:t=1e5,className:s=""}){const i=e.slice(-10);if(i.length<2)return null;const n=64,o=20,a=2,l=Math.max(...i,1),h=Math.min(...i,0),c=l-h||1,u=i.map((y,x)=>({x:a+x/(i.length-1)*(n-a*2),y:a+(1-(y-h)/c)*(o-a*2)})),m=u.map((y,x)=>`${x===0?"M":"L"} ${y.x.toFixed(1)} ${y.y.toFixed(1)}`).join(" "),f=`${m} L ${u[u.length-1].x.toFixed(1)} ${o-a} L ${u[0].x.toFixed(1)} ${o-a} Z`,p=i[i.length-1]/t;let g="#1FC5A8",v="rgba(31, 197, 168, 0.15)";return p>1?(g="#C45B5B",v="rgba(196, 91, 91, 0.15)"):p>.75&&(g="#D4A03C",v="rgba(212, 160, 60, 0.15)"),r.jsxs("svg",{width:n,height:o,viewBox:`0 0 ${n} ${o}`,className:`inline-block align-middle ${s}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:f,fill:v}),r.jsx("path",{d:m,fill:"none",stroke:g,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:"2",fill:g})]})}function qx(){const[e,t]=d.useState([]),s=d.useRef(0);return{history:e,recordTokens:n=>{n!==s.current&&(s.current=n,t(o=>{const a=[...o,n];return a.length>20?a.slice(-20):a}))}}}function Vx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:Z,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:Z,color:"text-yellow-500",label:"JSX"},ts:{icon:Z,color:"text-blue-500",label:"TypeScript"},tsx:{icon:Z,color:"text-blue-400",label:"TSX"},py:{icon:Z,color:"text-green-600",label:"Python"},html:{icon:Z,color:"text-orange-500",label:"HTML"},css:{icon:so,color:"text-purple-500",label:"CSS"},json:{icon:to,color:"text-green-500",label:"JSON"},md:{icon:fi,color:"text-muted",label:"Markdown"},go:{icon:Z,color:"text-cyan-600",label:"Go"},rs:{icon:Z,color:"text-orange-600",label:"Rust"}}[t]||{icon:io,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function Gx(e){const t=Math.floor((Date.now()-e)/1e3);return t<2?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ago`}function Ll(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function Yx({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:u}){const[m,f]=d.useState(""),[_,p]=d.useState(!1);d.useEffect(()=>{if(!n)return;const j=()=>f(Gx(n));j();const w=setInterval(j,5e3);return()=>clearInterval(w)},[n]);const g=d.useCallback(async()=>{const j=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Ll(h)}`:"",u?`
|
|
253
228
|
Project: ${u.substring(0,100)}${u.length>100?"...":""}`:"",`
|
|
254
229
|
https://autonomi.dev`].filter(Boolean).join(`
|
|
255
|
-
`);try{await navigator.clipboard.writeText(N),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[c,h,u]);if(!e)return null;const v=Zx(t),y=v.icon,x=h?h*5:0,k=h&&x>0?(x/h).toFixed(1):null;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 bg-card border-t border-border text-[11px] font-mono text-muted select-none flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(y,{size:12,className:v.color}),r.jsx("span",{children:v.label})]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:[o," lines"]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:["Ln ",a,", Col ",l]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ad,{size:11}),i?r.jsx("span",{className:"text-primary animate-pulse",children:"Saving..."}):s?r.jsx("span",{className:"text-warning",children:"Unsaved"}):n?r.jsxs("span",{className:"text-success",children:["Saved ",m]}):r.jsx("span",{children:"Saved"})]}),r.jsx("div",{className:"flex-1"}),h!=null&&h>0&&r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(cc,{size:11}),r.jsxs("span",{children:["Built in ",Ll(h)]}),k&&r.jsxs("span",{className:"text-muted ml-1",children:[r.jsx(Zt,{size:10,className:"inline"})," ",k,"x faster"]})]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-border",children:"|"}),r.jsx("button",{onClick:g,className:"flex items-center gap-1 hover:text-primary transition-colors",title:"Copy build summary to clipboard",children:_?r.jsxs(r.Fragment,{children:[r.jsx(Ut,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(no,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Gn=[{id:"desktop",label:"Desktop",icon:yd,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Bu,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:Mu,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function tv({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Gn.map(i=>{const n=i.icon,o=e===i.id;return r.jsx("button",{onClick:()=>t(i.id),title:`${i.label} (${i.frameWidth}px)`,className:`p-1.5 rounded transition-colors ${o?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:r.jsx(n,{size:14})},i.id)}),s!=null&&s>0&&r.jsxs("span",{className:"text-[10px] font-mono text-muted ml-1 tabular-nums",children:[s,"px"]})]})}function sv(){const[e,t]=d.useState("desktop"),s=Gn.find(i=>i.id===e)||Gn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const iv=[75,100,125];function rv({zoom:e,onZoomChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5 border border-border rounded-btn",children:iv.map(s=>r.jsxs("button",{onClick:()=>t(s),className:`px-2 py-1 text-[10px] font-medium transition-colors ${e===s?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,title:`Zoom ${s}%`,children:[s,"%"]},s))})}function nv({data:e,size:t=80}){const i=t/11,n=[];let o=0;for(let a=0;a<e.length;a++)o=(o<<5)-o+e.charCodeAt(a)|0;for(let a=0;a<11;a++){n[a]=[];for(let l=0;l<11;l++){const h=l<3&&a<3,c=l>=8&&a<3,u=l<3&&a>=8;if((h||c||u)&&(l===0||a===0||l===2||a===2||l===10||a===10||l===8||a===8)||(l===1&&a===1||l===9&&a===1||l===1&&a===9))n[a][l]=!0;else if(h||c||u)n[a][l]=!1;else{const _=o+l*17+a*31&65535;n[a][l]=_%3!==0}}}return r.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"bg-white rounded p-1",children:n.map((a,l)=>a.map((h,c)=>h?r.jsx("rect",{x:c*i,y:l*i,width:i,height:i,fill:"#201515"},`${c}-${l}`):null))})}function ov(){const[e,t]=d.useState(!1);return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:()=>t(s=>!s),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Screenshot",children:r.jsx(Kd,{size:14})}),e&&r.jsx("div",{className:"absolute top-full right-0 mt-1 z-20 bg-card border border-border rounded-btn shadow-lg p-2 text-xs text-muted whitespace-nowrap",children:"Right-click the preview to save as image"})]})}function av({url:e}){const[t,s]=d.useState(!1),i=d.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}},[e]);return r.jsxs("button",{onClick:i,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors relative",title:"Copy preview URL",children:[t?r.jsx(Ut,{size:14,className:"text-success"}):r.jsx(Qn,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function lv({isFullscreen:e,onToggle:t}){return r.jsx("button",{onClick:t,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:e?"Exit fullscreen":"Fullscreen preview",children:e?r.jsx(lc,{size:14}):r.jsx(on,{size:14})})}function Bl({messages:e}){const[t,s]=d.useState(!1),i=e.slice(-5),n=i.some(o=>o.level==="error");return i.length===0?null:r.jsxs("div",{className:`border-t border-border bg-card ${t?"":"cursor-pointer"}`,children:[r.jsxs("button",{onClick:()=>s(o=>!o),className:"w-full flex items-center gap-2 px-3 py-1.5 text-[11px] font-mono hover:bg-hover transition-colors",children:[n?r.jsx(Rs,{size:12,className:"text-danger"}):r.jsx("span",{className:"w-3 h-3 rounded-full border border-muted/40 flex items-center justify-center text-[8px] text-muted",children:"i"}),r.jsxs("span",{className:`font-medium ${n?"text-danger":"text-muted"}`,children:["Console (",i.length,")"]}),r.jsx("div",{className:"flex-1"}),t?r.jsx(ls,{size:12}):r.jsx(dr,{size:12})]}),t&&r.jsx("div",{className:"max-h-32 overflow-y-auto terminal-scroll border-t border-border",children:i.map((o,a)=>r.jsxs("div",{className:`px-3 py-1 text-[11px] font-mono border-b border-border/50 last:border-b-0 ${o.level==="error"?"bg-danger/5 text-danger":o.level==="warn"?"bg-warning/5 text-warning":"text-muted"}`,children:[r.jsx("span",{className:"uppercase text-[9px] font-semibold mr-2 opacity-60",children:o.level}),o.message]},a))})]})}function cv({onClick:e,isRefreshing:t}){const[s,i]=d.useState(!1),n=d.useCallback(()=>{i(!0),e(),setTimeout(()=>i(!1),600)},[e]);return r.jsx("button",{onClick:n,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Refresh preview",children:r.jsx(Rd,{size:14,className:s||t?"animate-spin-once":""})})}function Tl(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-card p-8",children:[r.jsxs("div",{className:"w-full max-w-md space-y-4",children:[r.jsx("div",{className:"skeleton-shimmer h-10 w-full rounded"}),r.jsx("div",{className:"skeleton-shimmer h-32 w-full rounded"}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"})]}),r.jsx("div",{className:"skeleton-shimmer h-8 w-48 rounded mx-auto"})]}),r.jsx("p",{className:"text-xs text-muted mt-6 animate-pulse",children:"Loading preview..."})]})}function hv({url:e}){const[t,s]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!t)return;const n=o=>{i.current&&!i.current.contains(o.target)&&s(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[t]),r.jsxs("div",{className:"relative",ref:i,children:[r.jsx("button",{onClick:()=>s(n=>!n),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors text-[10px] font-semibold",title:"Show QR code",children:"QR"}),t&&r.jsxs("div",{className:"absolute top-full right-0 mt-1 z-30 bg-card border border-border rounded-btn shadow-lg p-3",children:[r.jsx(nv,{data:e,size:100}),r.jsx("p",{className:"text-[10px] text-muted text-center mt-2 max-w-[100px] truncate",children:e})]})]})}const zl={create:"bg-primary/8 text-primary border-primary/15 hover:bg-primary/15",improve:"bg-info/8 text-info border-info/15 hover:bg-info/15",fix:"bg-danger/8 text-danger border-danger/15 hover:bg-danger/15",test:"bg-teal/8 text-teal border-teal/15 hover:bg-teal/15",deploy:"bg-warning/8 text-warning border-warning/15 hover:bg-warning/15"};function dv(e){const{projectState:t,hasSession:s,files:i,lastError:n,phase:o}=e;if(!s||t==="empty")return[{label:"Build a SaaS dashboard",prompt:"Build a modern SaaS analytics dashboard with charts and dark mode",category:"create"},{label:"Create a CLI tool",prompt:"Create a CLI tool with commands, flags, and help text",category:"create"},{label:"Build a REST API",prompt:"Build a REST API with CRUD endpoints, authentication, and database",category:"create"},{label:"Make a landing page",prompt:"Create a beautiful landing page with hero, features, pricing, and CTA sections",category:"create"}];if(t==="failed"){const a=[{label:"Fix the build errors",prompt:"Fix all build errors and get the project to compile successfully",category:"fix"},{label:"Try a different approach",prompt:"The current approach has issues. Try an alternative implementation strategy",category:"fix"}];if(n){const l=n.length>60?n.slice(0,60)+"...":n;a.unshift({label:`Fix: ${l}`,prompt:`Fix this error: ${n}`,category:"fix"})}return a.push({label:"Add error handling",prompt:"Add comprehensive error handling and fallbacks throughout the codebase",category:"improve"}),a.slice(0,4)}if(t==="building")return[];if(t==="completed"||t==="idle"){const a=[],l=i==null?void 0:i.some(m=>m.path.toLowerCase().includes("auth")),h=i==null?void 0:i.some(m=>m.path.includes(".test.")||m.path.includes(".spec.")||m.path.includes("__tests__")),c=i==null?void 0:i.some(m=>m.path.endsWith(".css")||m.path.endsWith(".scss")),u=i==null?void 0:i.some(m=>m.path.includes("Dockerfile")||m.path.includes("docker-compose"));return l||a.push({label:"Add authentication",prompt:"Add user authentication with login, signup, and session management",category:"improve"}),h||a.push({label:"Add test suite",prompt:"Add comprehensive unit tests and integration tests for all major features",category:"test"}),a.push({label:"Improve the UI",prompt:"Improve the UI with better styling, animations, and responsive design",category:"improve"}),u||a.push({label:"Add Docker support",prompt:"Add Dockerfile and docker-compose.yml for containerized deployment",category:"deploy"}),l&&a.push({label:"Add role-based access",prompt:"Add role-based access control with admin, editor, and viewer roles",category:"improve"}),c||a.push({label:"Add dark mode",prompt:"Add a dark mode toggle with proper theme support across all components",category:"improve"}),a.push({label:"Add API docs",prompt:"Add OpenAPI/Swagger documentation for all API endpoints",category:"improve"}),a.push({label:"Performance optimization",prompt:"Optimize performance: add lazy loading, caching, code splitting, and minimize bundle size",category:"improve"}),a.slice(0,4)}return[]}function uv(e){const{onSelect:t,className:s=""}=e,[i,n]=d.useState(!0),[o,a]=d.useState(!1),l=d.useMemo(()=>dv(e),[e.projectState,e.hasSession,e.files,e.lastError,e.phase]),[h,c]=d.useState(0);if(d.useEffect(()=>{if(l.length<=4)return;const m=setInterval(()=>{a(!0),setTimeout(()=>{c(f=>(f+1)%l.length),a(!1)},300)},3e4);return()=>clearInterval(m)},[l.length]),l.length===0||!i)return null;const u=l.slice(h,h+4).concat(h+4>l.length?l.slice(0,h+4-l.length):[]).slice(0,4);return r.jsxs("div",{className:`${s}`,children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Sd,{size:12,className:"text-primary"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Suggestions"})]}),r.jsx("div",{className:`flex flex-wrap gap-1.5 transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:u.map((m,f)=>r.jsxs("button",{onClick:()=>t(m.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
230
|
+
`);try{await navigator.clipboard.writeText(j),p(!0),setTimeout(()=>p(!1),2e3)}catch{}},[c,h,u]);if(!e)return null;const v=Vx(t),y=v.icon,x=h?h*5:0,k=h&&x>0?(x/h).toFixed(1):null;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 bg-card border-t border-border text-[11px] font-mono text-muted select-none flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(y,{size:12,className:v.color}),r.jsx("span",{children:v.label})]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:[o," lines"]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:["Ln ",a,", Col ",l]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Od,{size:11}),i?r.jsx("span",{className:"text-primary animate-pulse",children:"Saving..."}):s?r.jsx("span",{className:"text-warning",children:"Unsaved"}):n?r.jsxs("span",{className:"text-success",children:["Saved ",m]}):r.jsx("span",{children:"Saved"})]}),r.jsx("div",{className:"flex-1"}),h!=null&&h>0&&r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(cc,{size:11}),r.jsxs("span",{children:["Built in ",Ll(h)]}),k&&r.jsxs("span",{className:"text-muted ml-1",children:[r.jsx(Zt,{size:10,className:"inline"})," ",k,"x faster"]})]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-border",children:"|"}),r.jsx("button",{onClick:g,className:"flex items-center gap-1 hover:text-primary transition-colors",title:"Copy build summary to clipboard",children:_?r.jsxs(r.Fragment,{children:[r.jsx(Ut,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(no,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Gn=[{id:"desktop",label:"Desktop",icon:yd,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Pu,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:Du,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function Xx({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Gn.map(i=>{const n=i.icon,o=e===i.id;return r.jsx("button",{onClick:()=>t(i.id),title:`${i.label} (${i.frameWidth}px)`,className:`p-1.5 rounded transition-colors ${o?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:r.jsx(n,{size:14})},i.id)}),s!=null&&s>0&&r.jsxs("span",{className:"text-[10px] font-mono text-muted ml-1 tabular-nums",children:[s,"px"]})]})}function Jx(){const[e,t]=d.useState("desktop"),s=Gn.find(i=>i.id===e)||Gn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const Zx=[75,100,125];function Qx({zoom:e,onZoomChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5 border border-border rounded-btn",children:Zx.map(s=>r.jsxs("button",{onClick:()=>t(s),className:`px-2 py-1 text-[10px] font-medium transition-colors ${e===s?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,title:`Zoom ${s}%`,children:[s,"%"]},s))})}function ev({data:e,size:t=80}){const i=t/11,n=[];let o=0;for(let a=0;a<e.length;a++)o=(o<<5)-o+e.charCodeAt(a)|0;for(let a=0;a<11;a++){n[a]=[];for(let l=0;l<11;l++){const h=l<3&&a<3,c=l>=8&&a<3,u=l<3&&a>=8;if((h||c||u)&&(l===0||a===0||l===2||a===2||l===10||a===10||l===8||a===8)||(l===1&&a===1||l===9&&a===1||l===1&&a===9))n[a][l]=!0;else if(h||c||u)n[a][l]=!1;else{const _=o+l*17+a*31&65535;n[a][l]=_%3!==0}}}return r.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:"bg-white rounded p-1",children:n.map((a,l)=>a.map((h,c)=>h?r.jsx("rect",{x:c*i,y:l*i,width:i,height:i,fill:"#201515"},`${c}-${l}`):null))})}function tv(){const[e,t]=d.useState(!1);return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:()=>t(s=>!s),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Screenshot",children:r.jsx(Vd,{size:14})}),e&&r.jsx("div",{className:"absolute top-full right-0 mt-1 z-20 bg-card border border-border rounded-btn shadow-lg p-2 text-xs text-muted whitespace-nowrap",children:"Right-click the preview to save as image"})]})}function sv({url:e}){const[t,s]=d.useState(!1),i=d.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}},[e]);return r.jsxs("button",{onClick:i,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors relative",title:"Copy preview URL",children:[t?r.jsx(Ut,{size:14,className:"text-success"}):r.jsx(Qn,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function iv({isFullscreen:e,onToggle:t}){return r.jsx("button",{onClick:t,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:e?"Exit fullscreen":"Fullscreen preview",children:e?r.jsx(lc,{size:14}):r.jsx(on,{size:14})})}function Bl({messages:e}){const[t,s]=d.useState(!1),i=e.slice(-5),n=i.some(o=>o.level==="error");return i.length===0?null:r.jsxs("div",{className:`border-t border-border bg-card ${t?"":"cursor-pointer"}`,children:[r.jsxs("button",{onClick:()=>s(o=>!o),className:"w-full flex items-center gap-2 px-3 py-1.5 text-[11px] font-mono hover:bg-hover transition-colors",children:[n?r.jsx(Rs,{size:12,className:"text-danger"}):r.jsx("span",{className:"w-3 h-3 rounded-full border border-muted/40 flex items-center justify-center text-[8px] text-muted",children:"i"}),r.jsxs("span",{className:`font-medium ${n?"text-danger":"text-muted"}`,children:["Console (",i.length,")"]}),r.jsx("div",{className:"flex-1"}),t?r.jsx(ls,{size:12}):r.jsx(dr,{size:12})]}),t&&r.jsx("div",{className:"max-h-32 overflow-y-auto terminal-scroll border-t border-border",children:i.map((o,a)=>r.jsxs("div",{className:`px-3 py-1 text-[11px] font-mono border-b border-border/50 last:border-b-0 ${o.level==="error"?"bg-danger/5 text-danger":o.level==="warn"?"bg-warning/5 text-warning":"text-muted"}`,children:[r.jsx("span",{className:"uppercase text-[9px] font-semibold mr-2 opacity-60",children:o.level}),o.message]},a))})]})}function rv({onClick:e,isRefreshing:t}){const[s,i]=d.useState(!1),n=d.useCallback(()=>{i(!0),e(),setTimeout(()=>i(!1),600)},[e]);return r.jsx("button",{onClick:n,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Refresh preview",children:r.jsx(Dd,{size:14,className:s||t?"animate-spin-once":""})})}function Tl(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-card p-8",children:[r.jsxs("div",{className:"w-full max-w-md space-y-4",children:[r.jsx("div",{className:"skeleton-shimmer h-10 w-full rounded"}),r.jsx("div",{className:"skeleton-shimmer h-32 w-full rounded"}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"})]}),r.jsx("div",{className:"skeleton-shimmer h-8 w-48 rounded mx-auto"})]}),r.jsx("p",{className:"text-xs text-muted mt-6 animate-pulse",children:"Loading preview..."})]})}function nv({url:e}){const[t,s]=d.useState(!1),i=d.useRef(null);return d.useEffect(()=>{if(!t)return;const n=o=>{i.current&&!i.current.contains(o.target)&&s(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[t]),r.jsxs("div",{className:"relative",ref:i,children:[r.jsx("button",{onClick:()=>s(n=>!n),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors text-[10px] font-semibold",title:"Show QR code",children:"QR"}),t&&r.jsxs("div",{className:"absolute top-full right-0 mt-1 z-30 bg-card border border-border rounded-btn shadow-lg p-3",children:[r.jsx(ev,{data:e,size:100}),r.jsx("p",{className:"text-[10px] text-muted text-center mt-2 max-w-[100px] truncate",children:e})]})]})}const zl={create:"bg-primary/8 text-primary border-primary/15 hover:bg-primary/15",improve:"bg-info/8 text-info border-info/15 hover:bg-info/15",fix:"bg-danger/8 text-danger border-danger/15 hover:bg-danger/15",test:"bg-teal/8 text-teal border-teal/15 hover:bg-teal/15",deploy:"bg-warning/8 text-warning border-warning/15 hover:bg-warning/15"};function ov(e){const{projectState:t,hasSession:s,files:i,lastError:n,phase:o}=e;if(!s||t==="empty")return[{label:"Build a SaaS dashboard",prompt:"Build a modern SaaS analytics dashboard with charts and dark mode",category:"create"},{label:"Create a CLI tool",prompt:"Create a CLI tool with commands, flags, and help text",category:"create"},{label:"Build a REST API",prompt:"Build a REST API with CRUD endpoints, authentication, and database",category:"create"},{label:"Make a landing page",prompt:"Create a beautiful landing page with hero, features, pricing, and CTA sections",category:"create"}];if(t==="failed"){const a=[{label:"Fix the build errors",prompt:"Fix all build errors and get the project to compile successfully",category:"fix"},{label:"Try a different approach",prompt:"The current approach has issues. Try an alternative implementation strategy",category:"fix"}];if(n){const l=n.length>60?n.slice(0,60)+"...":n;a.unshift({label:`Fix: ${l}`,prompt:`Fix this error: ${n}`,category:"fix"})}return a.push({label:"Add error handling",prompt:"Add comprehensive error handling and fallbacks throughout the codebase",category:"improve"}),a.slice(0,4)}if(t==="building")return[];if(t==="completed"||t==="idle"){const a=[],l=i==null?void 0:i.some(m=>m.path.toLowerCase().includes("auth")),h=i==null?void 0:i.some(m=>m.path.includes(".test.")||m.path.includes(".spec.")||m.path.includes("__tests__")),c=i==null?void 0:i.some(m=>m.path.endsWith(".css")||m.path.endsWith(".scss")),u=i==null?void 0:i.some(m=>m.path.includes("Dockerfile")||m.path.includes("docker-compose"));return l||a.push({label:"Add authentication",prompt:"Add user authentication with login, signup, and session management",category:"improve"}),h||a.push({label:"Add test suite",prompt:"Add comprehensive unit tests and integration tests for all major features",category:"test"}),a.push({label:"Improve the UI",prompt:"Improve the UI with better styling, animations, and responsive design",category:"improve"}),u||a.push({label:"Add Docker support",prompt:"Add Dockerfile and docker-compose.yml for containerized deployment",category:"deploy"}),l&&a.push({label:"Add role-based access",prompt:"Add role-based access control with admin, editor, and viewer roles",category:"improve"}),c||a.push({label:"Add dark mode",prompt:"Add a dark mode toggle with proper theme support across all components",category:"improve"}),a.push({label:"Add API docs",prompt:"Add OpenAPI/Swagger documentation for all API endpoints",category:"improve"}),a.push({label:"Performance optimization",prompt:"Optimize performance: add lazy loading, caching, code splitting, and minimize bundle size",category:"improve"}),a.slice(0,4)}return[]}function av(e){const{onSelect:t,className:s=""}=e,[i,n]=d.useState(!0),[o,a]=d.useState(!1),l=d.useMemo(()=>ov(e),[e.projectState,e.hasSession,e.files,e.lastError,e.phase]),[h,c]=d.useState(0);if(d.useEffect(()=>{if(l.length<=4)return;const m=setInterval(()=>{a(!0),setTimeout(()=>{c(f=>(f+1)%l.length),a(!1)},300)},3e4);return()=>clearInterval(m)},[l.length]),l.length===0||!i)return null;const u=l.slice(h,h+4).concat(h+4>l.length?l.slice(0,h+4-l.length):[]).slice(0,4);return r.jsxs("div",{className:`${s}`,children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Sd,{size:12,className:"text-primary"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Suggestions"})]}),r.jsx("div",{className:`flex flex-wrap gap-1.5 transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:u.map((m,f)=>r.jsxs("button",{onClick:()=>t(m.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
256
231
|
border rounded-pill transition-all duration-200 cursor-pointer
|
|
257
232
|
${zl[m.category]||zl.create}
|
|
258
|
-
`,children:[m.label,r.jsx(Zn,{size:10,className:"opacity-50"})]},`${m.label}-${f}`))})]})}function Gt(e,t){if(e.length===0)return e;const s=[...e],i=s[s.length-1];return s[s.length-1]={...i,...t(i)},s}function
|
|
259
|
-
`))n.startsWith("__FILE_CHANGE__")?s.push(n.replace("__FILE_CHANGE__","")):n.startsWith("__COMMAND__")?i.push(n.replace("__COMMAND__","")):t.push(n);return{textLines:t,fileChanges:s,commands:i}}function
|
|
233
|
+
`,children:[m.label,r.jsx(Zn,{size:10,className:"opacity-50"})]},`${m.label}-${f}`))})]})}function Gt(e,t){if(e.length===0)return e;const s=[...e],i=s[s.length-1];return s[s.length-1]={...i,...t(i)},s}function lv(e){const t=[],s=[],i=[];for(const n of e.split(`
|
|
234
|
+
`))n.startsWith("__FILE_CHANGE__")?s.push(n.replace("__FILE_CHANGE__","")):n.startsWith("__COMMAND__")?i.push(n.replace("__COMMAND__","")):t.push(n);return{textLines:t,fileChanges:s,commands:i}}function cv({msgIndex:e}){const[t,s]=d.useState(null),i=n=>{s(t===n?null:n)};return r.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[r.jsx("button",{onClick:()=>i("up"),className:`p-1 rounded transition-colors ${t==="up"?"text-primary bg-primary/10":"text-muted/40 hover:text-primary hover:bg-primary/5"}`,title:"Helpful response","aria-label":"Thumbs up",children:r.jsx(zd,{size:12})}),r.jsx("button",{onClick:()=>i("down"),className:`p-1 rounded transition-colors ${t==="down"?"text-red-400 bg-red-400/10":"text-muted/40 hover:text-red-400 hover:bg-red-400/5"}`,title:"Not helpful","aria-label":"Thumbs down",children:r.jsx(Bu,{size:12})})]})}const Yn=[{id:"@file",label:"@file",description:"Reference a file in your project",icon:Z},{id:"@template",label:"@template",description:"Reference a template",icon:wd},{id:"@docs",label:"@docs",description:"Reference documentation",icon:Gs}];function hv({visible:e,filter:t,onSelect:s,onClose:i,selectedIndex:n}){if(!e)return null;const o=Yn.filter(a=>a.label.toLowerCase().includes(t.toLowerCase()));return o.length===0?null:r.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-1 bg-card border border-border rounded-lg shadow-lg py-1 z-50",children:[r.jsx("div",{className:"px-3 py-1",children:r.jsxs("span",{className:"text-[10px] text-muted font-semibold uppercase tracking-wider flex items-center gap-1",children:[r.jsx(Ud,{size:10}),"Mentions"]})}),o.map((a,l)=>{const h=a.icon;return r.jsxs("button",{onClick:()=>s(a.label),className:`w-full flex items-center gap-2 px-3 py-2 text-xs transition-colors text-left ${l===n?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(h,{size:14,className:l===n?"text-primary":"text-muted"}),r.jsx("span",{className:"font-medium",children:a.label}),r.jsx("span",{className:"text-muted text-[11px]",children:a.description})]},a.id)})]})}function dv(){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]}),r.jsx("span",{className:"text-[11px] text-muted italic",children:"Loki is thinking..."})]})}function uv({msg:e,msgIndex:t}){var l;const[s,i]=d.useState(!1),n=d.useMemo(()=>e.role==="system"?lv(e.content):null,[e.role,e.content]);if(e.role==="user")return r.jsx("div",{className:"flex justify-end",children:r.jsxs("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-primary/10 text-ink",children:[e.imageUrl&&r.jsxs("div",{className:"mb-2",children:[r.jsx("img",{src:e.imageUrl,alt:e.imageName||"Uploaded image",className:"max-w-full max-h-48 rounded border border-border object-contain"}),e.imageName&&r.jsx("span",{className:"text-[10px] text-muted mt-0.5 block",children:e.imageName})]}),r.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:e.content})]})});const o=n?n.textLines.join(`
|
|
260
235
|
`).trim():e.content,a=o.split(`
|
|
261
236
|
`).length>30;return r.jsxs("div",{className:"flex justify-start gap-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsxs("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:[n&&n.commands.length>0&&r.jsx("div",{className:"mb-2 space-y-0.5",children:n.commands.map((h,c)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono text-muted bg-card/50 px-2 py-0.5 rounded",children:[r.jsx(es,{size:10,className:"text-muted/60 flex-shrink-0"}),r.jsx("span",{className:"truncate",children:h})]},c))}),r.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:[a&&!s?o.split(`
|
|
262
237
|
`).slice(0,30).join(`
|
|
263
238
|
`)+`
|
|
264
239
|
...`:o,e.isStreaming&&r.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-primary/60 animate-pulse ml-0.5 align-text-bottom"})]}),a&&!e.isStreaming&&r.jsx("button",{onClick:()=>i(h=>!h),className:"text-[10px] text-primary hover:text-primary/80 mt-1 font-medium",children:s?"Show less":`Show all (${o.split(`
|
|
265
|
-
`).length} lines)`}),n&&n.fileChanges.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(Z,{size:11}),"Files modified (",n.fileChanges.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:n.fileChanges.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-primary/80",children:h},c))})]}),e.filesChanged&&e.filesChanged.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(Z,{size:11}),"Changed files (",e.filesChanged.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:e.filesChanged.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-muted",children:h},c))})]}),e.role==="system"&&!e.isStreaming&&e.returncode!==void 0&&r.jsx("div",{className:"mt-1 text-[10px] text-muted",children:e.returncode===0?r.jsxs("span",{children:["Done",n&&(n.fileChanges.length>0||e.filesChanged&&e.filesChanged.length>0)?` -- ${n.fileChanges.length+(((l=e.filesChanged)==null?void 0:l.length)||0)} files changed`:"",n&&n.commands.length>0?`, ${n.commands.length} commands run`:""]}):r.jsxs("span",{className:"text-red-400",children:["Task failed. ",e.returncode===124?"Timed out.":"Check the output above for error details."]})}),e.role==="system"&&!e.isStreaming&&e.content&&r.jsx(
|
|
266
|
-
[cancelled]`}:{})),(z=k.current)==null||z.focus()},[e]),Q=d.useCallback(async z=>{var
|
|
240
|
+
`).length} lines)`}),n&&n.fileChanges.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(Z,{size:11}),"Files modified (",n.fileChanges.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:n.fileChanges.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-primary/80",children:h},c))})]}),e.filesChanged&&e.filesChanged.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(Z,{size:11}),"Changed files (",e.filesChanged.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:e.filesChanged.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-muted",children:h},c))})]}),e.role==="system"&&!e.isStreaming&&e.returncode!==void 0&&r.jsx("div",{className:"mt-1 text-[10px] text-muted",children:e.returncode===0?r.jsxs("span",{children:["Done",n&&(n.fileChanges.length>0||e.filesChanged&&e.filesChanged.length>0)?` -- ${n.fileChanges.length+(((l=e.filesChanged)==null?void 0:l.length)||0)} files changed`:"",n&&n.commands.length>0?`, ${n.commands.length} commands run`:""]}):r.jsxs("span",{className:"text-red-400",children:["Task failed. ",e.returncode===124?"Timed out.":"Check the output above for error details."]})}),e.role==="system"&&!e.isStreaming&&e.content&&r.jsx(cv,{msgIndex:t})]})]})}const fv={quick:"Quick: Fast single-task fix (3 iterations max)",standard:"Standard: Thorough implementation with testing",max:"Max: Full autonomous build from your description"};function mv({sessionId:e,defaultMode:t,onFilesChanged:s,services:i}){var ue;const[n,o]=d.useState([]),[a,l]=d.useState(""),[h,c]=d.useState(t||"quick"),[u,m]=d.useState(!1),[f,_]=d.useState(!1),[p,g]=d.useState(null),[v,y]=d.useState(!1),x=d.useRef(null),k=d.useRef(null),j=d.useRef(null),w=d.useRef(null),D=d.useRef(null),T=d.useRef(null);d.useEffect(()=>{const z=sessionStorage.getItem(`chat_${e}`);if(z)try{o(JSON.parse(z))}catch{}},[e]),d.useEffect(()=>{n.length>0&&sessionStorage.setItem(`chat_${e}`,JSON.stringify(n.slice(-50)))},[n,e]),d.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[n]),d.useEffect(()=>()=>{w.current&&w.current.abort(),p!=null&&p.previewUrl&&URL.revokeObjectURL(p.previewUrl)},[]);const U=d.useCallback(z=>{if(!z.type.startsWith("image/"))return;p!=null&&p.previewUrl&&URL.revokeObjectURL(p.previewUrl);const V=URL.createObjectURL(z);g({file:z,previewUrl:V})},[p==null?void 0:p.previewUrl]),G=d.useCallback(()=>{p!=null&&p.previewUrl&&URL.revokeObjectURL(p.previewUrl),g(null)},[p==null?void 0:p.previewUrl]);d.useEffect(()=>{const z=V=>{var R;const J=(R=V.clipboardData)==null?void 0:R.items;if(J){for(const ae of J)if(ae.type.startsWith("image/")){V.preventDefault();const _e=ae.getAsFile();_e&&U(_e);return}}};return document.addEventListener("paste",z),()=>document.removeEventListener("paste",z)},[U]);const[K,A]=d.useState(!1),[M,E]=d.useState(!1),[L,S]=d.useState(""),[N,C]=d.useState(0),B=d.useCallback(z=>{z.preventDefault(),z.stopPropagation(),z.dataTransfer.types.includes("Files")&&A(!0)},[]),X=d.useCallback(z=>{z.preventDefault(),z.stopPropagation(),A(!1)},[]),oe=d.useCallback(z=>{z.preventDefault(),z.stopPropagation(),A(!1);const V=z.dataTransfer.files;if(V.length>0){const J=V[0];J.type.startsWith("image/")&&U(J)}},[U]),q=d.useCallback(async()=>{var z;if(w.current&&(w.current.abort(),w.current=null),D.current){try{await W.chatCancel(e,D.current)}catch{}D.current=null}_(!1),m(!1),o(V=>Gt(V,J=>J.isStreaming?{isStreaming:!1,content:J.content+`
|
|
241
|
+
[cancelled]`}:{})),(z=k.current)==null||z.focus()},[e]),Q=d.useCallback(async z=>{var ae;let J=0,R;do{if(await new Promise(_e=>setTimeout(_e,2e3)),R=await W.chatPoll(e,z),J++,R.output_lines.length>0){const _e=R.output_lines.join(`
|
|
267
242
|
`);o(Ee=>Gt(Ee,ee=>ee.role==="system"&&ee.isStreaming?{content:_e}:{}))}J>=150&&(R={complete:!0,output_lines:["Task timed out after 5 minutes. The AI may still be working in the background. Try checking the terminal or refreshing."],files_changed:[],returncode:1})}while(!R.complete);o(_e=>Gt(_e,Ee=>Ee.role==="system"?{isStreaming:!1,content:R.output_lines.join(`
|
|
268
|
-
`)||"Done.",filesChanged:R.files_changed,returncode:R.returncode}:{})),((
|
|
243
|
+
`)||"Done.",filesChanged:R.files_changed,returncode:R.returncode}:{})),((ae=R.files_changed)==null?void 0:ae.length)>0&&s&&s(R.files_changed)},[e,s]),ie=d.useCallback(async z=>{var J;const V=new AbortController;w.current=V,D.current=z,_(!0);try{const R=W.chatStreamUrl(e,z),ae=await fetch(R,{signal:V.signal});if(!ae.ok||!ae.body)throw new Error(`Stream failed: ${ae.status}`);const _e=ae.body.getReader(),Ee=new TextDecoder;let ee="";for(;;){const{done:fe,value:ge}=await _e.read();if(fe)break;ee+=Ee.decode(ge,{stream:!0});const Ce=ee.split(`
|
|
269
244
|
|
|
270
245
|
`);ee=Ce.pop()||"";for(const Ge of Ce){if(!Ge.trim())continue;const Ls=Ge.split(`
|
|
271
|
-
`);let us="",et="";for(const
|
|
272
|
-
`+ce:ce}:{}))}catch{}else if(us==="complete"&&et)try{const{returncode:ce,files_changed:ot}=JSON.parse(et);o(at=>Gt(at,fs=>fs.role==="system"&&fs.isStreaming?{isStreaming:!1,filesChanged:ot,returncode:ce,content:fs.content||"Done."}:{})),(ot==null?void 0:ot.length)>0&&s&&s(ot)}catch{}else if(us==="error"&&et)try{const{error:ce}=JSON.parse(et);o(ot=>Gt(ot,at=>at.role==="system"&&at.isStreaming?{isStreaming:!1,content:`Error: ${ce}`}:{}))}catch{}}}}catch(R){if(R instanceof DOMException&&R.name==="AbortError")return;await Q(z)}finally{_(!1),m(!1),w.current=null,D.current=null,(J=k.current)==null||J.focus()}},[e,s,Q]),de=async()=>{var ee;const z=a.trim();if(!z&&!p||u)return;let V,J,R="";if(p){y(!0);try{const fe=await W.chatImageUpload(e,p.file);V=p.previewUrl,J=fe.filename,R=`[Attached image: ${fe.filename} (id: ${fe.image_id})] Make it look like this. `}catch{}y(!1)}const le=R+(z||"Make changes based on this screenshot."),_e={role:"user",content:z||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:V,imageName:J},Ee={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(fe=>[...fe,_e,Ee]),l(""),g(null),m(!0);try{const fe=n.filter(Ce=>Ce.role==="user"||Ce.role==="system"&&!Ce.isStreaming&&Ce.content).slice(-10).map(Ce=>({role:Ce.role==="user"?"user":"assistant",content:Ce.content})),{task_id:ge}=await W.chatStart(e,le,h,fe.length>0?fe:void 0);await ie(ge)}catch(fe){o(ge=>Gt(ge,Ce=>Ce.role==="system"&&Ce.isStreaming?{isStreaming:!1,content:`Error: ${fe instanceof Error?fe.message:"Request failed"}`}:{})),m(!1),(ee=k.current)==null||ee.focus()}};return r.jsxs("div",{ref:T,className:`flex flex-col h-full relative ${K?"ring-2 ring-primary ring-inset":""}`,onDragOver:B,onDragLeave:X,onDrop:oe,children:[K&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 backdrop-blur-sm",children:r.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[r.jsx(aa,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[n.length===0&&r.jsxs("div",{className:"flex items-start gap-2 py-6 px-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:r.jsx("p",{className:"leading-relaxed",children:"Hey! I'm Loki, your AI coding companion. Tell me what you want to build and I'll make it happen."})})]}),n.map((z,V)=>r.jsx(_v,{msg:z,msgIndex:V},V)),f&&r.jsx(gv,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[f&&r.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[r.jsxs("span",{className:"text-[10px] text-muted font-mono flex items-center gap-1.5",children:["Loki is thinking",r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]})]}),r.jsxs("button",{onClick:q,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(tr,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!f&&(i==null?void 0:i.some(z=>z.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Ul,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(ue=i.find(z=>z.fix_status==="fixing"))==null?void 0:ue.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(z=>r.jsx("button",{onClick:()=>c(z),title:xv[z],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===z?"bg-primary text-white":"text-muted hover:text-ink"}`,children:z},z))}),p&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:p.previewUrl,alt:"Pending upload",className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:G,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-red-500 text-white rounded-full flex items-center justify-center hover:bg-red-600",title:"Remove image",children:r.jsx(ft,{size:10})})]}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[150px]",children:p.file.name}),v&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),!f&&r.jsx(uv,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:z=>l(z),className:"mb-2"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:N,type:"file",accept:"image/*",className:"hidden",onChange:z=>{var J;const V=(J=z.target.files)==null?void 0:J[0];V&&U(V),z.target.value=""}}),r.jsx("button",{onClick:()=>{var z;return(z=N.current)==null?void 0:z.click()},disabled:u,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)",children:r.jsx(aa,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(pv,{visible:M,filter:L,selectedIndex:j,onSelect:z=>{var R;const V=a.lastIndexOf("@"),J=V>=0?a.slice(0,V):a;l(J+z+" "),E(!1),C(0),(R=k.current)==null||R.focus()},onClose:()=>E(!1)}),r.jsx("textarea",{ref:k,value:a,onChange:z=>{const V=z.target.value;l(V);const J=V.lastIndexOf("@");if(J>=0){const R=V.slice(J);/^@\w*$/.test(R)?(E(!0),S(R),C(0)):E(!1)}else E(!1)},onKeyDown:z=>{if(M){if(z.key==="ArrowDown"){z.preventDefault(),C(V=>Math.min(V+1,Yn.length-1));return}if(z.key==="ArrowUp"){z.preventDefault(),C(V=>Math.max(V-1,0));return}if(z.key==="Tab"||z.key==="Enter"&&!z.shiftKey){z.preventDefault();const V=Yn.filter(J=>J.label.toLowerCase().includes(L.toLowerCase()));if(V[j]){const J=a.lastIndexOf("@"),R=J>=0?a.slice(0,J):a;l(R+V[j].label+" "),E(!1),C(0)}return}if(z.key==="Escape"){E(!1);return}}z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),de())},placeholder:"Ask AI to modify your project... (Shift+Enter for new line)",rows:1,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none",style:{maxHeight:"120px",overflow:"auto"},disabled:u})]}),f?r.jsx(he,{size:"sm",icon:tr,onClick:q,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(he,{size:"sm",icon:Du,onClick:de,disabled:u||!a.trim()&&!p,"aria-label":"Send message",children:"Send"})]})]})]})}function bv(e){const t=[],s=e.gatePassRate*100;t.push({label:"Quality Gates",value:s,weight:.4,description:`${Math.round(s)}% of quality gates passing`});const i=Math.min(e.testCoverage,100);t.push({label:"Test Coverage",value:i,weight:.3,description:`${Math.round(i)}% code covered by tests`});const n=e.maxIterations>0?Math.min(e.iteration/e.maxIterations*100,100):50;t.push({label:"Iteration Progress",value:n,weight:.2,description:`${e.iteration}/${e.maxIterations} iterations completed`});const a={planning:30,building:50,testing:75,reviewing:90,complete:100,idle:0}[e.phase]??40;t.push({label:"Build Phase",value:a,weight:.1,description:`Currently in ${e.phase} phase`});const l=t.reduce((h,c)=>h+c.value*c.weight,0);return{score:Math.round(Math.min(l,100)),factors:t}}function Eh(e){return e>=80?{ring:"#1FC5A8",text:"text-success",bg:"bg-success/10",label:"High"}:e>=60?{ring:"#D4A03C",text:"text-warning",bg:"bg-warning/10",label:"Medium"}:{ring:"#C45B5B",text:"text-danger",bg:"bg-danger/10",label:"Low"}}function Al({score:e,size:t=48}){const s=t<40?3:4,i=(t-s*2)/2,n=2*Math.PI*i,o=e/100*n,a=Eh(e);return r.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:t,height:t},children:[r.jsxs("svg",{width:t,height:t,className:"-rotate-90",children:[r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",className:"text-border",strokeWidth:s}),r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:a.ring,strokeWidth:s,strokeLinecap:"round",strokeDasharray:n,strokeDashoffset:n-o,className:"transition-all duration-1000 ease-out"})]}),r.jsx("span",{className:`absolute text-center font-mono font-bold ${a.text}`,style:{fontSize:t<40?"10px":"12px"},children:e})]})}function yv(e){const[t,s]=d.useState(!1),{score:i,factors:n}=bv(e),o=Eh(i);return e.compact?r.jsxs("div",{className:"relative inline-flex items-center gap-1.5",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[r.jsx(Al,{score:i,size:28}),r.jsx("span",{className:`text-xs font-medium ${o.text}`,children:o.label}),t&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 w-56",children:[r.jsxs("div",{className:"text-xs font-semibold text-ink mb-2",children:["AI Confidence: ",i,"%"]}),n.map(a=>r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted mb-1",children:[r.jsx("span",{children:a.label}),r.jsxs("span",{className:"font-mono",children:[Math.round(a.value),"%"]})]},a.label))]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]}):r.jsxs("div",{className:"card p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsx(Al,{score:i,size:56}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"AI Confidence"}),r.jsxs("div",{className:`text-xs font-medium ${o.text} flex items-center gap-1`,children:[o.label," Confidence",r.jsxs("div",{className:"relative",children:[r.jsx(Kl,{size:12,className:"text-muted cursor-help",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)}),t&&r.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 w-64 pointer-events-none",children:r.jsx("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2",children:r.jsx("p",{className:"text-[11px] text-muted leading-relaxed",children:"Confidence is computed from quality gate pass rate (40%), test coverage (30%), iteration progress (20%), and build phase maturity (10%)."})})})]})]})]})]}),r.jsx("div",{className:"space-y-2.5",children:n.map(a=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-xs text-secondary",children:a.label}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[Math.round(a.value),"%"]})]}),r.jsx("div",{className:"w-full h-1.5 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out ${a.value>=80?"bg-success":a.value>=60?"bg-warning":"bg-danger"}`,style:{width:`${Math.min(a.value,100)}%`}})}),r.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:a.description})]},a.label))})]})}function Zi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Qi(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function Sv(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function wv(e){return e>=90?{label:"Excellent",color:"text-success"}:e>=75?{label:"Good",color:"text-teal"}:e>=60?{label:"Fair",color:"text-warning"}:{label:"Needs Work",color:"text-danger"}}function bs({icon:e,label:t,value:s,subtext:i,iconColor:n="text-primary"}){return r.jsxs("div",{className:"bg-hover/40 rounded-card p-3 flex flex-col items-center text-center",children:[r.jsx(e,{size:18,className:`${n} mb-1.5`}),r.jsx("div",{className:"text-lg font-bold font-mono text-ink leading-tight",children:s}),r.jsx("div",{className:"text-[11px] text-muted font-medium mt-0.5",children:t}),i&&r.jsx("div",{className:"text-[11px] text-muted/60 mt-0.5",children:i})]})}function Cv({phase:e,maxDuration:t}){const s=t>0?e.durationSecs/t*100:0,i={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-secondary w-16 text-right flex-shrink-0",children:e.label}),r.jsxs("div",{className:"flex-1 h-4 bg-border rounded-sm overflow-hidden relative",children:[r.jsx("div",{className:`h-full rounded-sm transition-all duration-700 ease-out ${i[e.phase]||"bg-primary"}`,style:{width:`${s}%`}}),r.jsxs("span",{className:"absolute inset-0 flex items-center px-2 text-[10px] font-mono text-white mix-blend-difference",children:[Qi(e.durationSecs)," | ",Zi(e.tokenCount)," tokens"]})]}),r.jsxs("span",{className:"text-[11px] font-mono text-muted w-10 text-right flex-shrink-0",children:[Math.round(e.percentage),"%"]})]})}function kv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:l,qualityScore:h,totalCost:c,iterations:u,provider:m,onShare:f,className:_=""}){const[p,g]=d.useState(!0),v=wv(h),y=Math.max(...a.map(k=>k.durationSecs),1),x=()=>{const k=["Build Insights Summary","=====================",`Provider: ${m}`,`Total Time: ${Qi(l)}`,`Iterations: ${u}`,`Cost: $${c.toFixed(2)}`,"","Output:",` Files Created: ${e}`,` Files Modified: ${t}`,` Lines Generated: ${s}`,` Tests Generated: ${i}`,` Test Pass Rate: ${Math.round(n*100)}%`,"","Resources:",` Total Tokens: ${Zi(o)}`,` Quality Score: ${h}/100 (${v.label})`,"","Time Breakdown:",...a.map(N=>` ${N.label}: ${Qi(N.durationSecs)} (${Math.round(N.percentage)}%)`)].join(`
|
|
273
|
-
`);f==null||f(k)};return r.jsxs("div",{className:`card overflow-hidden ${_}`,children:[r.jsxs("button",{onClick:()=>g(!p),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-hover/30 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Qr,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Insights"}),r.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded-pill ${h>=80?"bg-success/10 text-success":h>=60?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:v.label})]}),r.jsx("span",{className:"text-muted",children:p?r.jsx(dr,{size:16}):r.jsx(ls,{size:16})})]}),p&&r.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(bs,{icon:Z,label:"Files",value:String(e+t),subtext:`${e} new, ${t} modified`,iconColor:"text-primary"}),r.jsx(bs,{icon:
|
|
274
|
-
text-primary hover:bg-primary/5 rounded-card transition-colors`,children:[r.jsx(no,{size:12}),"Share Insights"]})})]})]})}const Ol=[1,2,5];function
|
|
275
|
-
`);a==null||a(C)},L=x>0?m/x*100:0;return _?r.jsxs("div",{className:"card overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Replay"}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("button",{onClick:()=>p(!1),className:"text-xs text-muted hover:text-ink transition-colors",children:"Collapse"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0 min-h-[240px]",children:[r.jsxs("div",{className:"border-r border-border p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"File Tree"}),t.filter(C=>C.type==="file").length===0?r.jsx("div",{className:"text-xs text-muted py-4 text-center",children:"No files to display"}):t.filter(C=>C.type==="file").map((C,B)=>r.jsx(
|
|
246
|
+
`);let us="",et="";for(const le of Ls)le.startsWith("event:")?us=le.slice(6).trim():le.startsWith("data:")&&(et=le.slice(5).trim());if(us==="output"&&et)try{const{line:le}=JSON.parse(et);o(ot=>Gt(ot,at=>at.role==="system"&&at.isStreaming?{content:at.content?at.content+`
|
|
247
|
+
`+le:le}:{}))}catch{}else if(us==="complete"&&et)try{const{returncode:le,files_changed:ot}=JSON.parse(et);o(at=>Gt(at,fs=>fs.role==="system"&&fs.isStreaming?{isStreaming:!1,filesChanged:ot,returncode:le,content:fs.content||"Done."}:{})),(ot==null?void 0:ot.length)>0&&s&&s(ot)}catch{}else if(us==="error"&&et)try{const{error:le}=JSON.parse(et);o(ot=>Gt(ot,at=>at.role==="system"&&at.isStreaming?{isStreaming:!1,content:`Error: ${le}`}:{}))}catch{}}}}catch(R){if(R instanceof DOMException&&R.name==="AbortError")return;await Q(z)}finally{_(!1),m(!1),w.current=null,D.current=null,(J=k.current)==null||J.focus()}},[e,s,Q]),de=async()=>{var ee;const z=a.trim();if(!z&&!p||u)return;let V,J,R="";if(p){y(!0);try{const fe=await W.chatImageUpload(e,p.file);V=p.previewUrl,J=fe.filename,R=`[Attached image: ${fe.filename} (id: ${fe.image_id})] Make it look like this. `}catch{}y(!1)}const ae=R+(z||"Make changes based on this screenshot."),_e={role:"user",content:z||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:V,imageName:J},Ee={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(fe=>[...fe,_e,Ee]),l(""),g(null),m(!0);try{const fe=n.filter(Ce=>Ce.role==="user"||Ce.role==="system"&&!Ce.isStreaming&&Ce.content).slice(-10).map(Ce=>({role:Ce.role==="user"?"user":"assistant",content:Ce.content})),{task_id:ge}=await W.chatStart(e,ae,h,fe.length>0?fe:void 0);await ie(ge)}catch(fe){o(ge=>Gt(ge,Ce=>Ce.role==="system"&&Ce.isStreaming?{isStreaming:!1,content:`Error: ${fe instanceof Error?fe.message:"Request failed"}`}:{})),m(!1),(ee=k.current)==null||ee.focus()}};return r.jsxs("div",{ref:T,className:`flex flex-col h-full relative ${K?"ring-2 ring-primary ring-inset":""}`,onDragOver:B,onDragLeave:X,onDrop:oe,children:[K&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 backdrop-blur-sm",children:r.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[r.jsx(aa,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[n.length===0&&r.jsxs("div",{className:"flex items-start gap-2 py-6 px-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:r.jsx("p",{className:"leading-relaxed",children:"Hey! I'm Loki, your AI coding companion. Tell me what you want to build and I'll make it happen."})})]}),n.map((z,V)=>r.jsx(uv,{msg:z,msgIndex:V},V)),f&&r.jsx(dv,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[f&&r.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[r.jsxs("span",{className:"text-[10px] text-muted font-mono flex items-center gap-1.5",children:["Loki is thinking",r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]})]}),r.jsxs("button",{onClick:q,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(tr,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!f&&(i==null?void 0:i.some(z=>z.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Ul,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(ue=i.find(z=>z.fix_status==="fixing"))==null?void 0:ue.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(z=>r.jsx("button",{onClick:()=>c(z),title:fv[z],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===z?"bg-primary text-white":"text-muted hover:text-ink"}`,children:z},z))}),p&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:p.previewUrl,alt:"Pending upload",className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:G,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-red-500 text-white rounded-full flex items-center justify-center hover:bg-red-600",title:"Remove image",children:r.jsx(ft,{size:10})})]}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[150px]",children:p.file.name}),v&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),!f&&r.jsx(av,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:z=>l(z),className:"mb-2"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:j,type:"file",accept:"image/*",className:"hidden",onChange:z=>{var J;const V=(J=z.target.files)==null?void 0:J[0];V&&U(V),z.target.value=""}}),r.jsx("button",{onClick:()=>{var z;return(z=j.current)==null?void 0:z.click()},disabled:u,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)",children:r.jsx(aa,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(hv,{visible:M,filter:L,selectedIndex:N,onSelect:z=>{var R;const V=a.lastIndexOf("@"),J=V>=0?a.slice(0,V):a;l(J+z+" "),E(!1),C(0),(R=k.current)==null||R.focus()},onClose:()=>E(!1)}),r.jsx("textarea",{ref:k,value:a,onChange:z=>{const V=z.target.value;l(V);const J=V.lastIndexOf("@");if(J>=0){const R=V.slice(J);/^@\w*$/.test(R)?(E(!0),S(R),C(0)):E(!1)}else E(!1)},onKeyDown:z=>{if(M){if(z.key==="ArrowDown"){z.preventDefault(),C(V=>Math.min(V+1,Yn.length-1));return}if(z.key==="ArrowUp"){z.preventDefault(),C(V=>Math.max(V-1,0));return}if(z.key==="Tab"||z.key==="Enter"&&!z.shiftKey){z.preventDefault();const V=Yn.filter(J=>J.label.toLowerCase().includes(L.toLowerCase()));if(V[N]){const J=a.lastIndexOf("@"),R=J>=0?a.slice(0,J):a;l(R+V[N].label+" "),E(!1),C(0)}return}if(z.key==="Escape"){E(!1);return}}z.key==="Enter"&&!z.shiftKey&&(z.preventDefault(),de())},placeholder:"Ask AI to modify your project... (Shift+Enter for new line)",rows:1,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none",style:{maxHeight:"120px",overflow:"auto"},disabled:u})]}),f?r.jsx(he,{size:"sm",icon:tr,onClick:q,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(he,{size:"sm",icon:ju,onClick:de,disabled:u||!a.trim()&&!p,"aria-label":"Send message",children:"Send"})]})]})]})}function pv(e){const t=[],s=e.gatePassRate*100;t.push({label:"Quality Gates",value:s,weight:.4,description:`${Math.round(s)}% of quality gates passing`});const i=Math.min(e.testCoverage,100);t.push({label:"Test Coverage",value:i,weight:.3,description:`${Math.round(i)}% code covered by tests`});const n=e.maxIterations>0?Math.min(e.iteration/e.maxIterations*100,100):50;t.push({label:"Iteration Progress",value:n,weight:.2,description:`${e.iteration}/${e.maxIterations} iterations completed`});const a={planning:30,building:50,testing:75,reviewing:90,complete:100,idle:0}[e.phase]??40;t.push({label:"Build Phase",value:a,weight:.1,description:`Currently in ${e.phase} phase`});const l=t.reduce((h,c)=>h+c.value*c.weight,0);return{score:Math.round(Math.min(l,100)),factors:t}}function Eh(e){return e>=80?{ring:"#1FC5A8",text:"text-success",bg:"bg-success/10",label:"High"}:e>=60?{ring:"#D4A03C",text:"text-warning",bg:"bg-warning/10",label:"Medium"}:{ring:"#C45B5B",text:"text-danger",bg:"bg-danger/10",label:"Low"}}function Al({score:e,size:t=48}){const s=t<40?3:4,i=(t-s*2)/2,n=2*Math.PI*i,o=e/100*n,a=Eh(e);return r.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:t,height:t},children:[r.jsxs("svg",{width:t,height:t,className:"-rotate-90",children:[r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:"currentColor",className:"text-border",strokeWidth:s}),r.jsx("circle",{cx:t/2,cy:t/2,r:i,fill:"none",stroke:a.ring,strokeWidth:s,strokeLinecap:"round",strokeDasharray:n,strokeDashoffset:n-o,className:"transition-all duration-1000 ease-out"})]}),r.jsx("span",{className:`absolute text-center font-mono font-bold ${a.text}`,style:{fontSize:t<40?"10px":"12px"},children:e})]})}function gv(e){const[t,s]=d.useState(!1),{score:i,factors:n}=pv(e),o=Eh(i);return e.compact?r.jsxs("div",{className:"relative inline-flex items-center gap-1.5",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:[r.jsx(Al,{score:i,size:28}),r.jsx("span",{className:`text-xs font-medium ${o.text}`,children:o.label}),t&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 w-56",children:[r.jsxs("div",{className:"text-xs font-semibold text-ink mb-2",children:["AI Confidence: ",i,"%"]}),n.map(a=>r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted mb-1",children:[r.jsx("span",{children:a.label}),r.jsxs("span",{className:"font-mono",children:[Math.round(a.value),"%"]})]},a.label))]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]}):r.jsxs("div",{className:"card p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsx(Al,{score:i,size:56}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"AI Confidence"}),r.jsxs("div",{className:`text-xs font-medium ${o.text} flex items-center gap-1`,children:[o.label," Confidence",r.jsxs("div",{className:"relative",children:[r.jsx(Kl,{size:12,className:"text-muted cursor-help",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)}),t&&r.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 w-64 pointer-events-none",children:r.jsx("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2",children:r.jsx("p",{className:"text-[11px] text-muted leading-relaxed",children:"Confidence is computed from quality gate pass rate (40%), test coverage (30%), iteration progress (20%), and build phase maturity (10%)."})})})]})]})]})]}),r.jsx("div",{className:"space-y-2.5",children:n.map(a=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-xs text-secondary",children:a.label}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[Math.round(a.value),"%"]})]}),r.jsx("div",{className:"w-full h-1.5 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out ${a.value>=80?"bg-success":a.value>=60?"bg-warning":"bg-danger"}`,style:{width:`${Math.min(a.value,100)}%`}})}),r.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:a.description})]},a.label))})]})}function Zi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Qi(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function _v(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function xv(e){return e>=90?{label:"Excellent",color:"text-success"}:e>=75?{label:"Good",color:"text-teal"}:e>=60?{label:"Fair",color:"text-warning"}:{label:"Needs Work",color:"text-danger"}}function bs({icon:e,label:t,value:s,subtext:i,iconColor:n="text-primary"}){return r.jsxs("div",{className:"bg-hover/40 rounded-card p-3 flex flex-col items-center text-center",children:[r.jsx(e,{size:18,className:`${n} mb-1.5`}),r.jsx("div",{className:"text-lg font-bold font-mono text-ink leading-tight",children:s}),r.jsx("div",{className:"text-[11px] text-muted font-medium mt-0.5",children:t}),i&&r.jsx("div",{className:"text-[11px] text-muted/60 mt-0.5",children:i})]})}function vv({phase:e,maxDuration:t}){const s=t>0?e.durationSecs/t*100:0,i={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-secondary w-16 text-right flex-shrink-0",children:e.label}),r.jsxs("div",{className:"flex-1 h-4 bg-border rounded-sm overflow-hidden relative",children:[r.jsx("div",{className:`h-full rounded-sm transition-all duration-700 ease-out ${i[e.phase]||"bg-primary"}`,style:{width:`${s}%`}}),r.jsxs("span",{className:"absolute inset-0 flex items-center px-2 text-[10px] font-mono text-white mix-blend-difference",children:[Qi(e.durationSecs)," | ",Zi(e.tokenCount)," tokens"]})]}),r.jsxs("span",{className:"text-[11px] font-mono text-muted w-10 text-right flex-shrink-0",children:[Math.round(e.percentage),"%"]})]})}function bv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:l,qualityScore:h,totalCost:c,iterations:u,provider:m,onShare:f,className:_=""}){const[p,g]=d.useState(!0),v=xv(h),y=Math.max(...a.map(k=>k.durationSecs),1),x=()=>{const k=["Build Insights Summary","=====================",`Provider: ${m}`,`Total Time: ${Qi(l)}`,`Iterations: ${u}`,`Cost: $${c.toFixed(2)}`,"","Output:",` Files Created: ${e}`,` Files Modified: ${t}`,` Lines Generated: ${s}`,` Tests Generated: ${i}`,` Test Pass Rate: ${Math.round(n*100)}%`,"","Resources:",` Total Tokens: ${Zi(o)}`,` Quality Score: ${h}/100 (${v.label})`,"","Time Breakdown:",...a.map(j=>` ${j.label}: ${Qi(j.durationSecs)} (${Math.round(j.percentage)}%)`)].join(`
|
|
248
|
+
`);f==null||f(k)};return r.jsxs("div",{className:`card overflow-hidden ${_}`,children:[r.jsxs("button",{onClick:()=>g(!p),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-hover/30 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Qr,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Insights"}),r.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded-pill ${h>=80?"bg-success/10 text-success":h>=60?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:v.label})]}),r.jsx("span",{className:"text-muted",children:p?r.jsx(dr,{size:16}):r.jsx(ls,{size:16})})]}),p&&r.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(bs,{icon:Z,label:"Files",value:String(e+t),subtext:`${e} new, ${t} modified`,iconColor:"text-primary"}),r.jsx(bs,{icon:rn,label:"Lines of Code",value:_v(s),iconColor:"text-info"}),r.jsx(bs,{icon:ri,label:"Tests",value:String(i),subtext:`${Math.round(n*100)}% passing`,iconColor:"text-teal"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(bs,{icon:Zt,label:"Tokens Used",value:Zi(o),iconColor:"text-warning"}),r.jsx(bs,{icon:nt,label:"Build Time",value:Qi(l),subtext:`${u} iterations`,iconColor:"text-muted"}),r.jsx(bs,{icon:Cd,label:"Quality",value:`${h}`,subtext:v.label,iconColor:v.color})]}),r.jsxs("div",{className:"flex items-center justify-between bg-hover/40 rounded-card px-3 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx($d,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-medium text-ink",children:"Total Cost"})]}),r.jsxs("span",{className:"text-sm font-bold font-mono text-ink",children:["$",c.toFixed(2)]})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Id,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Time Breakdown"})]}),r.jsx("div",{className:"space-y-1.5",children:a.map(k=>r.jsx(vv,{phase:k,maxDuration:y},k.phase))})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Zt,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Token Distribution"})]}),r.jsx("div",{className:"flex h-3 rounded-full overflow-hidden bg-border",children:a.map(k=>{const j={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsx("div",{className:`h-full transition-all duration-700 ${j[k.phase]||"bg-primary"}`,style:{width:`${k.percentage}%`},title:`${k.label}: ${Zi(k.tokenCount)} tokens (${Math.round(k.percentage)}%)`},k.phase)})}),r.jsx("div",{className:"flex items-center justify-between mt-1",children:a.map(k=>{const j={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${j[k.phase]||"bg-primary"}`}),k.label]},k.phase)})})]}),f&&r.jsx("div",{className:"flex justify-end pt-1",children:r.jsxs("button",{onClick:x,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
|
|
249
|
+
text-primary hover:bg-primary/5 rounded-card transition-colors`,children:[r.jsx(no,{size:12}),"Share Insights"]})})]})]})}const Ol=[1,2,5];function yv(e){const t=[];let s=0;const i=600,n=["planning","building","testing","reviewing","complete"],o=e.phases.length>0?e.phases:n;for(const a of o){if(t.push({timestamp:s,type:"phase_change",label:`Phase: ${a}`,phase:a}),s+=i,a==="building")for(const l of e.files.filter(h=>h.type==="file"))t.push({timestamp:s,type:"file_created",label:l.path,detail:l.path}),s+=i*.4;if(a==="testing"||a==="reviewing")for(const l of e.qualityGates){const h=l.status==="pass"?"gate_pass":"gate_fail";t.push({timestamp:s,type:h,label:l.label,phase:a}),s+=i*.3}}for(let a=1;a<=e.totalIterations;a++){const l=a/e.totalIterations*s;t.push({timestamp:l,type:"iteration",label:`Iteration ${a}/${e.totalIterations}`})}return t.sort((a,l)=>a.timestamp-l.timestamp),t}function Sv({path:e,visible:t,delay:s}){const i=e.split("/"),n=i[i.length-1],o=i.length-1;return r.jsxs("div",{className:`flex items-center gap-1.5 py-0.5 transition-all duration-500 ${t?"opacity-100 translate-x-0":"opacity-0 -translate-x-4"}`,style:{paddingLeft:`${o*16+8}px`,transitionDelay:`${s}ms`},children:[r.jsx(Z,{size:12,className:"text-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:n})]})}function wv({sessionId:e,files:t,phases:s,checkpoints:i,qualityGates:n,totalIterations:o,onShare:a}){var S,N;const[l,h]=d.useState(!1),[c,u]=d.useState(0),[m,f]=d.useState(0),[_,p]=d.useState(!1),g=d.useRef(null),v=d.useRef(0),y=d.useRef([]);y.current.length===0&&(y.current=yv({files:t,phases:s,qualityGates:n,totalIterations:o}));const x=y.current.length>0?y.current[y.current.length-1].timestamp+600:1,k=y.current.filter(C=>C.timestamp<=m),j=new Set(k.filter(C=>C.type==="file_created").map(C=>C.detail)),w=((S=[...k].reverse().find(C=>C.type==="phase_change"))==null?void 0:S.phase)||"idle",D=k.filter(C=>C.type==="gate_pass").length,T=k.filter(C=>C.type==="gate_fail").length,U=((N=[...k].reverse().find(C=>C.type==="iteration"))==null?void 0:N.label)||"",G=Ol[c],K=d.useCallback(C=>{v.current===0&&(v.current=C);const B=(C-v.current)*G;v.current=C,f(X=>{const oe=X+B;return oe>=x?(h(!1),x):oe}),g.current=requestAnimationFrame(K)},[G,x]);d.useEffect(()=>(l?(v.current=0,g.current=requestAnimationFrame(K)):g.current&&cancelAnimationFrame(g.current),()=>{g.current&&cancelAnimationFrame(g.current)}),[l,K]);const A=()=>{h(!1),f(0)},M=C=>{f(Number(C.target.value))},E=()=>{const C=[`Build Replay: Session ${e}`,`Total iterations: ${o}`,`Files created: ${t.filter(B=>B.type==="file").length}`,`Quality gates: ${D} passed, ${T} failed`,`Phases: ${s.join(" > ")}`].join(`
|
|
250
|
+
`);a==null||a(C)},L=x>0?m/x*100:0;return _?r.jsxs("div",{className:"card overflow-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Replay"}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("button",{onClick:()=>p(!1),className:"text-xs text-muted hover:text-ink transition-colors",children:"Collapse"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-0 min-h-[240px]",children:[r.jsxs("div",{className:"border-r border-border p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"File Tree"}),t.filter(C=>C.type==="file").length===0?r.jsx("div",{className:"text-xs text-muted py-4 text-center",children:"No files to display"}):t.filter(C=>C.type==="file").map((C,B)=>r.jsx(Sv,{path:C.path,visible:j.has(C.path),delay:B*30},C.path))]}),r.jsxs("div",{className:"p-3 overflow-y-auto terminal-scroll max-h-[300px]",children:[r.jsx("div",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider mb-2",children:"Activity"}),r.jsx("div",{className:"space-y-1",children:k.slice(-20).map((C,B)=>r.jsxs("div",{className:"flex items-center gap-2 text-xs animate-fade-in",children:[C.type==="file_created"&&r.jsx(Z,{size:11,className:"text-primary flex-shrink-0"}),C.type==="phase_change"&&r.jsx(nt,{size:11,className:"text-info flex-shrink-0"}),C.type==="gate_pass"&&r.jsx(kt,{size:11,className:"text-success flex-shrink-0"}),C.type==="gate_fail"&&r.jsx(kt,{size:11,className:"text-danger flex-shrink-0"}),C.type==="iteration"&&r.jsx(Yl,{size:11,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:`truncate ${C.type==="phase_change"?"font-semibold text-ink":C.type==="gate_fail"?"text-danger":"text-secondary"}`,children:C.label})]},`${C.timestamp}-${B}`))})]})]}),r.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 bg-hover/50 border-t border-border text-xs text-muted",children:[r.jsx("span",{className:"font-medium text-ink capitalize",children:w}),r.jsxs("span",{children:[j.size," files"]}),r.jsxs("span",{className:"text-success",children:[D," passed"]}),T>0&&r.jsxs("span",{className:"text-danger",children:[T," failed"]}),U&&r.jsx("span",{className:"font-mono",children:U})]}),r.jsxs("div",{className:"px-4 py-2 border-t border-border",children:[r.jsx("div",{className:"relative w-full h-1.5 bg-border rounded-full overflow-hidden mb-2",children:r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal rounded-full transition-all duration-100",style:{width:`${L}%`}})}),r.jsx("input",{type:"range",min:0,max:x,value:m,onChange:M,className:"w-full h-1 opacity-0 absolute cursor-pointer",style:{marginTop:"-14px"}})]}),r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-border",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>h(!l),className:"p-1.5 rounded-card hover:bg-hover transition-colors text-ink",title:l?"Pause":"Play",children:l?r.jsx(Jl,{size:16}):r.jsx(It,{size:16})}),r.jsx("button",{onClick:A,className:"p-1.5 rounded-card hover:bg-hover transition-colors text-muted",title:"Reset",children:r.jsx(ic,{size:14})}),r.jsxs("button",{onClick:()=>u((c+1)%Ol.length),className:"px-2 py-1 rounded-card hover:bg-hover transition-colors text-xs font-mono text-muted",title:"Playback speed",children:[G,"x"]})]}),r.jsxs("button",{onClick:E,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary hover:bg-primary/5 rounded-card transition-colors",children:[r.jsx(no,{size:12}),"Share Replay"]})]})]}):r.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-2 px-3 py-2 text-xs font-medium text-primary hover:bg-primary/5 rounded-card transition-colors",children:[r.jsx(It,{size:14}),"Replay Build"]})}function Cv(e){const t=e.toLowerCase().trim(),s=[];let i;const n=t.match(/where (?:is|are) (?:the )?(.+?)(?:\?|$)/);n&&s.push(...n[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l)));const o=t.match(/show (?:me )?(?:all )?(.+?)(?:\?|$)/);o&&s.length===0&&s.push(...o[1].split(/\s+/).filter(l=>!["the","a","an","my","all"].includes(l)));const a=t.match(/find (?:the )?(.+?)(?:\?|$)/);return a&&s.length===0&&s.push(...a[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l))),(t.includes("api endpoint")||t.includes("route")||t.includes("handler"))&&(i="api",s.length===0&&s.push("app.get","app.post","router","@app.route","endpoint")),(t.includes("database")||t.includes("db connection")||t.includes("schema"))&&s.length===0&&s.push("database","connection","schema","model","migration"),(t.includes("login")||t.includes("auth")||t.includes("authentication"))&&s.length===0&&s.push("auth","login","session","token","password"),(t.includes("test")||t.includes("spec"))&&(i="test",s.length===0&&s.push("describe","it(","test(","expect")),(t.includes("style")||t.includes("css")||t.includes("theme"))&&(i="css",s.length===0&&s.push("style","theme","color","font")),(t.includes("config")||t.includes("configuration")||t.includes("settings"))&&s.length===0&&s.push("config","settings","env","options"),s.length===0&&s.push(...t.split(/\s+/).filter(l=>l.length>2&&!["the","a","an","my","all","show","me","find","where","is","are","how"].includes(l))),{terms:s,filePattern:i}}function kv(e,t){let s=0;const i=e.path.toLowerCase(),n=e.name.toLowerCase();for(const o of t){const a=o.toLowerCase();n===a?s+=100:n.includes(a)?s+=60:i.includes(a)&&(s+=30)}return s+=Math.max(0,20-e.path.split("/").length*2),s}const jv=["Where is the login function?","Show me all API endpoints","Find the database connection","Where are the tests?","Show me the configuration files"];function Nv({sessionId:e,onOpenFile:t,className:s=""}){const[i,n]=d.useState(""),[o,a]=d.useState([]),[l,h]=d.useState(!1),[c,u]=d.useState(!1),[m,f]=d.useState(!1),_=d.useRef(null),p=d.useRef(null),g=d.useCallback(async w=>{if(!w.trim()||!e){a([]),f(!1);return}h(!0),f(!0);try{const{terms:D}=Cv(w),T=D.join(" "),G=(await W.searchFiles(e,T)).map(K=>({path:K.path,name:K.name,relevanceScore:kv(K,D)}));G.sort((K,A)=>A.relevanceScore-K.relevanceScore),a(G.slice(0,15))}catch{a([])}finally{h(!1)}},[e]),v=w=>{n(w),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>g(w),400)},y=w=>{w.preventDefault(),p.current&&clearTimeout(p.current),g(i)},x=()=>{var w;n(""),a([]),f(!1),(w=_.current)==null||w.focus()},k=w=>{n(w),g(w)};d.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const j=w=>w.includes(".test.")||w.includes(".spec.")?"text-teal":w.endsWith(".css")||w.endsWith(".scss")?"text-pink":w.endsWith(".json")||w.endsWith(".yaml")?"text-warning":w.endsWith(".md")?"text-muted":"text-primary";return r.jsxs("div",{className:`card overflow-hidden ${s}`,children:[r.jsxs("div",{className:"px-4 pt-4 pb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(ts,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Code Search"})]}),r.jsx("p",{className:"text-[11px] text-muted mb-3",children:'Search in natural language -- "Where is the login function?"'}),r.jsxs("form",{onSubmit:y,className:"relative",children:[r.jsx(ts,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{ref:_,type:"text",value:i,onChange:w=>v(w.target.value),onFocus:()=>u(!0),onBlur:()=>setTimeout(()=>u(!1),200),placeholder:"Ask about your code...",className:`w-full pl-9 pr-8 py-2 text-sm bg-hover/50 border border-border rounded-card
|
|
276
251
|
focus:border-primary focus:ring-1 focus:ring-primary/20 outline-none
|
|
277
|
-
text-ink placeholder:text-muted`}),i&&r.jsx("button",{type:"button",onClick:x,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-ink transition-colors",children:r.jsx(ft,{size:14})})]})]}),!m&&c&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"text-[11px] text-muted mb-1.5",children:"Try searching for:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:
|
|
252
|
+
text-ink placeholder:text-muted`}),i&&r.jsx("button",{type:"button",onClick:x,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-ink transition-colors",children:r.jsx(ft,{size:14})})]})]}),!m&&c&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"text-[11px] text-muted mb-1.5",children:"Try searching for:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:jv.map(w=>r.jsx("button",{onClick:()=>k(w),className:`text-[11px] text-primary bg-primary/5 hover:bg-primary/10
|
|
278
253
|
px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:w},w))})]}),l&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted",children:[r.jsx(mi,{size:14,className:"animate-spin"}),"Searching..."]}),m&&!l&&r.jsx("div",{className:"border-t border-border",children:o.length===0?r.jsx("div",{className:"text-center py-6 text-xs text-muted",children:"No results found. Try a different query."}):r.jsxs("div",{className:"max-h-[320px] overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"text-[11px] text-muted px-4 py-1.5 bg-hover/30 border-b border-border",children:[o.length," result",o.length!==1?"s":""," found"]}),o.map((w,D)=>r.jsxs("button",{onClick:()=>t(w.path,w.lineNumber),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left
|
|
279
254
|
hover:bg-hover/50 transition-colors border-b border-border last:border-b-0
|
|
280
|
-
group cursor-pointer`,children:[r.jsx(Z,{size:14,className:N(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(hu,{size:10}),w.lineNumber]}),r.jsx(Zn,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${D}`))]})})]})}const cr={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"},gemini:{input:.00125,output:.005,label:"Gemini Pro"}},hr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Lv(e,t,s){const i=cr[t]||cr.claude,n=hr[e]||hr.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(p=>{const g=Math.round(h*p.pct),v=g*.4,y=g*.6,x=(v*i.input+y*i.output)/1e3;return{phase:p.phase,label:p.label,estimatedCost:x,estimatedTokens:g}}),u=c.reduce((p,g)=>p+g.estimatedCost,0),f=o*(e==="complex"?40:e==="simple"?15:25),_=f<60?`${f}s`:f<3600?`${Math.round(f/60)}min`:`${(f/3600).toFixed(1)}hr`;return{total:{low:u*.7,high:u*1.4},breakdown:c,totalTokens:h,estimatedTime:_}}function $l(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Bv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Lv(e,t,i),u=cr[t]||cr.claude,m=hr[e]||hr.standard,f=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Ql,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Zt,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:$l(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(nt,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Zt,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||m.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:u.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:m.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(zd,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(dr,{size:12}):r.jsx(ls,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(_=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:_.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[$l(_.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",_.estimatedCost.toFixed(2)]})]},_.phase))})]}),f&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ot,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(he,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(he,{variant:"primary",size:"sm",onClick:n,icon:Zt,children:"Start Build"})]})]})}function Tv({sessionId:e}){return r.jsx(jh,{sessionId:e})}function Xn(e,t,s){var o;if(t==="directory")return s?r.jsx(sn,{size:14}):r.jsx(ro,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(Z,{size:14,className:"text-yellow-600"}),ts:r.jsx(Z,{size:14,className:"text-blue-500"}),tsx:r.jsx(Z,{size:14,className:"text-blue-400"}),jsx:r.jsx(Z,{size:14,className:"text-yellow-500"}),py:r.jsx(Z,{size:14,className:"text-green-600"}),html:r.jsx(nc,{size:14,className:"text-orange-500"}),css:r.jsx(so,{size:14,className:"text-purple-500"}),json:r.jsx(to,{size:14,className:"text-green-500"}),md:r.jsx(fi,{size:14,className:"text-muted"}),go:r.jsx(Z,{size:14,className:"text-cyan-600"}),rs:r.jsx(Z,{size:14,className:"text-orange-600"}),rb:r.jsx(Z,{size:14,className:"text-red-500"}),sh:r.jsx(Z,{size:14,className:"text-green-600"})}[i]||r.jsx(io,{size:14})}function zv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function Dh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Dh(s.children,t);if(i!==void 0)return i}}}function Rh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ph({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",u=a.has(h.path),m=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":m,...c?{"aria-expanded":u}:{},onContextMenu:f=>{f.preventDefault(),n==null||n(f,h.path,h.name,h.type)},onClick:()=>{c?l(f=>{const _=new Set(f);return _.has(h.path)?_.delete(h.path):_.add(h.path),_}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${m?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:u?r.jsx(ls,{size:14}):r.jsx(ur,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Xn(h.name,h.type,u)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Rh(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:f=>{f.stopPropagation(),i(h.path,h.name)},onKeyDown:f=>{f.key==="Enter"&&(f.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(ft,{size:12})})]}),c&&u&&h.children&&r.jsx(Ph,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Mh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Mh(i.children,i.path+"/"));return s}function Av(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[u,m]=d.useState(new Set),f=d.useCallback(async()=>{try{const y=await W.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{f()},[f]);const _=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await W.setSecret(y,n),i(""),o(""),await f()}catch(x){c(x instanceof Error?x.message:"Failed to set secret")}}},p=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await W.deleteSecret(y),await f()}catch(x){c(x instanceof Error?x.message:"Failed to delete secret")}},g=y=>{m(x=>{const k=new Set(x);return k.has(y)?k.delete(y):k.add(y),k})},v=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(ii,{variant:"text",width:"180px",height:"16px"}),r.jsx(ii,{variant:"block",width:"100%",height:"60px"}),r.jsx(ii,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ot,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),v.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:v.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:u.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>g(y),className:"text-muted hover:text-ink transition-colors",title:u.has(y)?"Hide value":"Show value",children:u.has(y)?r.jsx(Td,{size:14}):r.jsx(ys,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>p(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(eo,{size:14})})})]},y))})]})}),v.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("button",{onClick:_,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(mr,{size:14}),"Add"]})]})]})]})})}function Ov({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[l,h]=d.useState(""),[c,u]=d.useState(!0),[m,f]=d.useState(!1),[_,p]=d.useState(null),g=d.useCallback(async()=>{try{const x=await W.getDocsStatus(e);if(s(x),x.has_docs){const k=await W.getDocFiles(e);n(k.files)}}catch{}u(!1)},[e]);d.useEffect(()=>{g()},[g]);const v=async()=>{f(!0),p(null);try{await W.generateDocs(e);const x=setInterval(async()=>{try{const k=await W.getDocsStatus(e);if(k.has_docs){s(k);const N=await W.getDocFiles(e);n(N.files),f(!1),clearInterval(x)}}catch{}},3e3);setTimeout(()=>{clearInterval(x),f(!1)},3e5)}catch(x){p(x instanceof Error?x.message:"Failed to start doc generation"),f(!1)}},y=async x=>{try{const k=await W.getDocFileContent(e,x);a(x),h(k)}catch(k){p(k instanceof Error?k.message:"Failed to load doc file")}};return c?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(ii,{variant:"text",width:"180px",height:"16px"}),r.jsx(ii,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(Xl,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:l})})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Documentation"}),_&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:_})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(he,{onClick:v,disabled:m,size:"sm",variant:"secondary",children:[r.jsx(gt,{size:14,className:m?"animate-spin":""}),m?"Updating...":"Update Docs"]}):r.jsx(he,{onClick:v,disabled:m,size:"sm",children:m?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(x=>r.jsxs("button",{onClick:()=>y(x.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(fi,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:x.name}),r.jsx("span",{className:"text-xs text-muted",children:x.size<1024?`${x.size} B`:`${(x.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},x.name))}):t!=null&&t.has_docs?null:r.jsx("p",{className:"text-sm text-muted",children:'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}),(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function $v({session:e,onClose:t}){var ea;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(!1),[f,_]=d.useState("code"),[p,g]=d.useState(!1),[v,y]=d.useState(!1),[x,k]=d.useState(e),N=d.useRef(null),[w,D]=d.useState([]),[T,U]=d.useState(!1),[G,K]=d.useState(""),A=d.useRef(null),M=d.useRef(null),[E,L]=d.useState(0),[S,j]=d.useState(null),[C,B]=d.useState(!0),[X,oe]=d.useState(!0),[q,Q]=d.useState(!1),[ie,de]=d.useState("overview"),ue=57374,[z,V]=d.useState(null),J=d.useCallback(()=>{Q(b=>{const I=!b;return B(!I),oe(!I),I})},[]),[R,le]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${x.id}`)||"standard"),[_e,Ee]=d.useState(()=>sessionStorage.getItem(`pl_provider_${x.id}`)||"claude"),[ee,fe]=d.useState(null),[ge,Ce]=d.useState(null),[Ge,Ls]=d.useState(!1),[us,et]=d.useState(!1),[ce,ot]=d.useState({phase:"idle",iteration:0,maxIterations:10,cost:0,startTime:0}),[at,fs]=d.useState(!1),[Bs,bi]=d.useState(null),Ts=d.useRef(null),[Lh,jo]=d.useState(!1),[Bh,Eo]=d.useState([]),[Do,zs]=d.useState(null),[Th,yr]=d.useState(!1),[zh,yi]=d.useState(!1),[Ah,As]=d.useState(!1),[Si,Ro]=d.useState("files"),{history:Po,recordTokens:Mo}=Jx(),[Oh,$h]=d.useState(null),[Lo,Ih]=d.useState({line:1,column:1}),[Fh,Bo]=d.useState(0),{device:Hh,setDevice:Wh,frameClass:To}=sv(),[Sr,Uh]=d.useState(100),[zo,Kh]=d.useState(!1),[wi,wr]=d.useState(!1),[Ao,Fv]=d.useState([]),ms=d.useRef(null),[qh,Oo]=d.useState(0),{subscribe:$o}=kd(),Ye=d.useCallback(async()=>{try{const b=await W.getSessionDetail(x.id);k(b)}catch{}},[x.id]),Io=d.useCallback(async()=>{try{await W.stopSession(),Ls(!1),et(!1)}catch{}},[]),Vh=d.useCallback(async()=>{try{await W.pauseSession(),et(!0)}catch{}},[]),Gh=d.useCallback(async()=>{try{await W.resumeSession(),et(!1)}catch{}},[]),Fo=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await W.getStatus();Ls(F.running),et(F.paused),F.provider&&Ee(F.provider);const te=F.phase||"idle";if(te!==Fo.current&&te!=="idle"){const Xe=new Date().toISOString(),Rt={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},yt={starting:"Setting up the build environment and checking prerequisites...",planning:"Analyzing requirements and designing the architecture...",building:"Writing code and creating project files...",testing:"Running test suite to verify everything works...",reviewing:"Checking code quality and best practices...",complete:"All done. Your project is ready."},Is=[{id:`phase-${Date.now()}`,type:"phase_change",message:Rt[te]||`Phase: ${te}`,timestamp:Xe}];yt[te]&&Is.push({id:`narration-${Date.now()}`,type:"narration",message:yt[te],timestamp:Xe}),Eo(Pi=>[...Pi,...Is]),Fo.current=te}ot({phase:te,iteration:F.iteration||0,maxIterations:F.max_iterations||10,cost:F.cost||0,startTime:F.start_time?F.start_time*1e3:0});const Ke=F.tokens_used;Ke!=null&&Mo(Ke)}catch{}};b();const I=setInterval(b,Ge?3e3:1e4);return()=>clearInterval(I)},[Ge,Mo]),d.useEffect(()=>{if(!(ge!=null&&ge.loading))return;const b=setInterval(()=>{Ce(I=>I?{...I,elapsed:Math.floor((Date.now()-I.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[ge==null?void 0:ge.loading]);const[se,Yh]=d.useState(null);d.useEffect(()=>{W.getPreviewInfo(x.id).then(Yh).catch(()=>{})},[x.id]);const[$,Ci]=d.useState(null),[Os,Ho]=d.useState(!1),[Wo,Uo]=d.useState(!1),[Ko,ki]=d.useState(null),[Kt,Xh]=d.useState("");d.useEffect(()=>{const b=$o("file_changed",I=>{const F=I;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),Ke=F.paths.map((Xe,Rt)=>{var Pi;const yt=(Pi=F.event_types)==null?void 0:Pi[Rt],Is=yt==="created"||yt==="IN_CREATE";return{id:`file-${Date.now()}-${Rt}`,type:Is?"file_created":"file_modified",message:Is?`Created ${Xe.split("/").pop()}`:`Modified ${Xe.split("/").pop()}`,timestamp:te,filePath:Xe}});if(Eo(Xe=>[...Xe,...Ke]),fs(!0),Ts.current&&clearTimeout(Ts.current),Ts.current=setTimeout(()=>fs(!1),2e3),Ye(),s&&F.paths.some(Rt=>Rt===s||s.endsWith(Rt))&&bi(s),f==="preview"){const Xe=["react","vite","next","nuxt","svelte","remix"];($==null?void 0:$.running)&&($==null?void 0:$.framework)&&Xe.some(yt=>$.framework.toLowerCase().includes(yt))||L(yt=>yt+1)}});return()=>{b(),Ts.current&&clearTimeout(Ts.current)}},[$o,s,f,$==null?void 0:$.running,Ye]);const Jh=d.useCallback(async()=>{if(!(!Bs||!x.id)){try{const b=await W.getSessionFileContent(x.id,Bs);l(b.content),c(b.content),g(!1),D(I=>I.map(F=>F.path===Bs?{...F,content:b.content,modified:!1}:F))}catch{}bi(null)}},[Bs,x.id]);d.useEffect(()=>{if(f!=="preview")return;let b=!1;const I=async()=>{try{const te=await W.devserver.status(x.id);b||Ci(te)}catch{}};I();const F=setInterval(I,3e3);return()=>{b=!0,clearInterval(F)}},[f,x.id]),d.useEffect(()=>{f==="dashboard"&&fetch(`http://127.0.0.1:${ue}/health`).then(b=>V(b.ok)).catch(()=>V(!1))},[f]);const ps=d.useCallback(async b=>{Ho(!0),ki(null);try{const I=await W.devserver.start(x.id,b);if(I.status==="error")ki(I.message||"Failed to start dev server");else{const F=await W.devserver.status(x.id);Ci(F)}}catch(I){ki(I instanceof Error?I.message:"Failed to start dev server")}Ho(!1)},[x.id]),qo=d.useRef(!1);d.useEffect(()=>{qo.current||se!=null&&se.dev_command&&($!=null&&$.running||($==null?void 0:$.status)==="starting"||Os||(qo.current=!0,ps(se.dev_command)))},[se==null?void 0:se.dev_command,$==null?void 0:$.running,$==null?void 0:$.status,Os,ps]);const Zh=d.useCallback(async()=>{try{await W.devserver.stop(x.id);const b=await W.devserver.status(x.id);Ci(b)}catch{}},[x.id]),Qh=d.useCallback(async()=>{Uo(!0);try{const b=await W.fixProject(x.id);if(b.task_id){let F=0,te;do await new Promise(Xe=>setTimeout(Xe,2e3)),te=await W.chatPoll(x.id,b.task_id),F++;while(!te.complete&&F<150);const Ke=await W.devserver.status(x.id);Ci(Ke)}}catch(b){ki(b instanceof Error?b.message:"Fix failed")}Uo(!1)},[x.id]),gs=$!=null&&$.running&&($!=null&&$.port)?$.framework==="expo"?`${Zr}/api/sessions/${encodeURIComponent(x.id)}/expo-qr`:$.portless_url||`http://localhost:${$.port}/`:null,ed=(se==null?void 0:se.preview_url)||`${Zr}/api/sessions/${encodeURIComponent(x.id)}/preview/index.html`,td=gs||ed,[Ni,Vo]=d.useState([]),[vt,ji]=d.useState(0);d.useEffect(()=>{const b=gs||(se==null?void 0:se.preview_url);b&&(Vo([b]),ji(0))},[gs,se==null?void 0:se.preview_url]);const bt=Ni[vt]||td,[Go,Cr]=d.useState(bt),sd=d.useCallback((b,I,F,te)=>{b.preventDefault(),j({x:b.clientX,y:b.clientY,path:I,name:F,type:te})},[]),id=d.useCallback(()=>{vt>0&&(ji(b=>b-1),L(b=>b+1))},[vt]),rd=d.useCallback(()=>{vt<Ni.length-1&&(ji(b=>b+1),L(b=>b+1))},[vt,Ni.length]),nd=d.useCallback(b=>{let I=b;if(b.startsWith("/")&&gs)try{I=`${new URL(gs).origin}${b}`}catch{const F=$==null?void 0:$.port;F&&(I=`http://localhost:${F}${b}`)}Vo(F=>[...F.slice(0,vt+1),I]),ji(F=>F+1),L(F=>F+1)},[vt,gs,$==null?void 0:$.port]);d.useEffect(()=>{try{const b=new URL(bt,window.location.origin);Cr(b.pathname+b.search+b.hash||"/")}catch{Cr(bt)}},[bt]);const Ei=d.useCallback(async()=>{Ce({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await W.reviewProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),Di=d.useCallback(async()=>{Ce({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await W.testProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),kr=d.useCallback(async()=>{Ce({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await W.explainProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),Nr=d.useCallback(async(b,I)=>{if(window.confirm(`Delete "${I}"?`))try{await W.deleteSessionFile(x.id,b),s===b&&(i(null),o(""),l(null),c(null),g(!1)),await Ye()}catch(te){const Ke=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${Ke}`)}},[x.id,s,Ye]),od=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:ys,onClick:()=>{Ei()}},{label:"Generate Tests",icon:ri,onClick:()=>{Di()}},{label:"Explain",icon:Gs,onClick:()=>{kr()}},{label:"Delete",icon:eo,onClick:()=>{Nr(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:ys,onClick:()=>{Ei()}},{label:"Run Tests",icon:ri,onClick:()=>{Di()}}],[Ei,Di,kr,Nr]),Dt=d.useCallback(async(b,I)=>{bi(null),p&&s&&h!==null&&D(te=>te.map(Ke=>Ke.path===s?{...Ke,content:h,modified:!0}:Ke));const F=w.find(te=>te.path===b);if(F){i(b),o(I),l(F.content),c(F.content),g(F.modified);return}i(b),o(I),m(!0),g(!1);try{const te=x.id?await W.getSessionFileContent(x.id,b):await W.getFileContent(b);l(te.content),c(te.content),D(Ke=>[...Ke,{path:b,name:I,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{m(!1)}},[x.id,p,s,h,w]),jr=d.useCallback(async()=>{var b;if(!(!s||h===null||!x.id)){y(!0);try{await W.saveSessionFile(x.id,s,h),l(h),g(!1),$h(Date.now()),D(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const I=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(I)&&L(F=>F+1)}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,x.id]),Yo=d.useCallback(b=>{const I=w.find(F=>F.path===b);if(!(I!=null&&I.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(D(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),g(te.modified)}else i(null),o(""),l(null),c(null),g(!1)}},[w,s]);d.useEffect(()=>{const b=I=>{(I.metaKey||I.ctrlKey)&&I.key==="s"&&(I.preventDefault(),p&&s&&jr()),(I.metaKey||I.ctrlKey)&&I.key==="p"&&(I.preventDefault(),U(F=>!F),K("")),(I.metaKey||I.ctrlKey)&&I.key==="k"&&(I.preventDefault(),jo(F=>!F)),I.key==="Escape"&&T&&U(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[p,s,jr,T]),d.useEffect(()=>{T&&A.current&&A.current.focus()},[T]);const Xo=Mh(x.files),$s=G?Xo.filter(b=>b.path.toLowerCase().includes(G.toLowerCase())):Xo;d.useEffect(()=>{const b=x.files.find(I=>I.name==="index.html"&&I.type==="file");b&&Dt(b.path,b.name)},[]);const ad=d.useCallback(b=>{b!==void 0&&(c(b),g(b!==a),Bo(b.split(`
|
|
281
|
-
`).length))},[a]),ld=d.useCallback(b=>{N.current=b;const I=b;if(I!=null&&I.onDidChangeCursorPosition&&I.onDidChangeCursorPosition(F=>{Ih({line:F.position.lineNumber,column:F.position.column})}),I!=null&&I.getModel){const F=I.getModel();F!=null&&F.getLineCount&&Bo(F.getLineCount())}},[]),cd=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await W.createSessionFile(x.id,b.trim()),await Ye()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[x.id,Ye]),hd=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await W.createSessionDirectory(x.id,b.trim()),await Ye()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[x.id,Ye]),Jo=d.useCallback(async()=>{try{const b=await W.previewChanges(x.id,"preview current changes");zs(b)}catch{}},[x.id]),dd=d.useCallback(()=>{zs(null),Ye()},[Ye]),ud=d.useCallback(b=>{zs(null),Ye()},[Ye]),fd=d.useCallback(()=>{zs(null)},[]),Zo=s?Dh(x.files,s):void 0,md=((ea=n.split(".").pop())==null?void 0:ea.toUpperCase())||"",{showHelp:pd,setShowHelp:Qo}=yx({onToggleBuild:()=>{Ge&&Io()}}),gd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:ys,action:()=>_("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:tn,action:()=>_("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:es,action:()=>oe(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Er,action:()=>_("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:$t,action:()=>_("deploy")},{id:"git",label:"Git Status",category:"command",icon:ze,action:()=>_("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:na,action:()=>_("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:Z,action:()=>{U(!0),K("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:on,action:()=>J()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:oa,action:()=>B(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:ze,action:()=>Jo()},{id:"insights",label:"Build Insights",category:"command",icon:Qr,action:()=>_("insights")},{id:"docs",label:"Documentation",category:"command",icon:Gs,action:()=>_("docs")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:ts,action:()=>As(!0)}],[_,J,Jo]),Ri=d.useMemo(()=>{if(!Ge)return"idle";const b=(ce.phase||x.status||"").toLowerCase();return b.includes("starting")||b.includes("plan")||b.includes("bootstrap")?"planning":b.includes("review")||b.includes("council")?"reviewing":b.includes("test")||b.includes("verify")?"testing":b.includes("complete")||b.includes("fulfilled")?"complete":"building"},[Ge,ce.phase,x.status]);return r.jsxs("div",{className:"flex flex-col h-full relative",children:[r.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[r.jsx("button",{onClick:()=>{p&&!window.confirm("Unsaved changes. Discard?")||t()},className:"text-xs font-medium px-3 py-1.5 rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Back"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:x.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:x.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${x.status==="completed"||x.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:x.status}),Po.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Xx,{tokenHistory:Po})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>B(b=>!b),title:C?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:C?r.jsx(oa,{size:16}):r.jsx(ku,{size:16})}),r.jsx("button",{onClick:()=>oe(b=>!b),title:X?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:X?r.jsx(yu,{size:16}):r.jsx(wu,{size:16})}),r.jsx("button",{onClick:J,title:q?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${q?"text-primary":"text-muted hover:text-ink"}`,children:q?r.jsx(lc,{size:16}):r.jsx(on,{size:16})})]}),!Ge&&r.jsx(he,{variant:"primary",size:"sm",icon:It,onClick:()=>{if(!(x.prd||"").trim()){window.alert("No spec found for this project. Go to Home to start a new build.");return}yi(!0)},title:"Start build for this project",children:"Build"}),!Ge&&Ri==="complete"&&r.jsx(he,{variant:"ghost",size:"sm",icon:nn,onClick:()=>yr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(Pt,{icon:ts,label:"Natural language search",size:"sm",onClick:()=>As(!0)}),Ge&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[us?r.jsx(he,{variant:"ghost",size:"sm",icon:It,onClick:Gh,title:"Resume build",children:"Resume"}):r.jsx(he,{variant:"ghost",size:"sm",icon:Jl,onClick:Vh,title:"Pause build",children:"Pause"}),r.jsx(he,{variant:"danger",size:"sm",icon:tr,onClick:Io,title:"Stop build",children:"Stop"})]}),r.jsx(Pt,{icon:ys,label:"Review project",size:"sm",onClick:Ei,disabled:!!(ge!=null&&ge.loading)}),r.jsx(Pt,{icon:ri,label:"Run tests",size:"sm",onClick:Di,disabled:!!(ge!=null&&ge.loading)}),r.jsx(Pt,{icon:Gs,label:"Explain project",size:"sm",onClick:kr,disabled:!!(ge!=null&&ge.loading)}),r.jsx(he,{variant:"secondary",size:"sm",icon:$t,onClick:()=>_("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(wx,{onClick:()=>Qo(!0)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex-1",children:r.jsx(hx,{phase:Ri,iteration:ce.iteration,maxIterations:ce.maxIterations,cost:ce.cost,startTime:ce.startTime,isRunning:Ge})}),Ge&&r.jsx("div",{className:"flex-shrink-0 pr-2",children:r.jsx(yv,{gatePassRate:.8,testCoverage:ce.iteration>2?60:20,iteration:ce.iteration,maxIterations:ce.maxIterations,phase:Ri,compact:!0})})]}),r.jsx(Ax,{sessionId:x.id,onRestore:Ye}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(cn,{orientation:"vertical",children:[r.jsx(Js,{defaultSize:70,minSize:40,children:r.jsxs(cn,{orientation:"horizontal",className:"h-full",children:[C&&r.jsx(Js,{defaultSize:20,minSize:15,children:r.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[r.jsxs("div",{className:"flex items-center border-b border-border flex-shrink-0",children:[r.jsxs("button",{onClick:()=>Ro("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Si==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(ro,{size:14}),"Files",at&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Ro("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Si==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(ql,{size:14}),"Chat"]}),Si==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:cd,title:"New File",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(fr,{size:12})," New"]}),r.jsxs("button",{onClick:hd,title:"New Folder",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(Pd,{size:12})," New"]})]})]}),Si==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:x.files.length>0?r.jsx(Ph,{nodes:x.files,selectedPath:s,onSelect:Dt,onDelete:Nr,onContextMenu:sd}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(sn,{size:28,className:"text-muted/40 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(vv,{sessionId:x.id,defaultMode:R})})})]})}),C&&r.jsx(hn,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(Js,{defaultSize:80,minSize:40,children:r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[r.jsx("div",{className:"flex items-center border-b border-border bg-hover px-1 flex-shrink-0",role:"tablist",children:[{id:"code",label:"Code",icon:tn},{id:"preview",label:"Preview",icon:ys},{id:"deploy",label:"Deploy",icon:$t},{id:"config",label:"Config",icon:na},{id:"secrets",label:"Secrets",icon:mu},{id:"prd",label:"Spec",icon:fi},{id:"dashboard",label:"Dashboard",icon:Er},{id:"git",label:"Git",icon:ze},{id:"cicd",label:"CI/CD",icon:ze},{id:"insights",label:"Insights",icon:Qr},{id:"docs",label:"Docs",icon:Gs}].map(b=>r.jsxs("button",{role:"tab","aria-selected":f===b.id,onClick:()=>_(b.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${f===b.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(b.icon,{size:14}),b.label]},b.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[f==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[w.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:w.map(b=>r.jsxs("button",{onClick:()=>Dt(b.path,b.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${b.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Xn(b.name,"file")}),b.name,b.modified&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),r.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:I=>{I.stopPropagation(),Yo(b.path)},onKeyDown:I=>{I.key==="Enter"&&(I.stopPropagation(),Yo(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(ft,{size:12})})]},b.path))}),s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[r.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),v&&r.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),r.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:Zo!=null?Rh(Zo):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:md}),p&&r.jsx("button",{onClick:jr,className:"text-xs font-medium px-2 py-0.5 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:"Save"})]}),Bs===s&&r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[r.jsx(gt,{size:12,className:"text-warning"}),r.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsx("button",{onClick:Jh,className:"text-xs font-medium px-2 py-0.5 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors",children:"Reload"}),r.jsx("button",{onClick:()=>bi(null),className:"text-xs font-medium px-2 py-0.5 rounded border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Dismiss"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:u?r.jsx(Nd,{}):r.jsx(Hi,{name:"Editor",children:r.jsx(Zf,{value:h??"",language:zv(n),theme:"vs",onChange:ad,onMount:ld,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8},renderLineHighlight:"line",smoothScrolling:!0,cursorBlinking:"smooth",folding:!0,bracketPairColorization:{enabled:!0}}})})}),r.jsx(ev,{selectedFile:s,fileName:n,isModified:p,isSaving:v,lastSavedAt:Oh,lineCount:Fh,cursorLine:Lo.line,cursorColumn:Lo.column,buildTime:ce.phase==="complete"&&ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):void 0,sessionId:x.id,prd:x.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(Z,{size:32,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),r.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Cmd+P"})," to quick open"]})]})]}),f==="preview"&&r.jsx(Hi,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${zo?"preview-fullscreen":""}`,children:[r.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover flex-shrink-0",children:$!=null&&$.running||se!=null&&se.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(Pt,{icon:Xl,label:"Back",size:"sm",onClick:id,disabled:vt<=0}),r.jsx(Pt,{icon:Zn,label:"Forward",size:"sm",onClick:rd,disabled:vt>=Ni.length-1}),r.jsx(cv,{onClick:()=>{wr(!0),L(b=>b+1)}}),r.jsx("input",{value:Go,onChange:b=>Cr(b.target.value),onKeyDown:b=>{b.key==="Enter"&&nd(Go)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(tv,{selectedDevice:Hh,onDeviceChange:Wh,containerWidth:qh}),r.jsx(rv,{zoom:Sr,onZoomChange:Uh}),r.jsx(av,{url:bt}),r.jsx(ov,{}),r.jsx(hv,{url:bt}),r.jsx(Pt,{icon:ss,label:"Open in new tab",size:"sm",onClick:()=>window.open(bt,"_blank")}),r.jsx(lv,{isFullscreen:zo,onToggle:()=>Kh(b=>!b)}),($==null?void 0:$.running)&&r.jsxs("button",{onClick:Zh,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded border border-danger/40 bg-danger/10 text-danger hover:bg-danger/20 transition-colors",children:[r.jsx(tr,{size:12}),"Stop"]})]}):se?r.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:r.jsx("span",{className:"font-medium text-ink",children:se.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),$&&$.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${$.running?"bg-green-50 border-green-200 text-green-700":$.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":$.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${$.running?"bg-green-500":$.status==="starting"?"bg-yellow-500 animate-pulse":$.status==="error"?"bg-red-500":"bg-gray-400"}`}),$.running&&$.portless_url&&r.jsxs("span",{children:["Running at ",$.portless_url]}),$.running&&$.port&&!$.portless_url&&r.jsxs("span",{children:["Running on port ",$.port]}),$.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),$.status==="error"&&!$.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),$.status==="error"&&$.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",$.auto_fix_status]}),$.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:$.command})]}),$!=null&&$.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[wi&&r.jsx(Tl,{}),r.jsx("div",{ref:ms,className:`flex-1 bg-white overflow-auto flex justify-center ${wi?"hidden":""}`,children:r.jsx("div",{className:`${To} h-full preview-zoom-${Sr}`,children:r.jsx("iframe",{ref:M,src:bt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{wr(!1),ms.current&&Oo(ms.current.clientWidth)}},E)})}),r.jsx(Bl,{messages:Ao})]}):se!=null&&se.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[wi&&r.jsx(Tl,{}),r.jsx("div",{ref:ms,className:`flex-1 bg-white overflow-auto flex justify-center ${wi?"hidden":""}`,children:r.jsx("div",{className:`${To} h-full preview-zoom-${Sr}`,children:r.jsx("iframe",{ref:M,src:bt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{wr(!1),ms.current&&Oo(ms.current.clientWidth)}},E)})}),r.jsx(Bl,{messages:Ao})]}):se?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:se.type==="api"||se.type==="python-api"?r.jsx(Id,{size:28,className:"text-primary"}):se.type==="library"?r.jsx(Zl,{size:28,className:"text-primary"}):se.type==="go-app"||se.type==="rust-app"?r.jsx(es,{size:28,className:"text-primary"}):r.jsx(sn,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:se.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:se.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[se.dev_command&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:se.dev_command}),r.jsxs("button",{onClick:()=>ps(se.dev_command||void 0),disabled:Os,className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary/90 transition-colors disabled:opacity-50",children:[r.jsx(It,{size:12}),Os?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:se.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:se.dev_command?"Or use a custom command:":"Start a dev server:"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:Kt,onChange:b=>Xh(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Kt.trim()&&ps(Kt.trim())},placeholder:"e.g. npm run dev",className:"flex-1 px-3 py-1.5 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx("button",{onClick:()=>Kt.trim()&&ps(Kt.trim()),disabled:Os||!Kt.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-btn border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:"Run"})]})]})]}),Ko&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),r.jsx("p",{className:"text-xs text-danger/80",children:Ko})]}),($==null?void 0:$.status)==="error"&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:Qh,disabled:Wo,className:"text-xs px-2 py-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:Wo?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>ps(se.dev_command||Kt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),$.auto_fix_status&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),r.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",$.auto_fix_status]}),$.auto_fix_attempts!==void 0&&$.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",$.auto_fix_attempts,"/3"]})]}),$.output.length>0&&r.jsx("pre",{className:"text-[11px] font-mono text-danger/70 bg-danger/5 p-2 rounded max-h-32 overflow-y-auto whitespace-pre-wrap",children:$.output.slice(-10).join(`
|
|
282
|
-
`)})]}),se.port&&!($!=null&&$.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",se.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),f==="config"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),r.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:_e})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{onClick:()=>{Ee(b),sessionStorage.setItem(`pl_provider_${x.id}`,b),W.setProvider(b).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${_e===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{le(b),sessionStorage.setItem(`pl_buildmode_${x.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${R===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),r.jsx("input",{value:x.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),r.jsx("input",{value:x.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),f==="secrets"&&r.jsx(Av,{}),f==="prd"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),x.prd?r.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:x.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No spec found for this project."})]})}),f==="deploy"&&r.jsx(xx,{sessionId:x.id}),f==="dashboard"&&(z===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(Er,{size:48,className:"text-muted/30"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),r.jsx("p",{className:"text-sm text-muted max-w-md",children:"The Loki Dashboard provides task boards, RARV timeline, quality gates, and cost tracking. Start it to see project analytics."}),r.jsx("button",{onClick:async()=>{V(null);try{const b=await fetch(`http://127.0.0.1:${ue}/health`);V(b.ok)}catch{V(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[[{id:"overview",label:"Overview"},{id:"tasks",label:"Tasks"},{id:"timeline",label:"RARV Timeline"},{id:"quality",label:"Quality"},{id:"cost",label:"Cost"}].map(b=>r.jsx("button",{onClick:()=>de(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${ie===b.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:b.label},b.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${ue}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(ss,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${ue}/#${ie}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),f==="git"&&r.jsx(zx,{sessionId:x.id}),f==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Tv,{sessionId:e.id})}),f==="docs"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Ov,{sessionId:x.id})}),f==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(kv,{filesCreated:x.files.filter(b=>b.type==="file").length,filesModified:0,linesGenerated:0,testsGenerated:0,testPassRate:0,totalTokens:0,phaseBreakdown:[],totalTimeSecs:ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):0,qualityScore:0,totalCost:ce.cost,iterations:ce.iteration,provider:_e})})]})]})})]})}),X&&r.jsx(hn,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),X&&r.jsx(Js,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx(Hi,{name:"ActivityPanel",children:r.jsx(lx,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:x.status==="running"||x.status==="in_progress",buildMode:R,buildEvents:Bh,onFileClick:b=>Dt(b,b.split("/").pop()||b)})})})]})}),(ge==null?void 0:ge.loading)&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),r.jsxs("span",{className:"text-sm font-medium text-ink",children:[ge.type==="review"?"Reviewing project":ge.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[ge.elapsed,"s"]})]})}),ee&&r.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4 max-h-64 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),r.jsx(Pt,{icon:ft,label:"Close",size:"sm",onClick:()=>fe(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:ee})]}),S&&r.jsx(Tm,{x:S.x,y:S.y,items:od(S),onClose:()=>j(null)}),T&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",role:"dialog","aria-modal":"true","aria-label":"Quick open file search",onClick:()=>U(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsx("input",{ref:A,type:"text",value:G,onChange:b=>K(b.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:b=>{b.key==="Enter"&&$s.length>0&&(Dt($s[0].path,$s[0].name),U(!1)),b.key==="Escape"&&U(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[$s.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{Dt(b.path,b.name),U(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[r.jsx("span",{className:"w-5 flex items-center justify-center",children:Xn(b.name,"file")}),r.jsx("span",{className:"text-ink",children:b.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:b.path})]},b.path)),$s.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(Sx,{open:pd,onClose:()=>Qo(!1)}),r.jsx(jx,{isOpen:Lh,onClose:()=>jo(!1),commands:gd,sessionId:x.id,onFileSelect:Dt}),Do&&r.jsx(Ix,{data:Do,onAcceptAll:dd,onAcceptSelected:ud,onReject:fd,onClose:()=>zs(null)}),r.jsx(Yx,{phase:Ri,buildTime:ce.startTime?Math.floor((Date.now()-ce.startTime)/1e3):void 0}),Th&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>yr(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Build Replay"}),r.jsx("button",{onClick:()=>yr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(Ev,{sessionId:x.id,files:x.files.map(b=>({path:b.path,type:b.type})),phases:["planning","building","testing","reviewing","complete"],checkpoints:[],qualityGates:[],totalIterations:ce.iteration||ce.maxIterations})})]})}),Ah&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>As(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Search Files"}),r.jsx("button",{onClick:()=>As(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsx(Mv,{sessionId:x.id,onOpenFile:(b,I)=>{Dt(b,b.split("/").pop()||b),As(!1)},className:"p-4"})]})}),zh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>yi(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:b=>b.stopPropagation(),children:r.jsx(Bv,{complexity:R==="quick"?"simple":R==="max"?"complex":"standard",provider:_e,estimatedIterations:ce.maxIterations,onConfirm:async()=>{yi(!1);try{const b=x.prd||"";await W.startSession({prd:b,provider:_e,projectDir:x.path}),Ls(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>yi(!1)})})})]})}function Iv(){const{sessionId:e}=jd(),t=Ed(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),W.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),o(!1)}))},[e]),n?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),r.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),r.jsx("button",{onClick:()=>t("/"),className:"mt-4 px-4 py-2 rounded-btn text-sm font-semibold border border-primary/30 text-primary hover:bg-primary/5 transition-all",children:"Back to Home"})]})}):r.jsx("div",{className:"h-screen bg-background flex flex-col",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Hi,{name:"ProjectWorkspace",children:r.jsx($v,{session:s,onClose:()=>t("/")})})})})}const Sb=Object.freeze(Object.defineProperty({__proto__:null,default:Iv},Symbol.toStringTag,{value:"Module"}));export{Yd as C,rn as G,pr as L,Sb as P,Du as S};
|
|
255
|
+
group cursor-pointer`,children:[r.jsx(Z,{size:14,className:j(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(lu,{size:10}),w.lineNumber]}),r.jsx(Zn,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${D}`))]})})]})}const cr={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"},gemini:{input:.00125,output:.005,label:"Gemini Pro"}},hr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Ev(e,t,s){const i=cr[t]||cr.claude,n=hr[e]||hr.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(p=>{const g=Math.round(h*p.pct),v=g*.4,y=g*.6,x=(v*i.input+y*i.output)/1e3;return{phase:p.phase,label:p.label,estimatedCost:x,estimatedTokens:g}}),u=c.reduce((p,g)=>p+g.estimatedCost,0),f=o*(e==="complex"?40:e==="simple"?15:25),_=f<60?`${f}s`:f<3600?`${Math.round(f/60)}min`:`${(f/3600).toFixed(1)}hr`;return{total:{low:u*.7,high:u*1.4},breakdown:c,totalTokens:h,estimatedTime:_}}function $l(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Dv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Ev(e,t,i),u=cr[t]||cr.claude,m=hr[e]||hr.standard,f=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Ql,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Zt,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:$l(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(nt,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Zt,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||m.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:u.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:m.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Fd,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(dr,{size:12}):r.jsx(ls,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(_=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:_.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[$l(_.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",_.estimatedCost.toFixed(2)]})]},_.phase))})]}),f&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ot,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(he,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(he,{variant:"primary",size:"sm",onClick:n,icon:Zt,children:"Start Build"})]})]})}function Rv({sessionId:e}){return r.jsx(Nh,{sessionId:e})}function Xn(e,t,s){var o;if(t==="directory")return s?r.jsx(nn,{size:14}):r.jsx(ro,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(Z,{size:14,className:"text-yellow-600"}),ts:r.jsx(Z,{size:14,className:"text-blue-500"}),tsx:r.jsx(Z,{size:14,className:"text-blue-400"}),jsx:r.jsx(Z,{size:14,className:"text-yellow-500"}),py:r.jsx(Z,{size:14,className:"text-green-600"}),html:r.jsx(oc,{size:14,className:"text-orange-500"}),css:r.jsx(so,{size:14,className:"text-purple-500"}),json:r.jsx(to,{size:14,className:"text-green-500"}),md:r.jsx(fi,{size:14,className:"text-muted"}),go:r.jsx(Z,{size:14,className:"text-cyan-600"}),rs:r.jsx(Z,{size:14,className:"text-orange-600"}),rb:r.jsx(Z,{size:14,className:"text-red-500"}),sh:r.jsx(Z,{size:14,className:"text-green-600"})}[i]||r.jsx(io,{size:14})}function Pv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function Dh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Dh(s.children,t);if(i!==void 0)return i}}}function Rh(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ph({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",u=a.has(h.path),m=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":m,...c?{"aria-expanded":u}:{},onContextMenu:f=>{f.preventDefault(),n==null||n(f,h.path,h.name,h.type)},onClick:()=>{c?l(f=>{const _=new Set(f);return _.has(h.path)?_.delete(h.path):_.add(h.path),_}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${m?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:u?r.jsx(ls,{size:14}):r.jsx(ur,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Xn(h.name,h.type,u)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Rh(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:f=>{f.stopPropagation(),i(h.path,h.name)},onKeyDown:f=>{f.key==="Enter"&&(f.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(ft,{size:12})})]}),c&&u&&h.children&&r.jsx(Ph,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Mh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Mh(i.children,i.path+"/"));return s}function Mv(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[u,m]=d.useState(new Set),f=d.useCallback(async()=>{try{const y=await W.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{f()},[f]);const _=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await W.setSecret(y,n),i(""),o(""),await f()}catch(x){c(x instanceof Error?x.message:"Failed to set secret")}}},p=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await W.deleteSecret(y),await f()}catch(x){c(x instanceof Error?x.message:"Failed to delete secret")}},g=y=>{m(x=>{const k=new Set(x);return k.has(y)?k.delete(y):k.add(y),k})},v=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(ii,{variant:"text",width:"180px",height:"16px"}),r.jsx(ii,{variant:"block",width:"100%",height:"60px"}),r.jsx(ii,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ot,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),v.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:v.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:u.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>g(y),className:"text-muted hover:text-ink transition-colors",title:u.has(y)?"Hide value":"Show value",children:u.has(y)?r.jsx(Ad,{size:14}):r.jsx(ys,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>p(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(eo,{size:14})})})]},y))})]})}),v.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("button",{onClick:_,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(mr,{size:14}),"Add"]})]})]})]})})}function Lv({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[l,h]=d.useState(""),[c,u]=d.useState(!0),[m,f]=d.useState(!1),[_,p]=d.useState(null),g=d.useCallback(async()=>{try{const x=await W.getDocsStatus(e);if(s(x),x.has_docs){const k=await W.getDocFiles(e);n(k.files)}}catch{}u(!1)},[e]);d.useEffect(()=>{g()},[g]);const v=async()=>{f(!0),p(null);try{await W.generateDocs(e);const x=setInterval(async()=>{try{const k=await W.getDocsStatus(e);if(k.has_docs){s(k);const j=await W.getDocFiles(e);n(j.files),f(!1),clearInterval(x)}}catch{}},3e3);setTimeout(()=>{clearInterval(x),f(!1)},3e5)}catch(x){p(x instanceof Error?x.message:"Failed to start doc generation"),f(!1)}},y=async x=>{try{const k=await W.getDocFileContent(e,x);a(x),h(k)}catch(k){p(k instanceof Error?k.message:"Failed to load doc file")}};return c?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(ii,{variant:"text",width:"180px",height:"16px"}),r.jsx(ii,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(Xl,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:l})})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Documentation"}),_&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:_})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(he,{onClick:v,disabled:m,size:"sm",variant:"secondary",children:[r.jsx(gt,{size:14,className:m?"animate-spin":""}),m?"Updating...":"Update Docs"]}):r.jsx(he,{onClick:v,disabled:m,size:"sm",children:m?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(x=>r.jsxs("button",{onClick:()=>y(x.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(fi,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:x.name}),r.jsx("span",{className:"text-xs text-muted",children:x.size<1024?`${x.size} B`:`${(x.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},x.name))}):t!=null&&t.has_docs?null:r.jsx("p",{className:"text-sm text-muted",children:'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}),(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function Bv({session:e,onClose:t}){var ea;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[u,m]=d.useState(!1),[f,_]=d.useState("code"),[p,g]=d.useState(!1),[v,y]=d.useState(!1),[x,k]=d.useState(e),j=d.useRef(null),[w,D]=d.useState([]),[T,U]=d.useState(!1),[G,K]=d.useState(""),A=d.useRef(null),M=d.useRef(null),[E,L]=d.useState(0),[S,N]=d.useState(null),[C,B]=d.useState(!0),[X,oe]=d.useState(!0),[q,Q]=d.useState(!1),[ie,de]=d.useState("overview"),ue=57374,[z,V]=d.useState(null),J=d.useCallback(()=>{Q(b=>{const I=!b;return B(!I),oe(!I),I})},[]),[R,ae]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${x.id}`)||"standard"),[_e,Ee]=d.useState(()=>sessionStorage.getItem(`pl_provider_${x.id}`)||"claude"),[ee,fe]=d.useState(null),[ge,Ce]=d.useState(null),[Ge,Ls]=d.useState(!1),[us,et]=d.useState(!1),[le,ot]=d.useState({phase:"idle",iteration:0,maxIterations:10,cost:0,startTime:0}),[at,fs]=d.useState(!1),[Bs,bi]=d.useState(null),Ts=d.useRef(null),[Lh,No]=d.useState(!1),[Bh,Eo]=d.useState([]),[Do,zs]=d.useState(null),[Th,yr]=d.useState(!1),[zh,yi]=d.useState(!1),[Ah,As]=d.useState(!1),[Si,Ro]=d.useState("files"),{history:Po,recordTokens:Mo}=qx(),[Oh,$h]=d.useState(null),[Lo,Ih]=d.useState({line:1,column:1}),[Fh,Bo]=d.useState(0),{device:Hh,setDevice:Wh,frameClass:To}=Jx(),[Sr,Uh]=d.useState(100),[zo,Kh]=d.useState(!1),[wi,wr]=d.useState(!1),[Ao,zv]=d.useState([]),ms=d.useRef(null),[qh,Oo]=d.useState(0),{subscribe:$o}=kd(),Ye=d.useCallback(async()=>{try{const b=await W.getSessionDetail(x.id);k(b)}catch{}},[x.id]),Io=d.useCallback(async()=>{try{await W.stopSession(),Ls(!1),et(!1)}catch{}},[]),Vh=d.useCallback(async()=>{try{await W.pauseSession(),et(!0)}catch{}},[]),Gh=d.useCallback(async()=>{try{await W.resumeSession(),et(!1)}catch{}},[]),Fo=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await W.getStatus();Ls(F.running),et(F.paused),F.provider&&Ee(F.provider);const te=F.phase||"idle";if(te!==Fo.current&&te!=="idle"){const Xe=new Date().toISOString(),Rt={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},yt={starting:"Setting up the build environment and checking prerequisites...",planning:"Analyzing requirements and designing the architecture...",building:"Writing code and creating project files...",testing:"Running test suite to verify everything works...",reviewing:"Checking code quality and best practices...",complete:"All done. Your project is ready."},Is=[{id:`phase-${Date.now()}`,type:"phase_change",message:Rt[te]||`Phase: ${te}`,timestamp:Xe}];yt[te]&&Is.push({id:`narration-${Date.now()}`,type:"narration",message:yt[te],timestamp:Xe}),Eo(Pi=>[...Pi,...Is]),Fo.current=te}ot({phase:te,iteration:F.iteration||0,maxIterations:F.max_iterations||10,cost:F.cost||0,startTime:F.start_time?F.start_time*1e3:0});const Ke=F.tokens_used;Ke!=null&&Mo(Ke)}catch{}};b();const I=setInterval(b,Ge?3e3:1e4);return()=>clearInterval(I)},[Ge,Mo]),d.useEffect(()=>{if(!(ge!=null&&ge.loading))return;const b=setInterval(()=>{Ce(I=>I?{...I,elapsed:Math.floor((Date.now()-I.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[ge==null?void 0:ge.loading]);const[se,Yh]=d.useState(null);d.useEffect(()=>{W.getPreviewInfo(x.id).then(Yh).catch(()=>{})},[x.id]);const[$,Ci]=d.useState(null),[Os,Ho]=d.useState(!1),[Wo,Uo]=d.useState(!1),[Ko,ki]=d.useState(null),[Kt,Xh]=d.useState("");d.useEffect(()=>{const b=$o("file_changed",I=>{const F=I;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),Ke=F.paths.map((Xe,Rt)=>{var Pi;const yt=(Pi=F.event_types)==null?void 0:Pi[Rt],Is=yt==="created"||yt==="IN_CREATE";return{id:`file-${Date.now()}-${Rt}`,type:Is?"file_created":"file_modified",message:Is?`Created ${Xe.split("/").pop()}`:`Modified ${Xe.split("/").pop()}`,timestamp:te,filePath:Xe}});if(Eo(Xe=>[...Xe,...Ke]),fs(!0),Ts.current&&clearTimeout(Ts.current),Ts.current=setTimeout(()=>fs(!1),2e3),Ye(),s&&F.paths.some(Rt=>Rt===s||s.endsWith(Rt))&&bi(s),f==="preview"){const Xe=["react","vite","next","nuxt","svelte","remix"];($==null?void 0:$.running)&&($==null?void 0:$.framework)&&Xe.some(yt=>$.framework.toLowerCase().includes(yt))||L(yt=>yt+1)}});return()=>{b(),Ts.current&&clearTimeout(Ts.current)}},[$o,s,f,$==null?void 0:$.running,Ye]);const Jh=d.useCallback(async()=>{if(!(!Bs||!x.id)){try{const b=await W.getSessionFileContent(x.id,Bs);l(b.content),c(b.content),g(!1),D(I=>I.map(F=>F.path===Bs?{...F,content:b.content,modified:!1}:F))}catch{}bi(null)}},[Bs,x.id]);d.useEffect(()=>{if(f!=="preview")return;let b=!1;const I=async()=>{try{const te=await W.devserver.status(x.id);b||Ci(te)}catch{}};I();const F=setInterval(I,3e3);return()=>{b=!0,clearInterval(F)}},[f,x.id]),d.useEffect(()=>{f==="dashboard"&&fetch(`http://127.0.0.1:${ue}/health`).then(b=>V(b.ok)).catch(()=>V(!1))},[f]);const ps=d.useCallback(async b=>{Ho(!0),ki(null);try{const I=await W.devserver.start(x.id,b);if(I.status==="error")ki(I.message||"Failed to start dev server");else{const F=await W.devserver.status(x.id);Ci(F)}}catch(I){ki(I instanceof Error?I.message:"Failed to start dev server")}Ho(!1)},[x.id]),qo=d.useRef(!1);d.useEffect(()=>{qo.current||se!=null&&se.dev_command&&($!=null&&$.running||($==null?void 0:$.status)==="starting"||Os||(qo.current=!0,ps(se.dev_command)))},[se==null?void 0:se.dev_command,$==null?void 0:$.running,$==null?void 0:$.status,Os,ps]);const Zh=d.useCallback(async()=>{try{await W.devserver.stop(x.id);const b=await W.devserver.status(x.id);Ci(b)}catch{}},[x.id]),Qh=d.useCallback(async()=>{Uo(!0);try{const b=await W.fixProject(x.id);if(b.task_id){let F=0,te;do await new Promise(Xe=>setTimeout(Xe,2e3)),te=await W.chatPoll(x.id,b.task_id),F++;while(!te.complete&&F<150);const Ke=await W.devserver.status(x.id);Ci(Ke)}}catch(b){ki(b instanceof Error?b.message:"Fix failed")}Uo(!1)},[x.id]),gs=$!=null&&$.running&&($!=null&&$.port)?$.framework==="expo"?`${Zr}/api/sessions/${encodeURIComponent(x.id)}/expo-qr`:$.portless_url||`http://localhost:${$.port}/`:null,ed=(se==null?void 0:se.preview_url)||`${Zr}/api/sessions/${encodeURIComponent(x.id)}/preview/index.html`,td=gs||ed,[ji,Vo]=d.useState([]),[vt,Ni]=d.useState(0);d.useEffect(()=>{const b=gs||(se==null?void 0:se.preview_url);b&&(Vo([b]),Ni(0))},[gs,se==null?void 0:se.preview_url]);const bt=ji[vt]||td,[Go,Cr]=d.useState(bt),sd=d.useCallback((b,I,F,te)=>{b.preventDefault(),N({x:b.clientX,y:b.clientY,path:I,name:F,type:te})},[]),id=d.useCallback(()=>{vt>0&&(Ni(b=>b-1),L(b=>b+1))},[vt]),rd=d.useCallback(()=>{vt<ji.length-1&&(Ni(b=>b+1),L(b=>b+1))},[vt,ji.length]),nd=d.useCallback(b=>{let I=b;if(b.startsWith("/")&&gs)try{I=`${new URL(gs).origin}${b}`}catch{const F=$==null?void 0:$.port;F&&(I=`http://localhost:${F}${b}`)}Vo(F=>[...F.slice(0,vt+1),I]),Ni(F=>F+1),L(F=>F+1)},[vt,gs,$==null?void 0:$.port]);d.useEffect(()=>{try{const b=new URL(bt,window.location.origin);Cr(b.pathname+b.search+b.hash||"/")}catch{Cr(bt)}},[bt]);const Ei=d.useCallback(async()=>{Ce({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await W.reviewProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),Di=d.useCallback(async()=>{Ce({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await W.testProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),kr=d.useCallback(async()=>{Ce({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),fe(null);try{const b=await W.explainProject(x.id);fe(b.output)}catch(b){fe(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ce(null)}},[x.id]),jr=d.useCallback(async(b,I)=>{if(window.confirm(`Delete "${I}"?`))try{await W.deleteSessionFile(x.id,b),s===b&&(i(null),o(""),l(null),c(null),g(!1)),await Ye()}catch(te){const Ke=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${Ke}`)}},[x.id,s,Ye]),od=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:ys,onClick:()=>{Ei()}},{label:"Generate Tests",icon:ri,onClick:()=>{Di()}},{label:"Explain",icon:Gs,onClick:()=>{kr()}},{label:"Delete",icon:eo,onClick:()=>{jr(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:ys,onClick:()=>{Ei()}},{label:"Run Tests",icon:ri,onClick:()=>{Di()}}],[Ei,Di,kr,jr]),Dt=d.useCallback(async(b,I)=>{bi(null),p&&s&&h!==null&&D(te=>te.map(Ke=>Ke.path===s?{...Ke,content:h,modified:!0}:Ke));const F=w.find(te=>te.path===b);if(F){i(b),o(I),l(F.content),c(F.content),g(F.modified);return}i(b),o(I),m(!0),g(!1);try{const te=x.id?await W.getSessionFileContent(x.id,b):await W.getFileContent(b);l(te.content),c(te.content),D(Ke=>[...Ke,{path:b,name:I,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{m(!1)}},[x.id,p,s,h,w]),Nr=d.useCallback(async()=>{var b;if(!(!s||h===null||!x.id)){y(!0);try{await W.saveSessionFile(x.id,s,h),l(h),g(!1),$h(Date.now()),D(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const I=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(I)&&L(F=>F+1)}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,x.id]),Yo=d.useCallback(b=>{const I=w.find(F=>F.path===b);if(!(I!=null&&I.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(D(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),g(te.modified)}else i(null),o(""),l(null),c(null),g(!1)}},[w,s]);d.useEffect(()=>{const b=I=>{(I.metaKey||I.ctrlKey)&&I.key==="s"&&(I.preventDefault(),p&&s&&Nr()),(I.metaKey||I.ctrlKey)&&I.key==="p"&&(I.preventDefault(),U(F=>!F),K("")),(I.metaKey||I.ctrlKey)&&I.key==="k"&&(I.preventDefault(),No(F=>!F)),I.key==="Escape"&&T&&U(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[p,s,Nr,T]),d.useEffect(()=>{T&&A.current&&A.current.focus()},[T]);const Xo=Mh(x.files),$s=G?Xo.filter(b=>b.path.toLowerCase().includes(G.toLowerCase())):Xo;d.useEffect(()=>{const b=x.files.find(I=>I.name==="index.html"&&I.type==="file");b&&Dt(b.path,b.name)},[]);const ad=d.useCallback(b=>{b!==void 0&&(c(b),g(b!==a),Bo(b.split(`
|
|
256
|
+
`).length))},[a]),ld=d.useCallback(b=>{j.current=b;const I=b;if(I!=null&&I.onDidChangeCursorPosition&&I.onDidChangeCursorPosition(F=>{Ih({line:F.position.lineNumber,column:F.position.column})}),I!=null&&I.getModel){const F=I.getModel();F!=null&&F.getLineCount&&Bo(F.getLineCount())}},[]),cd=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await W.createSessionFile(x.id,b.trim()),await Ye()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[x.id,Ye]),hd=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await W.createSessionDirectory(x.id,b.trim()),await Ye()}catch(I){const F=I instanceof Error?I.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[x.id,Ye]),Jo=d.useCallback(async()=>{try{const b=await W.previewChanges(x.id,"preview current changes");zs(b)}catch{}},[x.id]),dd=d.useCallback(()=>{zs(null),Ye()},[Ye]),ud=d.useCallback(b=>{zs(null),Ye()},[Ye]),fd=d.useCallback(()=>{zs(null)},[]),Zo=s?Dh(x.files,s):void 0,md=((ea=n.split(".").pop())==null?void 0:ea.toUpperCase())||"",{showHelp:pd,setShowHelp:Qo}=gx({onToggleBuild:()=>{Ge&&Io()}}),gd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:ys,action:()=>_("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:rn,action:()=>_("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:es,action:()=>oe(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Er,action:()=>_("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:$t,action:()=>_("deploy")},{id:"git",label:"Git Status",category:"command",icon:ze,action:()=>_("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:na,action:()=>_("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:Z,action:()=>{U(!0),K("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:on,action:()=>J()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:oa,action:()=>B(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:ze,action:()=>Jo()},{id:"insights",label:"Build Insights",category:"command",icon:Qr,action:()=>_("insights")},{id:"docs",label:"Documentation",category:"command",icon:Gs,action:()=>_("docs")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:ts,action:()=>As(!0)}],[_,J,Jo]),Ri=d.useMemo(()=>{if(!Ge)return"idle";const b=(le.phase||x.status||"").toLowerCase();return b.includes("starting")||b.includes("plan")||b.includes("bootstrap")?"planning":b.includes("review")||b.includes("council")?"reviewing":b.includes("test")||b.includes("verify")?"testing":b.includes("complete")||b.includes("fulfilled")?"complete":"building"},[Ge,le.phase,x.status]);return r.jsxs("div",{className:"flex flex-col h-full relative",children:[r.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[r.jsx("button",{onClick:()=>{p&&!window.confirm("Unsaved changes. Discard?")||t()},className:"text-xs font-medium px-3 py-1.5 rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Back"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:x.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:x.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${x.status==="completed"||x.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:x.status}),Po.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Kx,{tokenHistory:Po})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>B(b=>!b),title:C?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:C?r.jsx(oa,{size:16}):r.jsx(Su,{size:16})}),r.jsx("button",{onClick:()=>oe(b=>!b),title:X?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:X?r.jsx(xu,{size:16}):r.jsx(bu,{size:16})}),r.jsx("button",{onClick:J,title:q?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${q?"text-primary":"text-muted hover:text-ink"}`,children:q?r.jsx(lc,{size:16}):r.jsx(on,{size:16})})]}),!Ge&&r.jsx(he,{variant:"primary",size:"sm",icon:It,onClick:()=>{if(!(x.prd||"").trim()){window.alert("No spec found for this project. Go to Home to start a new build.");return}yi(!0)},title:"Start build for this project",children:"Build"}),!Ge&&Ri==="complete"&&r.jsx(he,{variant:"ghost",size:"sm",icon:sn,onClick:()=>yr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(Pt,{icon:ts,label:"Natural language search",size:"sm",onClick:()=>As(!0)}),Ge&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[us?r.jsx(he,{variant:"ghost",size:"sm",icon:It,onClick:Gh,title:"Resume build",children:"Resume"}):r.jsx(he,{variant:"ghost",size:"sm",icon:Jl,onClick:Vh,title:"Pause build",children:"Pause"}),r.jsx(he,{variant:"danger",size:"sm",icon:tr,onClick:Io,title:"Stop build",children:"Stop"})]}),r.jsx(Pt,{icon:ys,label:"Review project",size:"sm",onClick:Ei,disabled:!!(ge!=null&&ge.loading)}),r.jsx(Pt,{icon:ri,label:"Run tests",size:"sm",onClick:Di,disabled:!!(ge!=null&&ge.loading)}),r.jsx(Pt,{icon:Gs,label:"Explain project",size:"sm",onClick:kr,disabled:!!(ge!=null&&ge.loading)}),r.jsx(he,{variant:"secondary",size:"sm",icon:$t,onClick:()=>_("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(xx,{onClick:()=>Qo(!0)})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"flex-1",children:r.jsx(nx,{phase:Ri,iteration:le.iteration,maxIterations:le.maxIterations,cost:le.cost,startTime:le.startTime,isRunning:Ge})}),Ge&&r.jsx("div",{className:"flex-shrink-0 pr-2",children:r.jsx(gv,{gatePassRate:.8,testCoverage:le.iteration>2?60:20,iteration:le.iteration,maxIterations:le.maxIterations,phase:Ri,compact:!0})})]}),r.jsx(Mx,{sessionId:x.id,onRestore:Ye}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(cn,{orientation:"vertical",children:[r.jsx(Js,{defaultSize:70,minSize:40,children:r.jsxs(cn,{orientation:"horizontal",className:"h-full",children:[C&&r.jsx(Js,{defaultSize:20,minSize:15,children:r.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[r.jsxs("div",{className:"flex items-center border-b border-border flex-shrink-0",children:[r.jsxs("button",{onClick:()=>Ro("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Si==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(ro,{size:14}),"Files",at&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Ro("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Si==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(ql,{size:14}),"Chat"]}),Si==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:cd,title:"New File",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(fr,{size:12})," New"]}),r.jsxs("button",{onClick:hd,title:"New Folder",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(Pd,{size:12})," New"]})]})]}),Si==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:x.files.length>0?r.jsx(Ph,{nodes:x.files,selectedPath:s,onSelect:Dt,onDelete:jr,onContextMenu:sd}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(nn,{size:28,className:"text-muted/40 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(mv,{sessionId:x.id,defaultMode:R})})})]})}),C&&r.jsx(hn,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(Js,{defaultSize:80,minSize:40,children:r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[r.jsx("div",{className:"flex items-center border-b border-border bg-hover px-1 flex-shrink-0",role:"tablist",children:[{id:"code",label:"Code",icon:rn},{id:"preview",label:"Preview",icon:ys},{id:"deploy",label:"Deploy",icon:$t},{id:"config",label:"Config",icon:na},{id:"secrets",label:"Secrets",icon:du},{id:"prd",label:"Spec",icon:fi},{id:"dashboard",label:"Dashboard",icon:Er},{id:"git",label:"Git",icon:ze},{id:"cicd",label:"CI/CD",icon:ze},{id:"insights",label:"Insights",icon:Qr},{id:"docs",label:"Docs",icon:Gs}].map(b=>r.jsxs("button",{role:"tab","aria-selected":f===b.id,onClick:()=>_(b.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${f===b.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(b.icon,{size:14}),b.label]},b.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[f==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[w.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:w.map(b=>r.jsxs("button",{onClick:()=>Dt(b.path,b.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${b.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Xn(b.name,"file")}),b.name,b.modified&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),r.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:I=>{I.stopPropagation(),Yo(b.path)},onKeyDown:I=>{I.key==="Enter"&&(I.stopPropagation(),Yo(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(ft,{size:12})})]},b.path))}),s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[r.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),v&&r.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),r.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:Zo!=null?Rh(Zo):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:md}),p&&r.jsx("button",{onClick:Nr,className:"text-xs font-medium px-2 py-0.5 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:"Save"})]}),Bs===s&&r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[r.jsx(gt,{size:12,className:"text-warning"}),r.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsx("button",{onClick:Jh,className:"text-xs font-medium px-2 py-0.5 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors",children:"Reload"}),r.jsx("button",{onClick:()=>bi(null),className:"text-xs font-medium px-2 py-0.5 rounded border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Dismiss"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:u?r.jsx(jd,{}):r.jsx(Hi,{name:"Editor",children:r.jsx(Vf,{value:h??"",language:Pv(n),theme:"vs",onChange:ad,onMount:ld,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8},renderLineHighlight:"line",smoothScrolling:!0,cursorBlinking:"smooth",folding:!0,bracketPairColorization:{enabled:!0}}})})}),r.jsx(Yx,{selectedFile:s,fileName:n,isModified:p,isSaving:v,lastSavedAt:Oh,lineCount:Fh,cursorLine:Lo.line,cursorColumn:Lo.column,buildTime:le.phase==="complete"&&le.startTime?Math.floor((Date.now()-le.startTime)/1e3):void 0,sessionId:x.id,prd:x.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(Z,{size:32,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),r.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Cmd+P"})," to quick open"]})]})]}),f==="preview"&&r.jsx(Hi,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${zo?"preview-fullscreen":""}`,children:[r.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover flex-shrink-0",children:$!=null&&$.running||se!=null&&se.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(Pt,{icon:Xl,label:"Back",size:"sm",onClick:id,disabled:vt<=0}),r.jsx(Pt,{icon:Zn,label:"Forward",size:"sm",onClick:rd,disabled:vt>=ji.length-1}),r.jsx(rv,{onClick:()=>{wr(!0),L(b=>b+1)}}),r.jsx("input",{value:Go,onChange:b=>Cr(b.target.value),onKeyDown:b=>{b.key==="Enter"&&nd(Go)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(Xx,{selectedDevice:Hh,onDeviceChange:Wh,containerWidth:qh}),r.jsx(Qx,{zoom:Sr,onZoomChange:Uh}),r.jsx(sv,{url:bt}),r.jsx(tv,{}),r.jsx(nv,{url:bt}),r.jsx(Pt,{icon:ss,label:"Open in new tab",size:"sm",onClick:()=>window.open(bt,"_blank")}),r.jsx(iv,{isFullscreen:zo,onToggle:()=>Kh(b=>!b)}),($==null?void 0:$.running)&&r.jsxs("button",{onClick:Zh,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded border border-danger/40 bg-danger/10 text-danger hover:bg-danger/20 transition-colors",children:[r.jsx(tr,{size:12}),"Stop"]})]}):se?r.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:r.jsx("span",{className:"font-medium text-ink",children:se.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),$&&$.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${$.running?"bg-green-50 border-green-200 text-green-700":$.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":$.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${$.running?"bg-green-500":$.status==="starting"?"bg-yellow-500 animate-pulse":$.status==="error"?"bg-red-500":"bg-gray-400"}`}),$.running&&$.portless_url&&r.jsxs("span",{children:["Running at ",$.portless_url]}),$.running&&$.port&&!$.portless_url&&r.jsxs("span",{children:["Running on port ",$.port]}),$.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),$.status==="error"&&!$.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),$.status==="error"&&$.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",$.auto_fix_status]}),$.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:$.command})]}),$!=null&&$.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[wi&&r.jsx(Tl,{}),r.jsx("div",{ref:ms,className:`flex-1 bg-white overflow-auto flex justify-center ${wi?"hidden":""}`,children:r.jsx("div",{className:`${To} h-full preview-zoom-${Sr}`,children:r.jsx("iframe",{ref:M,src:bt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{wr(!1),ms.current&&Oo(ms.current.clientWidth)}},E)})}),r.jsx(Bl,{messages:Ao})]}):se!=null&&se.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[wi&&r.jsx(Tl,{}),r.jsx("div",{ref:ms,className:`flex-1 bg-white overflow-auto flex justify-center ${wi?"hidden":""}`,children:r.jsx("div",{className:`${To} h-full preview-zoom-${Sr}`,children:r.jsx("iframe",{ref:M,src:bt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{wr(!1),ms.current&&Oo(ms.current.clientWidth)}},E)})}),r.jsx(Bl,{messages:Ao})]}):se?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:se.type==="api"||se.type==="python-api"?r.jsx(Hd,{size:28,className:"text-primary"}):se.type==="library"?r.jsx(Zl,{size:28,className:"text-primary"}):se.type==="go-app"||se.type==="rust-app"?r.jsx(es,{size:28,className:"text-primary"}):r.jsx(nn,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:se.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:se.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[se.dev_command&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:se.dev_command}),r.jsxs("button",{onClick:()=>ps(se.dev_command||void 0),disabled:Os,className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary/90 transition-colors disabled:opacity-50",children:[r.jsx(It,{size:12}),Os?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:se.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:se.dev_command?"Or use a custom command:":"Start a dev server:"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:Kt,onChange:b=>Xh(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Kt.trim()&&ps(Kt.trim())},placeholder:"e.g. npm run dev",className:"flex-1 px-3 py-1.5 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx("button",{onClick:()=>Kt.trim()&&ps(Kt.trim()),disabled:Os||!Kt.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-btn border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:"Run"})]})]})]}),Ko&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),r.jsx("p",{className:"text-xs text-danger/80",children:Ko})]}),($==null?void 0:$.status)==="error"&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:Qh,disabled:Wo,className:"text-xs px-2 py-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:Wo?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>ps(se.dev_command||Kt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),$.auto_fix_status&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),r.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",$.auto_fix_status]}),$.auto_fix_attempts!==void 0&&$.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",$.auto_fix_attempts,"/3"]})]}),$.output.length>0&&r.jsx("pre",{className:"text-[11px] font-mono text-danger/70 bg-danger/5 p-2 rounded max-h-32 overflow-y-auto whitespace-pre-wrap",children:$.output.slice(-10).join(`
|
|
257
|
+
`)})]}),se.port&&!($!=null&&$.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",se.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),f==="config"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),r.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:_e})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{onClick:()=>{Ee(b),sessionStorage.setItem(`pl_provider_${x.id}`,b),W.setProvider(b).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${_e===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{ae(b),sessionStorage.setItem(`pl_buildmode_${x.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${R===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),r.jsx("input",{value:x.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),r.jsx("input",{value:x.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),f==="secrets"&&r.jsx(Mv,{}),f==="prd"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),x.prd?r.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:x.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No spec found for this project."})]})}),f==="deploy"&&r.jsx(fx,{sessionId:x.id}),f==="dashboard"&&(z===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(Er,{size:48,className:"text-muted/30"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),r.jsx("p",{className:"text-sm text-muted max-w-md",children:"The Loki Dashboard provides task boards, RARV timeline, quality gates, and cost tracking. Start it to see project analytics."}),r.jsx("button",{onClick:async()=>{V(null);try{const b=await fetch(`http://127.0.0.1:${ue}/health`);V(b.ok)}catch{V(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[[{id:"overview",label:"Overview"},{id:"tasks",label:"Tasks"},{id:"timeline",label:"RARV Timeline"},{id:"quality",label:"Quality"},{id:"cost",label:"Cost"}].map(b=>r.jsx("button",{onClick:()=>de(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${ie===b.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:b.label},b.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${ue}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(ss,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${ue}/#${ie}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),f==="git"&&r.jsx(Px,{sessionId:x.id}),f==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Rv,{sessionId:e.id})}),f==="docs"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Lv,{sessionId:x.id})}),f==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(bv,{filesCreated:x.files.filter(b=>b.type==="file").length,filesModified:0,linesGenerated:0,testsGenerated:0,testPassRate:0,totalTokens:0,phaseBreakdown:[],totalTimeSecs:le.startTime?Math.floor((Date.now()-le.startTime)/1e3):0,qualityScore:0,totalCost:le.cost,iterations:le.iteration,provider:_e})})]})]})})]})}),X&&r.jsx(hn,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),X&&r.jsx(Js,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx(Hi,{name:"ActivityPanel",children:r.jsx(ix,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:x.status==="running"||x.status==="in_progress",buildMode:R,buildEvents:Bh,onFileClick:b=>Dt(b,b.split("/").pop()||b)})})})]})}),(ge==null?void 0:ge.loading)&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),r.jsxs("span",{className:"text-sm font-medium text-ink",children:[ge.type==="review"?"Reviewing project":ge.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[ge.elapsed,"s"]})]})}),ee&&r.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4 max-h-64 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),r.jsx(Pt,{icon:ft,label:"Close",size:"sm",onClick:()=>fe(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:ee})]}),S&&r.jsx(Rm,{x:S.x,y:S.y,items:od(S),onClose:()=>N(null)}),T&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",role:"dialog","aria-modal":"true","aria-label":"Quick open file search",onClick:()=>U(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsx("input",{ref:A,type:"text",value:G,onChange:b=>K(b.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:b=>{b.key==="Enter"&&$s.length>0&&(Dt($s[0].path,$s[0].name),U(!1)),b.key==="Escape"&&U(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[$s.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{Dt(b.path,b.name),U(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[r.jsx("span",{className:"w-5 flex items-center justify-center",children:Xn(b.name,"file")}),r.jsx("span",{className:"text-ink",children:b.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:b.path})]},b.path)),$s.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(_x,{open:pd,onClose:()=>Qo(!1)}),r.jsx(Sx,{isOpen:Lh,onClose:()=>No(!1),commands:gd,sessionId:x.id,onFileSelect:Dt}),Do&&r.jsx(Tx,{data:Do,onAcceptAll:dd,onAcceptSelected:ud,onReject:fd,onClose:()=>zs(null)}),r.jsx(Ux,{phase:Ri,buildTime:le.startTime?Math.floor((Date.now()-le.startTime)/1e3):void 0}),Th&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>yr(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Build Replay"}),r.jsx("button",{onClick:()=>yr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(wv,{sessionId:x.id,files:x.files.map(b=>({path:b.path,type:b.type})),phases:["planning","building","testing","reviewing","complete"],checkpoints:[],qualityGates:[],totalIterations:le.iteration||le.maxIterations})})]})}),Ah&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>As(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Search Files"}),r.jsx("button",{onClick:()=>As(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(ft,{size:16})})]}),r.jsx(Nv,{sessionId:x.id,onOpenFile:(b,I)=>{Dt(b,b.split("/").pop()||b),As(!1)},className:"p-4"})]})}),zh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>yi(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:b=>b.stopPropagation(),children:r.jsx(Dv,{complexity:R==="quick"?"simple":R==="max"?"complex":"standard",provider:_e,estimatedIterations:le.maxIterations,onConfirm:async()=>{yi(!1);try{const b=x.prd||"";await W.startSession({prd:b,provider:_e,projectDir:x.path}),Ls(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>yi(!1)})})})]})}function Tv(){const{sessionId:e}=Nd(),t=Ed(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),W.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),o(!1)}))},[e]),n?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),r.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),r.jsx("button",{onClick:()=>t("/"),className:"mt-4 px-4 py-2 rounded-btn text-sm font-semibold border border-primary/30 text-primary hover:bg-primary/5 transition-all",children:"Back to Home"})]})}):r.jsx("div",{className:"h-screen bg-background flex flex-col",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Hi,{name:"ProjectWorkspace",children:r.jsx(Bv,{session:s,onClose:()=>t("/")})})})})}const bb=Object.freeze(Object.defineProperty({__proto__:null,default:Tv},Symbol.toStringTag,{value:"Module"}));export{pr as L,bb as P,ju as S};
|