tmex-cli 0.2.1 → 0.2.2

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.
@@ -1,24 +1,24 @@
1
- import{c as fi,bw as qn,bx as jn,by as Vn,r as w,bz as Ae,bA as Os,j as B,b as Ss,u as Fr,bB as ws,bC as Yn,bD as bs,d as Ve,e as Xn,bE as Dt,f as wi,B as _t}from"./index-35UZ83ei.js";import{T as Gn,A as Jn,a as Zn,b as Qn,c as eo,d as to,e as io,f as so,g as ro}from"./useValueChanged-ia5UgAxm.js";import{L as bi,S as no,a as Ns}from"./switch-MW4hLOq6.js";/**
1
+ import{c as gi,bw as Vn,bx as Yn,by as Xn,r as C,bz as Ie,bA as Hs,j as M,b as Cs,u as $r,bB as xs,bC as Gn,bD as ks,d as Ve,e as Jn,bE as Mt,f as xi,B as ft}from"./index-BHd4Baer.js";import{T as Zn,A as Qn,a as eo,b as to,c as io,d as so,e as ro,f as no,g as oo}from"./useValueChanged-BLDl3GEN.js";import{L as ki,S as ao,a as zs}from"./switch-0pbATkFp.js";/**
2
2
  * @license lucide-react v0.564.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const oo=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],ao=fi("arrow-down-to-line",oo);/**
6
+ */const lo=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],ho=gi("arrow-down-to-line",lo);/**
7
7
  * @license lucide-react v0.564.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const lo=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],ho=fi("keyboard",lo);/**
11
+ */const co=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],uo=gi("keyboard",co);/**
12
12
  * @license lucide-react v0.564.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const co=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],uo=fi("refresh-cw",co);/**
16
+ */const _o=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],fo=gi("refresh-cw",_o);/**
17
17
  * @license lucide-react v0.564.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const _o=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],fo=fi("smartphone",_o);var Xt={};/**
21
+ */const po=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],go=gi("smartphone",po);var Jt={};/**
22
22
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
23
23
  * @license MIT
24
24
  *
@@ -29,22 +29,22 @@ import{c as fi,bw as qn,bx as jn,by as Vn,r as w,bz as Ae,bA as Os,j as B,b as S
29
29
  * Fabrice Bellard's javascript vt100 for jslinux:
30
30
  * http://bellard.org/jslinux/
31
31
  * Copyright (c) 2011 Fabrice Bellard
32
- */var Wr=Object.defineProperty,po=Object.getOwnPropertyDescriptor,go=(e,t)=>{for(var i in t)Wr(e,i,{get:t[i],enumerable:!0})},ae=(e,t,i,s)=>{for(var r=s>1?void 0:s?po(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Wr(t,i,r),r},D=(e,t)=>(i,s)=>t(i,s,e),Hs="Terminal input",Oi={get:()=>Hs,set:e=>Hs=e},zs="Too much output to announce, navigate to rows manually to read",Ni={get:()=>zs,set:e=>zs=e};function mo(e){return e.replace(/\r?\n/g,"\r")}function vo(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function So(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function wo(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");$r(r,t,i,s)}}function $r(e,t,i,s){e=mo(e),e=vo(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Kr(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Fs(e,t,i,s,r){Kr(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function nt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function pi(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var bo=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let l=e.charCodeAt(n);56320<=l&&l<=57343?t[s++]=(o-55296)*1024+l-56320+65536:(t[s++]=o,t[s++]=l);continue}o!==65279&&(t[s++]=o)}return s}},yo=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,l,h=0,a=0;if(this.interim[0]){let _=!1,u=this.interim[0];u&=(u&224)===192?31:(u&240)===224?15:7;let f=0,p;for(;(p=this.interim[++f]&63)&&f<4;)u<<=6,u|=p;let y=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,v=y-f;for(;a<v;){if(a>=i)return 0;if(p=e[a++],(p&192)!==128){a--,_=!0;break}else this.interim[f++]=p,u<<=6,u|=p&63}_||(y===2?u<128?a--:t[s++]=u:y===3?u<2048||u>=55296&&u<=57343||u===65279||(t[s++]=u):u<65536||u>1114111||(t[s++]=u)),this.interim.fill(0)}let d=i-4,c=a;for(;c<i;){for(;c<d&&!((r=e[c])&128)&&!((n=e[c+1])&128)&&!((o=e[c+2])&128)&&!((l=e[c+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=l,c+=4;if(r=e[c++],r<128)t[s++]=r;else if((r&224)===192){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(h=(r&31)<<6|n&63,h<128){c--;continue}t[s++]=h}else if((r&240)===224){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(l=e[c++],(l&192)!==128){c--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|l&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Ur="",ot=" ",qt=class qr{constructor(){this.fg=0,this.bg=0,this.extended=new li}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 qr;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}},li=class jr{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 jr(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},We=class Vr extends qt{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new li,this.combinedData=""}static fromCharData(t){let i=new Vr;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?nt(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 i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ws="di$target",Hi="di$dependencies",yi=new Map;function Co(e){return e[Hi]||[]}function Ce(e){if(yi.has(e))return yi.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");xo(t,i,r)};return t._id=e,yi.set(e,t),t}function xo(e,t,i){t[Ws]===t?t[Hi].push({id:e,index:i}):(t[Hi]=[{id:e,index:i}],t[Ws]=t)}var Me=Ce("BufferService"),Yr=Ce("CoreMouseService"),mt=Ce("CoreService"),ko=Ce("CharsetService"),ys=Ce("InstantiationService"),Xr=Ce("LogService"),Le=Ce("OptionsService"),Gr=Ce("OscLinkService"),Eo=Ce("UnicodeService"),jt=Ce("DecorationService"),zi=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var d;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new We,o=i.getTrimmedLength(),l=-1,h=-1,a=!1;for(let c=0;c<o;c++)if(!(h===-1&&!i.hasContent(c))){if(i.loadCell(c,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=c,l=n.extended.urlId;continue}else a=n.extended.urlId!==l;else h!==-1&&(a=!0);if(a||h!==-1&&c===o-1){let _=(d=this._oscLinkService.getLinkData(l))==null?void 0:d.uri;if(_){let u={start:{x:h+1,y:e},end:{x:c+(!a&&c===o-1?1:0),y:e}},f=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let p=new URL(_);["http:","https:"].includes(p.protocol)||(f=!0)}catch{f=!0}f||s.push({text:_,range:u,activate:(p,y)=>r?r.activate(p,y,u):Ro(p,y),hover:(p,y)=>{var v;return(v=r==null?void 0:r.hover)==null?void 0:v.call(r,p,y,u)},leave:(p,y)=>{var v;return(v=r==null?void 0:r.leave)==null?void 0:v.call(r,p,y,u)}})}a=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=c,l=n.extended.urlId):(h=-1,l=-1)}}t(s)}};zi=ae([D(0,Me),D(1,Le),D(2,Gr)],zi);function Ro(e,t){if(confirm(`Do you want to navigate to ${t}?
32
+ */var Kr=Object.defineProperty,mo=Object.getOwnPropertyDescriptor,vo=(e,t)=>{for(var i in t)Kr(e,i,{get:t[i],enumerable:!0})},le=(e,t,i,s)=>{for(var r=s>1?void 0:s?mo(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Kr(t,i,r),r},L=(e,t)=>(i,s)=>t(i,s,e),Fs="Terminal input",Fi={get:()=>Fs,set:e=>Fs=e},Ws="Too much output to announce, navigate to rows manually to read",Wi={get:()=>Ws,set:e=>Ws=e};function So(e){return e.replace(/\r?\n/g,"\r")}function wo(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function bo(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function yo(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Ur(r,t,i,s)}}function Ur(e,t,i,s){e=So(e),e=wo(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function qr(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function $s(e,t,i,s,r){qr(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function nt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function mi(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var Co=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let l=e.charCodeAt(n);56320<=l&&l<=57343?t[s++]=(o-55296)*1024+l-56320+65536:(t[s++]=o,t[s++]=l);continue}o!==65279&&(t[s++]=o)}return s}},xo=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,l,h=0,a=0;if(this.interim[0]){let _=!1,u=this.interim[0];u&=(u&224)===192?31:(u&240)===224?15:7;let f=0,p;for(;(p=this.interim[++f]&63)&&f<4;)u<<=6,u|=p;let b=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,g=b-f;for(;a<g;){if(a>=i)return 0;if(p=e[a++],(p&192)!==128){a--,_=!0;break}else this.interim[f++]=p,u<<=6,u|=p&63}_||(b===2?u<128?a--:t[s++]=u:b===3?u<2048||u>=55296&&u<=57343||u===65279||(t[s++]=u):u<65536||u>1114111||(t[s++]=u)),this.interim.fill(0)}let d=i-4,c=a;for(;c<i;){for(;c<d&&!((r=e[c])&128)&&!((n=e[c+1])&128)&&!((o=e[c+2])&128)&&!((l=e[c+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=l,c+=4;if(r=e[c++],r<128)t[s++]=r;else if((r&224)===192){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(h=(r&31)<<6|n&63,h<128){c--;continue}t[s++]=h}else if((r&240)===224){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(l=e[c++],(l&192)!==128){c--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|l&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},jr="",ot=" ",jt=class Vr{constructor(){this.fg=0,this.bg=0,this.extended=new ci}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 Vr;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}},ci=class Yr{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 Yr(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},We=class Xr extends jt{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ci,this.combinedData=""}static fromCharData(t){let i=new Xr;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?nt(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 i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ks="di$target",$i="di$dependencies",Ei=new Map;function ko(e){return e[$i]||[]}function xe(e){if(Ei.has(e))return Ei.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Eo(t,i,r)};return t._id=e,Ei.set(e,t),t}function Eo(e,t,i){t[Ks]===t?t[$i].push({id:e,index:i}):(t[$i]=[{id:e,index:i}],t[Ks]=t)}var Le=xe("BufferService"),Gr=xe("CoreMouseService"),vt=xe("CoreService"),Ro=xe("CharsetService"),Es=xe("InstantiationService"),Jr=xe("LogService"),Te=xe("OptionsService"),Zr=xe("OscLinkService"),Bo=xe("UnicodeService"),Vt=xe("DecorationService"),Ki=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var d;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new We,o=i.getTrimmedLength(),l=-1,h=-1,a=!1;for(let c=0;c<o;c++)if(!(h===-1&&!i.hasContent(c))){if(i.loadCell(c,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=c,l=n.extended.urlId;continue}else a=n.extended.urlId!==l;else h!==-1&&(a=!0);if(a||h!==-1&&c===o-1){let _=(d=this._oscLinkService.getLinkData(l))==null?void 0:d.uri;if(_){let u={start:{x:h+1,y:e},end:{x:c+(!a&&c===o-1?1:0),y:e}},f=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let p=new URL(_);["http:","https:"].includes(p.protocol)||(f=!0)}catch{f=!0}f||s.push({text:_,range:u,activate:(p,b)=>r?r.activate(p,b,u):Do(p,b),hover:(p,b)=>{var g;return(g=r==null?void 0:r.hover)==null?void 0:g.call(r,p,b,u)},leave:(p,b)=>{var g;return(g=r==null?void 0:r.leave)==null?void 0:g.call(r,p,b,u)}})}a=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=c,l=n.extended.urlId):(h=-1,l=-1)}}t(s)}};Ki=le([L(0,Le),L(1,Te),L(2,Zr)],Ki);function Do(e,t){if(confirm(`Do you want to navigate to ${t}?
33
33
 
34
- WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var gi=Ce("CharSizeService"),Qe=Ce("CoreBrowserService"),Cs=Ce("MouseService"),et=Ce("RenderService"),Bo=Ce("SelectionService"),Jr=Ce("CharacterJoinerService"),Ct=Ce("ThemeService"),Zr=Ce("LinkProviderService"),Do=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$s.isErrorNoTelemetry(e)?new $s(e.message+`
34
+ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var vi=xe("CharSizeService"),Qe=xe("CoreBrowserService"),Rs=xe("MouseService"),et=xe("RenderService"),Mo=xe("SelectionService"),Qr=xe("CharacterJoinerService"),Ct=xe("ThemeService"),en=xe("LinkProviderService"),Lo=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Us.isErrorNoTelemetry(e)?new Us(e.message+`
35
35
 
36
36
  `+e.stack):new Error(e.message+`
37
37
 
38
- `+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)}},Mo=new Do;function ii(e){Lo(e)||Mo.onUnexpectedError(e)}var Fi="Canceled";function Lo(e){return e instanceof To?!0:e instanceof Error&&e.name===Fi&&e.message===Fi}var To=class extends Error{constructor(){super(Fi),this.name=this.message}};function Po(e){return new Error(`Illegal argument: ${e}`)}var $s=class Wi extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Wi)return t;let i=new Wi;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},$i=class Qr extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Qr.prototype)}};function Ie(e,t=0){return e[e.length-(1+t)]}var Ao;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Ao||(Ao={}));function Io(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var en;(e=>{function t(L){return L&&typeof L=="object"&&typeof L[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(L){yield L}e.single=r;function n(L){return t(L)?L:r(L)}e.wrap=n;function o(L){return L||i}e.from=o;function*l(L){for(let O=L.length-1;O>=0;O--)yield L[O]}e.reverse=l;function h(L){return!L||L[Symbol.iterator]().next().done===!0}e.isEmpty=h;function a(L){return L[Symbol.iterator]().next().value}e.first=a;function d(L,O){let W=0;for(let H of L)if(O(H,W++))return!0;return!1}e.some=d;function c(L,O){for(let W of L)if(O(W))return W}e.find=c;function*_(L,O){for(let W of L)O(W)&&(yield W)}e.filter=_;function*u(L,O){let W=0;for(let H of L)yield O(H,W++)}e.map=u;function*f(L,O){let W=0;for(let H of L)yield*O(H,W++)}e.flatMap=f;function*p(...L){for(let O of L)yield*O}e.concat=p;function y(L,O,W){let H=W;for(let V of L)H=O(H,V);return H}e.reduce=y;function*v(L,O,W=L.length){for(O<0&&(O+=L.length),W<0?W+=L.length:W>L.length&&(W=L.length);O<W;O++)yield L[O]}e.slice=v;function A(L,O=Number.POSITIVE_INFINITY){let W=[];if(O===0)return[W,L];let H=L[Symbol.iterator]();for(let V=0;V<O;V++){let I=H.next();if(I.done)return[W,e.empty()];W.push(I.value)}return[W,{[Symbol.iterator](){return H}}]}e.consume=A;async function T(L){let O=[];for await(let W of L)O.push(W);return Promise.resolve(O)}e.asyncToArray=T})(en||(en={}));function pt(e){if(en.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}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 Oo(...e){return te(()=>pt(e))}function te(e){return{dispose:Io(()=>{e()})}}var tn=class sn{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{pt(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?sn.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)}};tn.DISABLE_DISPOSED_WARNING=!1;var at=tn,q=class{constructor(){this._store=new at,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)}};q.None=Object.freeze({dispose(){}});var yt=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}},Ze=typeof window=="object"?window:globalThis,Ki=class Ui{constructor(t){this.element=t,this.next=Ui.Undefined,this.prev=Ui.Undefined}};Ki.Undefined=new Ki(void 0);var se=Ki,Ks=class{constructor(){this._first=se.Undefined,this._last=se.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===se.Undefined}clear(){let e=this._first;for(;e!==se.Undefined;){let t=e.next;e.prev=se.Undefined,e.next=se.Undefined,e=t}this._first=se.Undefined,this._last=se.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new se(e);if(this._first===se.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==se.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==se.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==se.Undefined&&e.next!==se.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===se.Undefined&&e.next===se.Undefined?(this._first=se.Undefined,this._last=se.Undefined):e.next===se.Undefined?(this._last=this._last.prev,this._last.next=se.Undefined):e.prev===se.Undefined&&(this._first=this._first.next,this._first.prev=se.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==se.Undefined;)yield e.element,e=e.next}},No=globalThis.performance&&typeof globalThis.performance.now=="function",Ho=class rn{static create(t){return new rn(t)}constructor(t){this._now=No&&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}},ke;(e=>{e.None=()=>q.None;function t(C,m){return c(C,()=>{},0,void 0,!0,void 0,m)}e.defer=t;function i(C){return(m,k=null,E)=>{let R=!1,M;return M=C(x=>{if(!R)return M?M.dispose():R=!0,m.call(k,x)},null,E),R&&M.dispose(),M}}e.once=i;function s(C,m,k){return a((E,R=null,M)=>C(x=>E.call(R,m(x)),null,M),k)}e.map=s;function r(C,m,k){return a((E,R=null,M)=>C(x=>{m(x),E.call(R,x)},null,M),k)}e.forEach=r;function n(C,m,k){return a((E,R=null,M)=>C(x=>m(x)&&E.call(R,x),null,M),k)}e.filter=n;function o(C){return C}e.signal=o;function l(...C){return(m,k=null,E)=>{let R=Oo(...C.map(M=>M(x=>m.call(k,x))));return d(R,E)}}e.any=l;function h(C,m,k,E){let R=k;return s(C,M=>(R=m(R,M),R),E)}e.reduce=h;function a(C,m){let k,E={onWillAddFirstListener(){k=C(R.fire,R)},onDidRemoveLastListener(){k==null||k.dispose()}},R=new b(E);return m==null||m.add(R),R.event}function d(C,m){return m instanceof Array?m.push(C):m&&m.add(C),C}function c(C,m,k=100,E=!1,R=!1,M,x){let j,G,le,Ee=0,J,ie={leakWarningThreshold:M,onWillAddFirstListener(){j=C(ee=>{Ee++,G=m(G,ee),E&&!le&&(Z.fire(G),G=void 0),J=()=>{let Y=G;G=void 0,le=void 0,(!E||Ee>1)&&Z.fire(Y),Ee=0},typeof k=="number"?(clearTimeout(le),le=setTimeout(J,k)):le===void 0&&(le=0,queueMicrotask(J))})},onWillRemoveListener(){R&&Ee>0&&(J==null||J())},onDidRemoveLastListener(){J=void 0,j.dispose()}},Z=new b(ie);return x==null||x.add(Z),Z.event}e.debounce=c;function _(C,m=0,k){return e.debounce(C,(E,R)=>E?(E.push(R),E):[R],m,void 0,!0,void 0,k)}e.accumulate=_;function u(C,m=(E,R)=>E===R,k){let E=!0,R;return n(C,M=>{let x=E||!m(M,R);return E=!1,R=M,x},k)}e.latch=u;function f(C,m,k){return[e.filter(C,m,k),e.filter(C,E=>!m(E),k)]}e.split=f;function p(C,m=!1,k=[],E){let R=k.slice(),M=C(G=>{R?R.push(G):j.fire(G)});E&&E.add(M);let x=()=>{R==null||R.forEach(G=>j.fire(G)),R=null},j=new b({onWillAddFirstListener(){M||(M=C(G=>j.fire(G)),E&&E.add(M))},onDidAddFirstListener(){R&&(m?setTimeout(x):x())},onDidRemoveLastListener(){M&&M.dispose(),M=null}});return E&&E.add(j),j.event}e.buffer=p;function y(C,m){return(k,E,R)=>{let M=m(new A);return C(function(x){let j=M.evaluate(x);j!==v&&k.call(E,j)},void 0,R)}}e.chain=y;let v=Symbol("HaltChainable");class A{constructor(){this.steps=[]}map(m){return this.steps.push(m),this}forEach(m){return this.steps.push(k=>(m(k),k)),this}filter(m){return this.steps.push(k=>m(k)?k:v),this}reduce(m,k){let E=k;return this.steps.push(R=>(E=m(E,R),E)),this}latch(m=(k,E)=>k===E){let k=!0,E;return this.steps.push(R=>{let M=k||!m(R,E);return k=!1,E=R,M?R:v}),this}evaluate(m){for(let k of this.steps)if(m=k(m),m===v)break;return m}}function T(C,m,k=E=>E){let E=(...j)=>x.fire(k(...j)),R=()=>C.on(m,E),M=()=>C.removeListener(m,E),x=new b({onWillAddFirstListener:R,onDidRemoveLastListener:M});return x.event}e.fromNodeEventEmitter=T;function L(C,m,k=E=>E){let E=(...j)=>x.fire(k(...j)),R=()=>C.addEventListener(m,E),M=()=>C.removeEventListener(m,E),x=new b({onWillAddFirstListener:R,onDidRemoveLastListener:M});return x.event}e.fromDOMEventEmitter=L;function O(C){return new Promise(m=>i(C)(m))}e.toPromise=O;function W(C){let m=new b;return C.then(k=>{m.fire(k)},()=>{m.fire(void 0)}).finally(()=>{m.dispose()}),m.event}e.fromPromise=W;function H(C,m){return C(k=>m.fire(k))}e.forward=H;function V(C,m,k){return m(k),C(E=>m(E))}e.runAndSubscribe=V;class I{constructor(m,k){this._observable=m,this._counter=0,this._hasChanged=!1;let E={onWillAddFirstListener:()=>{m.addObserver(this)},onDidRemoveLastListener:()=>{m.removeObserver(this)}};this.emitter=new b(E),k&&k.add(this.emitter)}beginUpdate(m){this._counter++}handlePossibleChange(m){}handleChange(m,k){this._hasChanged=!0}endUpdate(m){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function $(C,m){return new I(C,m).emitter.event}e.fromObservable=$;function F(C){return(m,k,E)=>{let R=0,M=!1,x={beginUpdate(){R++},endUpdate(){R--,R===0&&(C.reportChanges(),M&&(M=!1,m.call(k)))},handlePossibleChange(){},handleChange(){M=!0}};C.addObserver(x),C.reportChanges();let j={dispose(){C.removeObserver(x)}};return E instanceof at?E.add(j):Array.isArray(E)&&E.push(j),j}}e.fromObservableLight=F})(ke||(ke={}));var qi=class ji{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${ji._idPool++}`,ji.all.add(this)}start(t){this._stopWatch=new Ho,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}}};qi.all=new Set,qi._idPool=0;var zo=qi,Fo=-1,nn=class on{constructor(t,i,s=(on._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(n);let h=new Ko(l,n);this._errorHandler(h)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};nn._idPool=1;var Wo=nn,$o=class an{constructor(t){this.value=t}static create(){let t=new Error;return new an(t.stack??"")}print(){console.warn(this.value.split(`
38
+ `+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)}},To=new Lo;function ri(e){Po(e)||To.onUnexpectedError(e)}var Ui="Canceled";function Po(e){return e instanceof Ao?!0:e instanceof Error&&e.name===Ui&&e.message===Ui}var Ao=class extends Error{constructor(){super(Ui),this.name=this.message}};function Io(e){return new Error(`Illegal argument: ${e}`)}var Us=class qi extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof qi)return t;let i=new qi;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},ji=class tn extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,tn.prototype)}};function Oe(e,t=0){return e[e.length-(1+t)]}var Oo;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Oo||(Oo={}));function No(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var sn;(e=>{function t(P){return P&&typeof P=="object"&&typeof P[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(P){yield P}e.single=r;function n(P){return t(P)?P:r(P)}e.wrap=n;function o(P){return P||i}e.from=o;function*l(P){for(let A=P.length-1;A>=0;A--)yield P[A]}e.reverse=l;function h(P){return!P||P[Symbol.iterator]().next().done===!0}e.isEmpty=h;function a(P){return P[Symbol.iterator]().next().value}e.first=a;function d(P,A){let I=0;for(let N of P)if(A(N,I++))return!0;return!1}e.some=d;function c(P,A){for(let I of P)if(A(I))return I}e.find=c;function*_(P,A){for(let I of P)A(I)&&(yield I)}e.filter=_;function*u(P,A){let I=0;for(let N of P)yield A(N,I++)}e.map=u;function*f(P,A){let I=0;for(let N of P)yield*A(N,I++)}e.flatMap=f;function*p(...P){for(let A of P)yield*A}e.concat=p;function b(P,A,I){let N=I;for(let $ of P)N=A(N,$);return N}e.reduce=b;function*g(P,A,I=P.length){for(A<0&&(A+=P.length),I<0?I+=P.length:I>P.length&&(I=P.length);A<I;A++)yield P[A]}e.slice=g;function T(P,A=Number.POSITIVE_INFINITY){let I=[];if(A===0)return[I,P];let N=P[Symbol.iterator]();for(let $=0;$<A;$++){let V=N.next();if(V.done)return[I,e.empty()];I.push(V.value)}return[I,{[Symbol.iterator](){return N}}]}e.consume=T;async function D(P){let A=[];for await(let I of P)A.push(I);return Promise.resolve(A)}e.asyncToArray=D})(sn||(sn={}));function gt(e){if(sn.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}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 Ho(...e){return ee(()=>gt(e))}function ee(e){return{dispose:No(()=>{e()})}}var rn=class nn{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{gt(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?nn.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)}};rn.DISABLE_DISPOSED_WARNING=!1;var at=rn,U=class{constructor(){this._store=new at,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)}};U.None=Object.freeze({dispose(){}});var yt=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}},Ze=typeof window=="object"?window:globalThis,Vi=class Yi{constructor(t){this.element=t,this.next=Yi.Undefined,this.prev=Yi.Undefined}};Vi.Undefined=new Vi(void 0);var se=Vi,qs=class{constructor(){this._first=se.Undefined,this._last=se.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===se.Undefined}clear(){let e=this._first;for(;e!==se.Undefined;){let t=e.next;e.prev=se.Undefined,e.next=se.Undefined,e=t}this._first=se.Undefined,this._last=se.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new se(e);if(this._first===se.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==se.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==se.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==se.Undefined&&e.next!==se.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===se.Undefined&&e.next===se.Undefined?(this._first=se.Undefined,this._last=se.Undefined):e.next===se.Undefined?(this._last=this._last.prev,this._last.next=se.Undefined):e.prev===se.Undefined&&(this._first=this._first.next,this._first.prev=se.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==se.Undefined;)yield e.element,e=e.next}},zo=globalThis.performance&&typeof globalThis.performance.now=="function",Fo=class on{static create(t){return new on(t)}constructor(t){this._now=zo&&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}},Ee;(e=>{e.None=()=>U.None;function t(B,y){return c(B,()=>{},0,void 0,!0,void 0,y)}e.defer=t;function i(B){return(y,v=null,S)=>{let k=!1,E;return E=B(x=>{if(!k)return E?E.dispose():k=!0,y.call(v,x)},null,S),k&&E.dispose(),E}}e.once=i;function s(B,y,v){return a((S,k=null,E)=>B(x=>S.call(k,y(x)),null,E),v)}e.map=s;function r(B,y,v){return a((S,k=null,E)=>B(x=>{y(x),S.call(k,x)},null,E),v)}e.forEach=r;function n(B,y,v){return a((S,k=null,E)=>B(x=>y(x)&&S.call(k,x),null,E),v)}e.filter=n;function o(B){return B}e.signal=o;function l(...B){return(y,v=null,S)=>{let k=Ho(...B.map(E=>E(x=>y.call(v,x))));return d(k,S)}}e.any=l;function h(B,y,v,S){let k=v;return s(B,E=>(k=y(k,E),k),S)}e.reduce=h;function a(B,y){let v,S={onWillAddFirstListener(){v=B(k.fire,k)},onDidRemoveLastListener(){v==null||v.dispose()}},k=new R(S);return y==null||y.add(k),k.event}function d(B,y){return y instanceof Array?y.push(B):y&&y.add(B),B}function c(B,y,v=100,S=!1,k=!1,E,x){let H,Y,te,Re=0,G,ie={leakWarningThreshold:E,onWillAddFirstListener(){H=B(Q=>{Re++,Y=y(Y,Q),S&&!te&&(J.fire(Y),Y=void 0),G=()=>{let j=Y;Y=void 0,te=void 0,(!S||Re>1)&&J.fire(j),Re=0},typeof v=="number"?(clearTimeout(te),te=setTimeout(G,v)):te===void 0&&(te=0,queueMicrotask(G))})},onWillRemoveListener(){k&&Re>0&&(G==null||G())},onDidRemoveLastListener(){G=void 0,H.dispose()}},J=new R(ie);return x==null||x.add(J),J.event}e.debounce=c;function _(B,y=0,v){return e.debounce(B,(S,k)=>S?(S.push(k),S):[k],y,void 0,!0,void 0,v)}e.accumulate=_;function u(B,y=(S,k)=>S===k,v){let S=!0,k;return n(B,E=>{let x=S||!y(E,k);return S=!1,k=E,x},v)}e.latch=u;function f(B,y,v){return[e.filter(B,y,v),e.filter(B,S=>!y(S),v)]}e.split=f;function p(B,y=!1,v=[],S){let k=v.slice(),E=B(Y=>{k?k.push(Y):H.fire(Y)});S&&S.add(E);let x=()=>{k==null||k.forEach(Y=>H.fire(Y)),k=null},H=new R({onWillAddFirstListener(){E||(E=B(Y=>H.fire(Y)),S&&S.add(E))},onDidAddFirstListener(){k&&(y?setTimeout(x):x())},onDidRemoveLastListener(){E&&E.dispose(),E=null}});return S&&S.add(H),H.event}e.buffer=p;function b(B,y){return(v,S,k)=>{let E=y(new T);return B(function(x){let H=E.evaluate(x);H!==g&&v.call(S,H)},void 0,k)}}e.chain=b;let g=Symbol("HaltChainable");class T{constructor(){this.steps=[]}map(y){return this.steps.push(y),this}forEach(y){return this.steps.push(v=>(y(v),v)),this}filter(y){return this.steps.push(v=>y(v)?v:g),this}reduce(y,v){let S=v;return this.steps.push(k=>(S=y(S,k),S)),this}latch(y=(v,S)=>v===S){let v=!0,S;return this.steps.push(k=>{let E=v||!y(k,S);return v=!1,S=k,E?k:g}),this}evaluate(y){for(let v of this.steps)if(y=v(y),y===g)break;return y}}function D(B,y,v=S=>S){let S=(...H)=>x.fire(v(...H)),k=()=>B.on(y,S),E=()=>B.removeListener(y,S),x=new R({onWillAddFirstListener:k,onDidRemoveLastListener:E});return x.event}e.fromNodeEventEmitter=D;function P(B,y,v=S=>S){let S=(...H)=>x.fire(v(...H)),k=()=>B.addEventListener(y,S),E=()=>B.removeEventListener(y,S),x=new R({onWillAddFirstListener:k,onDidRemoveLastListener:E});return x.event}e.fromDOMEventEmitter=P;function A(B){return new Promise(y=>i(B)(y))}e.toPromise=A;function I(B){let y=new R;return B.then(v=>{y.fire(v)},()=>{y.fire(void 0)}).finally(()=>{y.dispose()}),y.event}e.fromPromise=I;function N(B,y){return B(v=>y.fire(v))}e.forward=N;function $(B,y,v){return y(v),B(S=>y(S))}e.runAndSubscribe=$;class V{constructor(y,v){this._observable=y,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{y.addObserver(this)},onDidRemoveLastListener:()=>{y.removeObserver(this)}};this.emitter=new R(S),v&&v.add(this.emitter)}beginUpdate(y){this._counter++}handlePossibleChange(y){}handleChange(y,v){this._hasChanged=!0}endUpdate(y){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ne(B,y){return new V(B,y).emitter.event}e.fromObservable=ne;function W(B){return(y,v,S)=>{let k=0,E=!1,x={beginUpdate(){k++},endUpdate(){k--,k===0&&(B.reportChanges(),E&&(E=!1,y.call(v)))},handlePossibleChange(){},handleChange(){E=!0}};B.addObserver(x),B.reportChanges();let H={dispose(){B.removeObserver(x)}};return S instanceof at?S.add(H):Array.isArray(S)&&S.push(H),H}}e.fromObservableLight=W})(Ee||(Ee={}));var Xi=class Gi{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Gi._idPool++}`,Gi.all.add(this)}start(t){this._stopWatch=new Fo,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}}};Xi.all=new Set,Xi._idPool=0;var Wo=Xi,$o=-1,an=class ln{constructor(t,i,s=(ln._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(n);let h=new qo(l,n);this._errorHandler(h)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};an._idPool=1;var Ko=an,Uo=class hn{constructor(t){this.value=t}static create(){let t=new Error;return new hn(t.stack??"")}print(){console.warn(this.value.split(`
39
39
  `).slice(2).join(`
40
- `))}},Ko=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Uo=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},qo=0,Ci=class{constructor(e){this.value=e,this.id=qo++}},jo=2,Vo,b=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Wo((e==null?void 0:e.onListenerError)??ii,((i=this._options)==null?void 0:i.leakWarningThreshold)??Fo):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new zo(this._options._profName):void 0,this._deliveryQueue=(r=this._options)==null?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var o,l,h,a,d;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let c=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(c);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],u=new Uo(`${c}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((o=this._options)==null?void 0:o.onListenerError)||ii)(u),q.None}if(this._disposed)return q.None;t&&(e=e.bind(t));let s=new Ci(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=$o.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Ci?(this._deliveryQueue??(this._deliveryQueue=new Yo),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||h.call(l,this),this._listeners=s,(d=(a=this._options)==null?void 0:a.onDidAddFirstListener)==null||d.call(a,this)),this._size++;let n=te(()=>{r==null||r(),this._removeListener(s)});return i instanceof at?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,l;if((n=(r=this._options)==null?void 0:r.onWillRemoveListener)==null||n.call(r,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||l.call(o,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);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--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*jo<=t.length){let h=0;for(let a=0;a<t.length;a++)t[a]?t[h++]=t[a]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=h}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||ii;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Ci)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(r=this._perfMon)==null||r.stop()}hasListeners(){return this._size>0}},Yo=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vi=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new b,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new b,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Vi.INSTANCE=new Vi;var xs=Vi;function Xo(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}xs.INSTANCE.onDidChangeZoomLevel;function Go(e){return xs.INSTANCE.getZoomFactor(e)}xs.INSTANCE.onDidChangeFullscreen;var xt=typeof navigator=="object"?navigator.userAgent:"",Yi=xt.indexOf("Firefox")>=0,Jo=xt.indexOf("AppleWebKit")>=0,ks=xt.indexOf("Chrome")>=0,Zo=!ks&&xt.indexOf("Safari")>=0;xt.indexOf("Electron/")>=0;xt.indexOf("Android")>=0;var xi=!1;if(typeof Ze.matchMedia=="function"){let e=Ze.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Ze.matchMedia("(display-mode: fullscreen)");xi=e.matches,Xo(Ze,e,({matches:i})=>{xi&&t.matches||(xi=i)})}var bt="en",Xi=!1,Gi=!1,si=!1,ln=!1,Gt,ri=bt,Us=bt,Qo,Ke,ft=globalThis,xe,Nr;typeof ft.vscode<"u"&&typeof ft.vscode.process<"u"?xe=ft.vscode.process:typeof process<"u"&&typeof((Nr=process==null?void 0:process.versions)==null?void 0:Nr.node)=="string"&&(xe=process);var Hr,ea=typeof((Hr=xe==null?void 0:xe.versions)==null?void 0:Hr.electron)=="string",ta=ea&&(xe==null?void 0:xe.type)==="renderer",zr;if(typeof xe=="object"){Xi=xe.platform==="win32",Gi=xe.platform==="darwin",si=xe.platform==="linux",si&&xe.env.SNAP&&xe.env.SNAP_REVISION,xe.env.CI||xe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Gt=bt,ri=bt;let e=xe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Gt=t.userLocale,Us=t.osLocale,ri=t.resolvedLanguage||bt,Qo=(zr=t.languagePack)==null?void 0:zr.translationsConfigFile}catch{}ln=!0}else typeof navigator=="object"&&!ta?(Ke=navigator.userAgent,Xi=Ke.indexOf("Windows")>=0,Gi=Ke.indexOf("Macintosh")>=0,(Ke.indexOf("Macintosh")>=0||Ke.indexOf("iPad")>=0||Ke.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,si=Ke.indexOf("Linux")>=0,(Ke==null?void 0:Ke.indexOf("Mobi"))>=0,ri=globalThis._VSCODE_NLS_LANGUAGE||bt,Gt=navigator.language.toLowerCase(),Us=Gt):console.error("Unable to resolve platform.");var hn=Xi,Xe=Gi,ia=si,qs=ln,Ge=Ke,it=ri,sa;(e=>{function t(){return it}e.value=t;function i(){return it.length===2?it==="en":it.length>=3?it[0]==="e"&&it[1]==="n"&&it[2]==="-":!1}e.isDefaultVariant=i;function s(){return it==="en"}e.isDefault=s})(sa||(sa={}));var ra=typeof ft.postMessage=="function"&&!ft.importScripts;(()=>{if(ra){let e=[];ft.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),ft.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var na=!!(Ge&&Ge.indexOf("Chrome")>=0);Ge&&Ge.indexOf("Firefox")>=0;!na&&Ge&&Ge.indexOf("Safari")>=0;Ge&&Ge.indexOf("Edg/")>=0;Ge&&Ge.indexOf("Android")>=0;var St=typeof navigator=="object"?navigator:{};qs||document.queryCommandSupported&&document.queryCommandSupported("copy")||St&&St.clipboard&&St.clipboard.writeText,qs||St&&St.clipboard&&St.clipboard.readText;var Es=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}},ki=new Es,js=new Es,Vs=new Es,oa=new Array(230),cn;(e=>{function t(l){return ki.keyCodeToStr(l)}e.toString=t;function i(l){return ki.strToKeyCode(l)}e.fromString=i;function s(l){return js.keyCodeToStr(l)}e.toUserSettingsUS=s;function r(l){return Vs.keyCodeToStr(l)}e.toUserSettingsGeneral=r;function n(l){return js.strToKeyCode(l)||Vs.strToKeyCode(l)}e.fromUserSettings=n;function o(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 ki.keyCodeToStr(l)}e.toElectronAccelerator=o})(cn||(cn={}));var aa=class dn{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof dn&&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",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new la([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},la=class{constructor(e){if(e.length===0)throw Po("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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 ha(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return cn.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Yi)switch(t){case 59:return 85;case 60:if(ia)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Xe)return 57;break}else if(Jo&&(Xe&&t===93||!Xe&&t===92))return 57;return oa[t]||0}var ca=Xe?256:2048,da=512,ua=1024,_a=Xe?2048:256,Ys=class{constructor(e){var i;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=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=ha(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|=ca),this.altKey&&(t|=da),this.shiftKey&&(t|=ua),this.metaKey&&(t|=_a),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new aa(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Xs=new WeakMap;function fa(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var pa=class{static getSameOriginWindowChain(e){let t=Xs.get(e);if(!t){t=[],Xs.set(e,t);let i=e,s;do s=fa(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let l=n.iframeElement.getBoundingClientRect();i+=l.top,s+=l.left}return{top:i,left:s}}},Jt=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 i=pa.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Gs=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(ks){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,l=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*l):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Yi&&!Xe?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Zo&&hn?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*l):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Yi&&!Xe?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?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()}},un=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),ga;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof ma?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ke.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:un})})(ga||(ga={}));var ma=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?un:(this._emitter||(this._emitter=new b),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Rs=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 $i("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new $i("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},va=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,i=globalThis){if(this.isDisposed)throw new $i("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=te(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Sa;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(Sa||(Sa={}));var Js=class ze{static fromArray(t){return new ze(i=>{i.emitMany(t)})}static fromPromise(t){return new ze(async i=>{i.emitMany(await t)})}static fromPromises(t){return new ze(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new ze(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new b,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.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 ke.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new ze(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return ze.map(this,t)}static filter(t,i){return new ze(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return ze.filter(this,t)}static coalesce(t){return ze.filter(t,i=>!!i)}coalesce(){return ze.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return ze.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())}};Js.EMPTY=Js.fromArray([]);var{getWindow:Ye,getWindowId:wa,onDidRegisterWindow:ba}=(function(){let e=new Map,t={window:Ze,disposables:new at};e.set(Ze.vscodeWindowId,t);let i=new b,s=new b,r=new b;function n(o,l){return(typeof o=="number"?e.get(o):void 0)??(l?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return q.None;let l=new at,h={window:o,disposables:l.add(new at)};return e.set(o.vscodeWindowId,h),l.add(te(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),l.add(z(o,Se.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var a;let l=o;if((a=l==null?void 0:l.ownerDocument)!=null&&a.defaultView)return l.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:Ze},getDocument(o){return Ye(o).document}}})(),ya=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!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 z(e,t,i,s){return new ya(e,t,i,s)}var Zs=function(e,t,i,s){return z(e,t,i,s)},Bs,Ca=class extends va{constructor(e){super(),this.defaultTarget=e&&Ye(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Qs=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){ii(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(Qs.sort),o.shift().execute();s.set(n,!1)};Bs=(n,o,l=0)=>{let h=wa(n),a=new Qs(o,l),d=e.get(h);return d||(d=[],e.set(h,d)),d.push(a),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),a}})();function xa(e){let t=e.getBoundingClientRect(),i=Ye(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Se={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"},ka=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=Pe(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Pe(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Pe(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Pe(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Pe(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Pe(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Pe(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Pe(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Pe(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Pe(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Pe(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=Pe(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=Pe(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Pe(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 Pe(e){return typeof e=="number"?`${e}px`:e}function Wt(e){return new ka(e)}var _n=class{constructor(){this._hooks=new at,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(te(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=Ye(e)}this._hooks.add(z(n,Se.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(z(n,Se.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Ea(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var je;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(je||(je={}));var Ot=class Re extends q{constructor(){super(),this.dispatched=!1,this.targets=new Ks,this.ignoreTargets=new Ks,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ke.runAndSubscribe(ba,({window:t,disposables:i})=>{i.add(z(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(z(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(z(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Ze,disposables:this._store}))}static addTarget(t){if(!Re.isTouchDevice())return q.None;Re.INSTANCE||(Re.INSTANCE=new Re);let i=Re.INSTANCE.targets.push(t);return te(i)}static ignoreTarget(t){if(!Re.isTouchDevice())return q.None;Re.INSTANCE||(Re.INSTANCE=new Re);let i=Re.INSTANCE.ignoreTargets.push(t);return te(i)}static isTouchDevice(){return"ontouchstart"in Ze||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(je.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let l=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],a=Date.now()-h.initialTimeStamp;if(a<Re.HOLD_DELAY&&Math.abs(h.initialPageX-Ie(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ie(h.rollingPageY))<30){let d=this.newGestureEvent(je.Tap,h.initialTarget);d.pageX=Ie(h.rollingPageX),d.pageY=Ie(h.rollingPageY),this.dispatchEvent(d)}else if(a>=Re.HOLD_DELAY&&Math.abs(h.initialPageX-Ie(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ie(h.rollingPageY))<30){let d=this.newGestureEvent(je.Contextmenu,h.initialTarget);d.pageX=Ie(h.rollingPageX),d.pageY=Ie(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=Ie(h.rollingPageX),c=Ie(h.rollingPageY),_=Ie(h.rollingTimestamps)-h.rollingTimestamps[0],u=d-h.rollingPageX[0],f=c-h.rollingPageY[0],p=[...this.targets].filter(y=>h.initialTarget instanceof Node&&y.contains(h.initialTarget));this.inertia(t,p,s,Math.abs(u)/_,u>0?1:-1,d,Math.abs(f)/_,f>0?1:-1,c)}this.dispatchEvent(this.newGestureEvent(je.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===je.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Re.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===je.Change||t.type===je.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,l,h,a){this.handle=Bs(t,()=>{let d=Date.now(),c=d-s,_=0,u=0,f=!0;r+=Re.SCROLL_FRICTION*c,l+=Re.SCROLL_FRICTION*c,r>0&&(f=!1,_=n*r*c),l>0&&(f=!1,u=h*l*c);let p=this.newGestureEvent(je.Change);p.translationX=_,p.translationY=u,i.forEach(y=>y.dispatchEvent(p)),f||this.inertia(t,i,d,r,n,o+_,l,h,a+u)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],l=this.newGestureEvent(je.Change,o.initialTarget);l.translationX=n.pageX-Ie(o.rollingPageX),l.translationY=n.pageY-Ie(o.rollingPageY),l.pageX=n.pageX,l.pageY=n.pageY,this.dispatchEvent(l),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ot.SCROLL_FRICTION=-.005,Ot.HOLD_DELAY=700,Ot.CLEAR_TAP_COUNT_TIME=400,ae([Ea],Ot,"isTouchDevice",1);var Ra=Ot,Ds=class extends q{onclick(e,t){this._register(z(e,Se.CLICK,i=>t(new Jt(Ye(e),i))))}onmousedown(e,t){this._register(z(e,Se.MOUSE_DOWN,i=>t(new Jt(Ye(e),i))))}onmouseover(e,t){this._register(z(e,Se.MOUSE_OVER,i=>t(new Jt(Ye(e),i))))}onmouseleave(e,t){this._register(z(e,Se.MOUSE_LEAVE,i=>t(new Jt(Ye(e),i))))}onkeydown(e,t){this._register(z(e,Se.KEY_DOWN,i=>t(new Ys(i))))}onkeyup(e,t){this._register(z(e,Se.KEY_UP,i=>t(new Ys(i))))}oninput(e,t){this._register(z(e,Se.INPUT,t))}onblur(e,t){this._register(z(e,Se.BLUR,t))}onfocus(e,t){this._register(z(e,Se.FOCUS,t))}onchange(e,t){this._register(z(e,Se.CHANGE,t))}ignoreGesture(e){return Ra.ignoreTarget(e)}},er=11,Ba=class extends Ds{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=er+"px",this.domNode.style.height=er+"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 _n),this._register(Zs(this.bgDomNode,Se.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Zs(this.domNode,Se.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Ca),this._pointerdownScheduleRepeatTimer=this._register(new Rs)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ye(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Da=class Ji{constructor(t,i,s,r,n,o,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),l+n>o&&(l=o-n),l<0&&(l=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,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,i){return new Ji(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ji(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,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:h}}},Ma=class extends q{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new b),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Da(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 s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new ir(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=ir.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},tr=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Ei(e,t){let i=t-e;return function(s){return e+i*Pa(s)}}function La(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var ir=class Zi{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,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,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),La(Ei(t,r),Ei(n,i),.33)}return Ei(t,i)}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 i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new tr(s,r,!1)}return new tr(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Zi.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new Zi(t,i,r,s)}};function Ta(e){return Math.pow(e,3)}function Pa(e){return 1-Ta(1-e)}var Aa=class extends q{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Rs)}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":"")))}},Ia=140,fn=class extends Ds{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 Aa(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new _n),this._shouldRender=!0,this.domNode=Wt(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(z(this.domNode.domNode,Se.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Ba(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Wt(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(z(this.slider.domNode,Se.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.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,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=xa(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(hn&&o>Ia){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let l=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.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()}},pn=class Qi{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Qi(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),l=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let a=Math.round(Math.max(20,Math.floor(s*l/r))),d=(l-a)/(r-s),c=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:d,computedSliderPosition:Math.round(c)}}_refreshComputedValues(){let t=Qi._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 i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Oa=class extends fn{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new pn(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.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}},Na=class extends fn{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new pn(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.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}},Ha=500,sr=50,za=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},es=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,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(ks){let i=Ye(t.browserEvent),s=Go(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new za(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=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]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),l=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),a=Math.max(Math.min(n,l),1),d=Math.max(r,o),c=Math.max(n,l);d%h===0&&c%a===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};es.INSTANCE=new es;var Fa=es,Wa=class extends Ds{constructor(e,t,i){super(),this._onScroll=this._register(new b),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new b),this.onWillScroll=this._onWillScroll.event,this._options=Ka(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Na(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Oa(this._scrollable,this._options,s)),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=Wt(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Wt(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Wt(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,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Rs),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=pt(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,Xe&&(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 Gs(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=pt(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Gs(i))};this._mouseWheelToDispose.push(z(this._listenOnDomNode,Se.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=Fa.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let l=!Xe&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),a={};if(n){let d=sr*n,c=h.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(a,c)}if(o){let d=sr*o,c=h.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(a,c)}a=this._scrollable.validateScrollPosition(a),(h.scrollLeft!==a.scrollLeft||h.scrollTop!==a.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(a):this._scrollable.setScrollPositionNow(a),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(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,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_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(),Ha)}},$a=class extends Wa{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Ka(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,Xe&&(t.className+=" mac"),t}var ts=class extends q{constructor(e,t,i,s,r,n,o,l){super(),this._bufferService=i,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new b),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Ma({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:a=>Bs(s.window,a)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new $a(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(r.onProtocolChange(a=>{this._scrollableElement.updateOptions({handleMouseWheel:!(a&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ke.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(te(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(te(()=>this._styleElement.remove())),this._register(ke.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
41
- `)})),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(a=>this._handleScroll(a)))}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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};ts=ae([D(2,Me),D(3,Qe),D(4,Yr),D(5,Ct),D(6,Le),D(7,et)],ts);var is=class extends q{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,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(n=>this._removeDecoration(n))),this._register(te(()=>{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 s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*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()}};is=ae([D(1,Me),D(2,Qe),D(3,jt),D(4,et)],is);var Ua=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ue={full:0,left:0,center:0,right:0},st={full:0,left:0,center:0,right:0},Mt={full:0,left:0,center:0,right:0},hi=class extends q{constructor(e,t,i,s,r,n,o,l){var a;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new Ua,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(),(a=this._viewportElement.parentElement)==null||a.insertBefore(this._canvas,this._viewportElement),this._register(te(()=>{var d;return(d=this._canvas)==null?void 0:d.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);st.full=this._canvas.width,st.left=e,st.center=t,st.right=e,this._refreshDrawHeightConstants(),Mt.full=1,Mt.left=1,Mt.center=1+st.left,Mt.right=1+st.left+st.center}_refreshDrawHeightConstants(){Ue.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);Ue.left=t,Ue.center=t,Ue.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ue.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ue.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ue.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ue.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(Mt[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ue[e.position||"full"]/2),st[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ue[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}))}};hi=ae([D(2,Me),D(3,jt),D(4,et),D(5,Le),D(6,Ct),D(7,Qe)],hi);var S;(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=`
42
- `,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=""))(S||(S={}));var ni;(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="Ÿ"))(ni||(ni={}));var gn;(e=>e.ST=`${S.ESC}\\`)(gn||(gn={}));var ss=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${S.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),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};ss=ae([D(2,Me),D(3,Le),D(4,mt),D(5,et)],ss);var we=0,be=0,ye=0,oe=0,rr={css:"#00000000",rgba:0},ue;(e=>{function t(r,n,o,l){return l!==void 0?`#${ht(r)}${ht(n)}${ht(o)}${ht(l)}`:`#${ht(r)}${ht(n)}${ht(o)}`}e.toCss=t;function i(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}e.toRgba=i;function s(r,n,o,l){return{css:e.toCss(r,n,o,l),rgba:e.toRgba(r,n,o,l)}}e.toColor=s})(ue||(ue={}));var Q;(e=>{function t(h,a){if(oe=(a.rgba&255)/255,oe===1)return{css:a.css,rgba:a.rgba};let d=a.rgba>>24&255,c=a.rgba>>16&255,_=a.rgba>>8&255,u=h.rgba>>24&255,f=h.rgba>>16&255,p=h.rgba>>8&255;we=u+Math.round((d-u)*oe),be=f+Math.round((c-f)*oe),ye=p+Math.round((_-p)*oe);let y=ue.toCss(we,be,ye),v=ue.toRgba(we,be,ye);return{css:y,rgba:v}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,a,d){let c=oi.ensureContrastRatio(h.rgba,a.rgba,d);if(c)return ue.toColor(c>>24&255,c>>16&255,c>>8&255)}e.ensureContrastRatio=s;function r(h){let a=(h.rgba|255)>>>0;return[we,be,ye]=oi.toChannels(a),{css:ue.toCss(we,be,ye),rgba:a}}e.opaque=r;function n(h,a){return oe=Math.round(a*255),[we,be,ye]=oi.toChannels(h.rgba),{css:ue.toCss(we,be,ye,oe),rgba:ue.toRgba(we,be,ye,oe)}}e.opacity=n;function o(h,a){return oe=h.rgba&255,n(h,oe*a/255)}e.multiplyOpacity=o;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(Q||(Q={}));var re;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return we=parseInt(r.slice(1,2).repeat(2),16),be=parseInt(r.slice(2,3).repeat(2),16),ye=parseInt(r.slice(3,4).repeat(2),16),ue.toColor(we,be,ye);case 5:return we=parseInt(r.slice(1,2).repeat(2),16),be=parseInt(r.slice(2,3).repeat(2),16),ye=parseInt(r.slice(3,4).repeat(2),16),oe=parseInt(r.slice(4,5).repeat(2),16),ue.toColor(we,be,ye,oe);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return we=parseInt(n[1]),be=parseInt(n[2]),ye=parseInt(n[3]),oe=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ue.toColor(we,be,ye,oe);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[we,be,ye,oe]=t.getImageData(0,0,1,1).data,oe!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ue.toRgba(we,be,ye,oe),css:r}}e.toColor=s})(re||(re={}));var De;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,l=r/255,h=n/255,a=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),c=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return a*.2126+d*.7152+c*.0722}e.relativeLuminance2=i})(De||(De={}));var oi;(e=>{function t(o,l){if(oe=(l&255)/255,oe===1)return l;let h=l>>24&255,a=l>>16&255,d=l>>8&255,c=o>>24&255,_=o>>16&255,u=o>>8&255;return we=c+Math.round((h-c)*oe),be=_+Math.round((a-_)*oe),ye=u+Math.round((d-u)*oe),ue.toRgba(we,be,ye)}e.blend=t;function i(o,l,h){let a=De.relativeLuminance(o>>8),d=De.relativeLuminance(l>>8);if(Je(a,d)<h){if(d<a){let u=s(o,l,h),f=Je(a,De.relativeLuminance(u>>8));if(f<h){let p=r(o,l,h),y=Je(a,De.relativeLuminance(p>>8));return f>y?u:p}return u}let c=r(o,l,h),_=Je(a,De.relativeLuminance(c>>8));if(_<h){let u=s(o,l,h),f=Je(a,De.relativeLuminance(u>>8));return _>f?c:u}return c}}e.ensureContrastRatio=i;function s(o,l,h){let a=o>>24&255,d=o>>16&255,c=o>>8&255,_=l>>24&255,u=l>>16&255,f=l>>8&255,p=Je(De.relativeLuminance2(_,u,f),De.relativeLuminance2(a,d,c));for(;p<h&&(_>0||u>0||f>0);)_-=Math.max(0,Math.ceil(_*.1)),u-=Math.max(0,Math.ceil(u*.1)),f-=Math.max(0,Math.ceil(f*.1)),p=Je(De.relativeLuminance2(_,u,f),De.relativeLuminance2(a,d,c));return(_<<24|u<<16|f<<8|255)>>>0}e.reduceLuminance=s;function r(o,l,h){let a=o>>24&255,d=o>>16&255,c=o>>8&255,_=l>>24&255,u=l>>16&255,f=l>>8&255,p=Je(De.relativeLuminance2(_,u,f),De.relativeLuminance2(a,d,c));for(;p<h&&(_<255||u<255||f<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),u=Math.min(255,u+Math.ceil((255-u)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Je(De.relativeLuminance2(_,u,f),De.relativeLuminance2(a,d,c));return(_<<24|u<<16|f<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(oi||(oi={}));function ht(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Je(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var qa=class extends qt{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}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()]}},ci=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new We}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 i=[],s=t.translateToString(!0),r=0,n=0,o=0,l=t.getFg(0),h=t.getBg(0);for(let a=0;a<t.getTrimmedLength();a++)if(t.loadCell(a,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(a-r>1){let d=this._getJoinedRanges(s,o,n,t,r);for(let c=0;c<d.length;c++)i.push(d[c])}r=a,o=n,l=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||ot.length}if(this._bufferService.cols-r>1){let a=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<a.length;d++)i.push(a[d])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(n);for(let a=0;a<h.length;a++)ci._mergeRanges(o,h[a])}catch(h){console.error(h)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let l=i;l<this._bufferService.cols;l++){let h=t.getWidth(l),a=t.getString(l).length||ot.length;if(h!==0){if(!r&&o[0]<=n&&(o[0]=l,r=!0),o[1]<=n){if(o[1]=l,o=e[++s],!o)break;o[0]<=n?(o[0]=l,r=!0):r=!1}n+=a}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};ci=ae([D(0,Me)],ci);function ja(e){return 57508<=e&&e<=57558}function Va(e){return 9472<=e&&e<=9631}function Ya(e){return ja(e)||Va(e)}function Xa(){return{css:{canvas:Zt(),cell:Zt()},device:{canvas:Zt(),cell:Zt(),char:{width:0,height:0,left:0,top:0}}}}function Zt(){return{width:0,height:0}}var rs=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new We,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,l,h,a,d){let c=[],_=this._characterJoinerService.getJoinedCharacters(t),u=this._themeService.colors,f=e.getNoBgTrimmedLength();i&&f<n+1&&(f=n+1);let p,y=0,v="",A=0,T=0,L=0,O=0,W=!1,H=0,V=!1,I=0,$=0,F=[],C=a!==-1&&d!==-1;for(let m=0;m<f;m++){e.loadCell(m,this._workCell);let k=this._workCell.getWidth();if(k===0)continue;let E=!1,R=m>=$,M=m,x=this._workCell;if(_.length>0&&m===_[0][0]&&R){let K=_.shift(),vt=this._isCellInSelection(K[0],t);for(A=K[0]+1;A<K[1];A++)R&&(R=vt===this._isCellInSelection(A,t));R&&(R=!i||n<K[0]||n>=K[1]),R?(E=!0,x=new qa(this._workCell,e.translateToString(!0,K[0],K[1]),K[1]-K[0]),M=K[1]-1,k=x.getWidth()):$=K[1]}let j=this._isCellInSelection(m,t),G=i&&m===n,le=C&&m>=a&&m<=d,Ee=!1;this._decorationService.forEachDecorationAtCell(m,t,void 0,K=>{Ee=!0});let J=x.getChars()||ot;if(J===" "&&(x.isUnderline()||x.isOverline())&&(J=" "),I=k*l-h.get(J,x.isBold(),x.isItalic()),!p)p=this._document.createElement("span");else if(y&&(j&&V||!j&&!V&&x.bg===T)&&(j&&V&&u.selectionForeground||x.fg===L)&&x.extended.ext===O&&le===W&&I===H&&!G&&!E&&!Ee&&R){x.isInvisible()?v+=ot:v+=J,y++;continue}else y&&(p.textContent=v),p=this._document.createElement("span"),y=0,v="";if(T=x.bg,L=x.fg,O=x.extended.ext,W=le,H=I,V=j,E&&n>=m&&n<=M&&(n=m),!this._coreService.isCursorHidden&&G&&this._coreService.isCursorInitialized){if(F.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&F.push("xterm-cursor-blink"),F.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":F.push("xterm-cursor-outline");break;case"block":F.push("xterm-cursor-block");break;case"bar":F.push("xterm-cursor-bar");break;case"underline":F.push("xterm-cursor-underline");break}}if(x.isBold()&&F.push("xterm-bold"),x.isItalic()&&F.push("xterm-italic"),x.isDim()&&F.push("xterm-dim"),x.isInvisible()?v=ot:v=x.getChars()||ot,x.isUnderline()&&(F.push(`xterm-underline-${x.extended.underlineStyle}`),v===" "&&(v=" "),!x.isUnderlineColorDefault()))if(x.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${qt.toColorRGB(x.getUnderlineColor()).join(",")})`;else{let K=x.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&x.isBold()&&K<8&&(K+=8),p.style.textDecorationColor=u.ansi[K].css}x.isOverline()&&(F.push("xterm-overline"),v===" "&&(v=" ")),x.isStrikethrough()&&F.push("xterm-strikethrough"),le&&(p.style.textDecoration="underline");let ie=x.getFgColor(),Z=x.getFgColorMode(),ee=x.getBgColor(),Y=x.getBgColorMode(),tt=!!x.isInverse();if(tt){let K=ie;ie=ee,ee=K;let vt=Z;Z=Y,Y=vt}let me,Te,ve=!1;this._decorationService.forEachDecorationAtCell(m,t,void 0,K=>{K.options.layer!=="top"&&ve||(K.backgroundColorRGB&&(Y=50331648,ee=K.backgroundColorRGB.rgba>>8&16777215,me=K.backgroundColorRGB),K.foregroundColorRGB&&(Z=50331648,ie=K.foregroundColorRGB.rgba>>8&16777215,Te=K.foregroundColorRGB),ve=K.options.layer==="top")}),!ve&&j&&(me=this._coreBrowserService.isFocused?u.selectionBackgroundOpaque:u.selectionInactiveBackgroundOpaque,ee=me.rgba>>8&16777215,Y=50331648,ve=!0,u.selectionForeground&&(Z=50331648,ie=u.selectionForeground.rgba>>8&16777215,Te=u.selectionForeground)),ve&&F.push("xterm-decoration-top");let he;switch(Y){case 16777216:case 33554432:he=u.ansi[ee],F.push(`xterm-bg-${ee}`);break;case 50331648:he=ue.toColor(ee>>16,ee>>8&255,ee&255),this._addStyle(p,`background-color:#${nr((ee>>>0).toString(16),"0",6)}`);break;case 0:default:tt?(he=u.foreground,F.push("xterm-bg-257")):he=u.background}switch(me||x.isDim()&&(me=Q.multiplyOpacity(he,.5)),Z){case 16777216:case 33554432:x.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(p,he,u.ansi[ie],x,me,void 0)||F.push(`xterm-fg-${ie}`);break;case 50331648:let K=ue.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(p,he,K,x,me,Te)||this._addStyle(p,`color:#${nr(ie.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(p,he,u.foreground,x,me,Te)||tt&&F.push("xterm-fg-257")}F.length&&(p.className=F.join(" "),F.length=0),!G&&!E&&!Ee&&R?y++:p.textContent=v,I!==this.defaultSpacing&&(p.style.letterSpacing=`${I}px`),c.push(p),m=M}return p&&y&&(p.textContent=v),c}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ya(s.getCode()))return!1;let o=this._getContrastCache(s),l;if(!r&&!n&&(l=o.getColor(t.rgba,i.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);l=Q.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};rs=ae([D(1,Jr),D(2,Le),D(3,Qe),D(4,mt),D(5,jt),D(6,Ct)],rs);function nr(e,t,i){for(;e.length<i;)e=t+e;return e}var Ga=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Ja=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,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,l=Math.max(n,0),h=Math.min(o,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function Za(){return new Ja}var Ri="xterm-dom-renderer-owner-",He="xterm-rows",Qt="xterm-fg-",or="xterm-bg-",Lt="xterm-focus",ei="xterm-selection",Qa=1,ns=class extends q{constructor(e,t,i,s,r,n,o,l,h,a,d,c,_,u){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=a,this._bufferService=d,this._coreService=c,this._coreBrowserService=_,this._themeService=u,this._terminalClass=Qa++,this._rowElements=[],this._selectionRenderModel=Za(),this.onRequestRedraw=this._register(new b).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(He),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(ei),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Xa(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(f=>this._injectCss(f))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(rs,document),this._element.classList.add(Ri+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(f=>this._handleLinkHover(f))),this._register(this._linkifier2.onHideLinkUnderline(f=>this._handleLinkLeave(f))),this._register(te(()=>{this._element.classList.remove(Ri+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Ga(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${He} 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} .${He} { 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} .${He} .xterm-dim { color: ${Q.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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${He}.${Lt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${He}.${Lt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${He}.${Lt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ei} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ei} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ei} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Qt}${n} { color: ${o.css}; }${this._terminalSelector} .${Qt}${n}.xterm-dim { color: ${Q.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${or}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Qt}257 { color: ${Q.opaque(e.background).css}; }${this._terminalSelector} .${Qt}257.xterm-dim { color: ${Q.multiplyOpacity(Q.opaque(e.background),.5).css}; }${this._terminalSelector} .${or}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 i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(Lt),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Lt),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,a=n===r?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(n,h,a));let d=o-n-1;if(l.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==o){let c=r===o?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,c))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}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 i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let a=h+i.ydisp,d=this._rowElements[h],c=i.lines.get(a);if(!d||!c)break;d.replaceChildren(...this._rowFactory.createRow(c,a,a===s,o,l,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ri}${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,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,a=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,c=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let u=i;u<=s;++u){let f=u+l.ydisp,p=this._rowElements[u],y=l.lines.get(f);if(!p||!y)break;p.replaceChildren(...this._rowFactory.createRow(y,f,f===h,c,_,a,d,this.dimensions.css.cell.width,this._widthCache,n?u===i?e:0:-1,n?(u===s?t:r)-1:-1))}}};ns=ae([D(7,ys),D(8,gi),D(9,Le),D(10,Me),D(11,mt),D(12,Qe),D(13,Ct)],ns);var os=class extends q{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new b),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new tl(this._optionsService))}catch{this._measureStrategy=this._register(new el(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())}};os=ae([D(2,Le)],os);var mn=class extends q{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)}},el=class extends mn{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},tl=class extends mn{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}},il=class extends q{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new sl(this._window)),this._onDprChange=this._register(new b),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new b),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(ke.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(z(this._textarea,"focus",()=>this._isFocused=!0)),this._register(z(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}},sl=class extends q{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new yt),this._onDprChange=this._register(new b),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(te(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=z(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)}},rl=class extends q{constructor(){super(),this.linkProviders=[],this._register(te(()=>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 Ms(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function nl(e,t,i,s,r,n,o,l,h){if(!n)return;let a=Ms(e,t,i);if(a)return a[0]=Math.ceil((a[0]+(h?o/2:0))/o),a[1]=Math.ceil(a[1]/l),a[0]=Math.min(Math.max(a[0],1),s+(h?1:0)),a[1]=Math.min(Math.max(a[1],1),r),a}var as=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return nl(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Ms(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};as=ae([D(0,et),D(1,gi)],as);var ol=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,i){this._rowCount=i,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=[]}},vn={};go(vn,{getSafariVersion:()=>ll,isChromeOS:()=>yn,isFirefox:()=>Sn,isIpad:()=>hl,isIphone:()=>cl,isLegacyEdge:()=>al,isLinux:()=>Ls,isMac:()=>di,isNode:()=>mi,isSafari:()=>wn,isWindows:()=>bn});var mi=typeof process<"u"&&"title"in process,Vt=mi?"node":navigator.userAgent,Yt=mi?"node":navigator.platform,Sn=Vt.includes("Firefox"),al=Vt.includes("Edge"),wn=/^((?!chrome|android).)*safari/i.test(Vt);function ll(){if(!wn)return 0;let e=Vt.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var di=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Yt),hl=Yt==="iPad",cl=Yt==="iPhone",bn=["Windows","Win16","Win32","WinCE"].includes(Yt),Ls=Yt.indexOf("Linux")>=0,yn=/\bCrOS\b/.test(Vt),Cn=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,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},dl=class extends Cn{_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())}}},ul=class extends Cn{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ui=!mi&&"requestIdleCallback"in window?ul:dl,_l=class{constructor(){this._queue=new ui}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},ls=class extends q{constructor(e,t,i,s,r,n,o,l,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new yt),this._pausedResizeTask=new _l,this._observerDisposable=this._register(new yt),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 b),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new b),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new b),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new b),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ol((a,d)=>this._renderRows(a,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new fl(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(te(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var a;return(a=this._renderer.value)==null?void 0:a.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(a=>this._registerIntersectionObserver(a,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=te(()=>i.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,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(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 i;return(i=this._renderer.value)==null?void 0:i.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,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};ls=ae([D(2,Le),D(3,gi),D(4,mt),D(5,jt),D(6,Me),D(7,Qe),D(8,Ct)],ls);var fl=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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 pl(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return vl(r,n,e,t,i,s)+vi(n,t,i,s)+Sl(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",Kt(Math.abs(r-e),$t(o,s));o=n>t?"D":"C";let l=Math.abs(n-t),h=ml(n>t?e:r,i)+(l-1)*i.cols+1+gl(n>t?r:e);return Kt(h,$t(o,s))}function gl(e,t){return e-1}function ml(e,t){return t.cols-e}function vl(e,t,i,s,r,n){return vi(t,s,r,n).length===0?"":Kt(kn(e,t,e,t-gt(t,r),!1,r).length,$t("D",n))}function vi(e,t,i,s){let r=e-gt(e,i),n=t-gt(t,i),o=Math.abs(r-n)-wl(e,t,i);return Kt(o,$t(xn(e,t),s))}function Sl(e,t,i,s,r,n){let o;vi(t,s,r,n).length>0?o=s-gt(s,r):o=t;let l=s,h=bl(e,t,i,s,r,n);return Kt(kn(e,o,i,l,h==="C",r).length,$t(h,n))}function wl(e,t,i){var o;let s=0,r=e-gt(e,i),n=t-gt(t,i);for(let l=0;l<Math.abs(r-n);l++){let h=xn(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+h*l))!=null&&o.isWrapped&&s++}return s}function gt(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function bl(e,t,i,s,r,n){let o;return vi(i,s,r,n).length>0?o=s-gt(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function xn(e,t){return e>t?"A":"B"}function kn(e,t,i,s,r,n){let o=e,l=t,h="";for(;(o!==i||l!==s)&&l>=0&&l<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(l,!1,0,e+1),o=n.cols-1,e=o,l--);return h+n.buffer.translateBufferLineToString(l,!1,e,o)}function $t(e,t){let i=t?"O":"[";return S.ESC+i+e}function Kt(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var yl=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 ar(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 Bi=50,Cl=15,xl=50,kl=500,El=" ",Rl=new RegExp(El,"g"),hs=class extends q{constructor(e,t,i,s,r,n,o,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new We,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new b),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new b),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new b),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new b),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=a=>this._handleMouseMove(a),this._mouseUpListener=a=>this._handleMouseUp(a),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(a=>this._handleTrim(a)),this._register(this._bufferService.buffers.onBufferActivate(a=>this._handleBufferActivate(a))),this.enable(),this._model=new yl(this._bufferService),this._activeSelectionMode=0,this._register(te(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(a=>{a.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 i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let l=i.translateBufferLineToString(o,!0,r,n);s.push(l)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),l=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=l:s.push(l)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(Rl," ")).join(bn?`\r
40
+ `))}},qo=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},jo=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Vo=0,Ri=class{constructor(e){this.value=e,this.id=Vo++}},Yo=2,Xo,R=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Ko((e==null?void 0:e.onListenerError)??ri,((i=this._options)==null?void 0:i.leakWarningThreshold)??$o):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Wo(this._options._profName):void 0,this._deliveryQueue=(r=this._options)==null?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var o,l,h,a,d;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let c=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(c);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],u=new jo(`${c}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((o=this._options)==null?void 0:o.onListenerError)||ri)(u),U.None}if(this._disposed)return U.None;t&&(e=e.bind(t));let s=new Ri(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Uo.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Ri?(this._deliveryQueue??(this._deliveryQueue=new Go),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||h.call(l,this),this._listeners=s,(d=(a=this._options)==null?void 0:a.onDidAddFirstListener)==null||d.call(a,this)),this._size++;let n=ee(()=>{r==null||r(),this._removeListener(s)});return i instanceof at?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,l;if((n=(r=this._options)==null?void 0:r.onWillRemoveListener)==null||n.call(r,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||l.call(o,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);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--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*Yo<=t.length){let h=0;for(let a=0;a<t.length;a++)t[a]?t[h++]=t[a]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=h}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||ri;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Ri)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(r=this._perfMon)==null||r.stop()}hasListeners(){return this._size>0}},Go=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Ji=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new R,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new R,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Ji.INSTANCE=new Ji;var Bs=Ji;function Jo(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Bs.INSTANCE.onDidChangeZoomLevel;function Zo(e){return Bs.INSTANCE.getZoomFactor(e)}Bs.INSTANCE.onDidChangeFullscreen;var xt=typeof navigator=="object"?navigator.userAgent:"",Zi=xt.indexOf("Firefox")>=0,Qo=xt.indexOf("AppleWebKit")>=0,Ds=xt.indexOf("Chrome")>=0,ea=!Ds&&xt.indexOf("Safari")>=0;xt.indexOf("Electron/")>=0;xt.indexOf("Android")>=0;var Bi=!1;if(typeof Ze.matchMedia=="function"){let e=Ze.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Ze.matchMedia("(display-mode: fullscreen)");Bi=e.matches,Jo(Ze,e,({matches:i})=>{Bi&&t.matches||(Bi=i)})}var bt="en",Qi=!1,es=!1,ni=!1,cn=!1,Zt,oi=bt,js=bt,ta,Ke,pt=globalThis,ke,zr;typeof pt.vscode<"u"&&typeof pt.vscode.process<"u"?ke=pt.vscode.process:typeof process<"u"&&typeof((zr=process==null?void 0:process.versions)==null?void 0:zr.node)=="string"&&(ke=process);var Fr,ia=typeof((Fr=ke==null?void 0:ke.versions)==null?void 0:Fr.electron)=="string",sa=ia&&(ke==null?void 0:ke.type)==="renderer",Wr;if(typeof ke=="object"){Qi=ke.platform==="win32",es=ke.platform==="darwin",ni=ke.platform==="linux",ni&&ke.env.SNAP&&ke.env.SNAP_REVISION,ke.env.CI||ke.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Zt=bt,oi=bt;let e=ke.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Zt=t.userLocale,js=t.osLocale,oi=t.resolvedLanguage||bt,ta=(Wr=t.languagePack)==null?void 0:Wr.translationsConfigFile}catch{}cn=!0}else typeof navigator=="object"&&!sa?(Ke=navigator.userAgent,Qi=Ke.indexOf("Windows")>=0,es=Ke.indexOf("Macintosh")>=0,(Ke.indexOf("Macintosh")>=0||Ke.indexOf("iPad")>=0||Ke.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,ni=Ke.indexOf("Linux")>=0,(Ke==null?void 0:Ke.indexOf("Mobi"))>=0,oi=globalThis._VSCODE_NLS_LANGUAGE||bt,Zt=navigator.language.toLowerCase(),js=Zt):console.error("Unable to resolve platform.");var dn=Qi,Xe=es,ra=ni,Vs=cn,Ge=Ke,it=oi,na;(e=>{function t(){return it}e.value=t;function i(){return it.length===2?it==="en":it.length>=3?it[0]==="e"&&it[1]==="n"&&it[2]==="-":!1}e.isDefaultVariant=i;function s(){return it==="en"}e.isDefault=s})(na||(na={}));var oa=typeof pt.postMessage=="function"&&!pt.importScripts;(()=>{if(oa){let e=[];pt.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),pt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var aa=!!(Ge&&Ge.indexOf("Chrome")>=0);Ge&&Ge.indexOf("Firefox")>=0;!aa&&Ge&&Ge.indexOf("Safari")>=0;Ge&&Ge.indexOf("Edg/")>=0;Ge&&Ge.indexOf("Android")>=0;var St=typeof navigator=="object"?navigator:{};Vs||document.queryCommandSupported&&document.queryCommandSupported("copy")||St&&St.clipboard&&St.clipboard.writeText,Vs||St&&St.clipboard&&St.clipboard.readText;var Ms=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}},Di=new Ms,Ys=new Ms,Xs=new Ms,la=new Array(230),un;(e=>{function t(l){return Di.keyCodeToStr(l)}e.toString=t;function i(l){return Di.strToKeyCode(l)}e.fromString=i;function s(l){return Ys.keyCodeToStr(l)}e.toUserSettingsUS=s;function r(l){return Xs.keyCodeToStr(l)}e.toUserSettingsGeneral=r;function n(l){return Ys.strToKeyCode(l)||Xs.strToKeyCode(l)}e.fromUserSettings=n;function o(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 Di.keyCodeToStr(l)}e.toElectronAccelerator=o})(un||(un={}));var ha=class _n{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof _n&&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",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new ca([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},ca=class{constructor(e){if(e.length===0)throw Io("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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 da(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return un.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Zi)switch(t){case 59:return 85;case 60:if(ra)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Xe)return 57;break}else if(Qo&&(Xe&&t===93||!Xe&&t===92))return 57;return la[t]||0}var ua=Xe?256:2048,_a=512,fa=1024,pa=Xe?2048:256,Gs=class{constructor(e){var i;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=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=da(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|=ua),this.altKey&&(t|=_a),this.shiftKey&&(t|=fa),this.metaKey&&(t|=pa),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new ha(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Js=new WeakMap;function ga(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var ma=class{static getSameOriginWindowChain(e){let t=Js.get(e);if(!t){t=[],Js.set(e,t);let i=e,s;do s=ga(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let l=n.iframeElement.getBoundingClientRect();i+=l.top,s+=l.left}return{top:i,left:s}}},Qt=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 i=ma.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Zs=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Ds){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,l=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*l):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Zi&&!Xe?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")ea&&dn?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*l):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Zi&&!Xe?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?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()}},fn=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),va;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Sa?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ee.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:fn})})(va||(va={}));var Sa=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?fn:(this._emitter||(this._emitter=new R),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ls=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 ji("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ji("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},wa=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,i=globalThis){if(this.isDisposed)throw new ji("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=ee(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},ba;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(ba||(ba={}));var Qs=class ze{static fromArray(t){return new ze(i=>{i.emitMany(t)})}static fromPromise(t){return new ze(async i=>{i.emitMany(await t)})}static fromPromises(t){return new ze(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new ze(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new R,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.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 Ee.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new ze(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return ze.map(this,t)}static filter(t,i){return new ze(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return ze.filter(this,t)}static coalesce(t){return ze.filter(t,i=>!!i)}coalesce(){return ze.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return ze.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())}};Qs.EMPTY=Qs.fromArray([]);var{getWindow:Ye,getWindowId:ya,onDidRegisterWindow:Ca}=(function(){let e=new Map,t={window:Ze,disposables:new at};e.set(Ze.vscodeWindowId,t);let i=new R,s=new R,r=new R;function n(o,l){return(typeof o=="number"?e.get(o):void 0)??(l?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return U.None;let l=new at,h={window:o,disposables:l.add(new at)};return e.set(o.vscodeWindowId,h),l.add(ee(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),l.add(F(o,we.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var a;let l=o;if((a=l==null?void 0:l.ownerDocument)!=null&&a.defaultView)return l.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:Ze},getDocument(o){return Ye(o).document}}})(),xa=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!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 F(e,t,i,s){return new xa(e,t,i,s)}var er=function(e,t,i,s){return F(e,t,i,s)},Ts,ka=class extends wa{constructor(e){super(),this.defaultTarget=e&&Ye(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},tr=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){ri(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(tr.sort),o.shift().execute();s.set(n,!1)};Ts=(n,o,l=0)=>{let h=ya(n),a=new tr(o,l),d=e.get(h);return d||(d=[],e.set(h,d)),d.push(a),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),a}})();function Ea(e){let t=e.getBoundingClientRect(),i=Ye(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var we={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"},Ra=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=Ae(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ae(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ae(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ae(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ae(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ae(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ae(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ae(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ae(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ae(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ae(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=Ae(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=Ae(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ae(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 Ae(e){return typeof e=="number"?`${e}px`:e}function $t(e){return new Ra(e)}var pn=class{constructor(){this._hooks=new at,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(ee(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=Ye(e)}this._hooks.add(F(n,we.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(F(n,we.POINTER_UP,o=>this.stopMonitoring(!0)))}};function Ba(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var je;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(je||(je={}));var Nt=class Be extends U{constructor(){super(),this.dispatched=!1,this.targets=new qs,this.ignoreTargets=new qs,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ee.runAndSubscribe(Ca,({window:t,disposables:i})=>{i.add(F(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(F(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(F(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Ze,disposables:this._store}))}static addTarget(t){if(!Be.isTouchDevice())return U.None;Be.INSTANCE||(Be.INSTANCE=new Be);let i=Be.INSTANCE.targets.push(t);return ee(i)}static ignoreTarget(t){if(!Be.isTouchDevice())return U.None;Be.INSTANCE||(Be.INSTANCE=new Be);let i=Be.INSTANCE.ignoreTargets.push(t);return ee(i)}static isTouchDevice(){return"ontouchstart"in Ze||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(je.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let l=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],a=Date.now()-h.initialTimeStamp;if(a<Be.HOLD_DELAY&&Math.abs(h.initialPageX-Oe(h.rollingPageX))<30&&Math.abs(h.initialPageY-Oe(h.rollingPageY))<30){let d=this.newGestureEvent(je.Tap,h.initialTarget);d.pageX=Oe(h.rollingPageX),d.pageY=Oe(h.rollingPageY),this.dispatchEvent(d)}else if(a>=Be.HOLD_DELAY&&Math.abs(h.initialPageX-Oe(h.rollingPageX))<30&&Math.abs(h.initialPageY-Oe(h.rollingPageY))<30){let d=this.newGestureEvent(je.Contextmenu,h.initialTarget);d.pageX=Oe(h.rollingPageX),d.pageY=Oe(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=Oe(h.rollingPageX),c=Oe(h.rollingPageY),_=Oe(h.rollingTimestamps)-h.rollingTimestamps[0],u=d-h.rollingPageX[0],f=c-h.rollingPageY[0],p=[...this.targets].filter(b=>h.initialTarget instanceof Node&&b.contains(h.initialTarget));this.inertia(t,p,s,Math.abs(u)/_,u>0?1:-1,d,Math.abs(f)/_,f>0?1:-1,c)}this.dispatchEvent(this.newGestureEvent(je.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===je.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Be.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===je.Change||t.type===je.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,l,h,a){this.handle=Ts(t,()=>{let d=Date.now(),c=d-s,_=0,u=0,f=!0;r+=Be.SCROLL_FRICTION*c,l+=Be.SCROLL_FRICTION*c,r>0&&(f=!1,_=n*r*c),l>0&&(f=!1,u=h*l*c);let p=this.newGestureEvent(je.Change);p.translationX=_,p.translationY=u,i.forEach(b=>b.dispatchEvent(p)),f||this.inertia(t,i,d,r,n,o+_,l,h,a+u)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],l=this.newGestureEvent(je.Change,o.initialTarget);l.translationX=n.pageX-Oe(o.rollingPageX),l.translationY=n.pageY-Oe(o.rollingPageY),l.pageX=n.pageX,l.pageY=n.pageY,this.dispatchEvent(l),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Nt.SCROLL_FRICTION=-.005,Nt.HOLD_DELAY=700,Nt.CLEAR_TAP_COUNT_TIME=400,le([Ba],Nt,"isTouchDevice",1);var Da=Nt,Ps=class extends U{onclick(e,t){this._register(F(e,we.CLICK,i=>t(new Qt(Ye(e),i))))}onmousedown(e,t){this._register(F(e,we.MOUSE_DOWN,i=>t(new Qt(Ye(e),i))))}onmouseover(e,t){this._register(F(e,we.MOUSE_OVER,i=>t(new Qt(Ye(e),i))))}onmouseleave(e,t){this._register(F(e,we.MOUSE_LEAVE,i=>t(new Qt(Ye(e),i))))}onkeydown(e,t){this._register(F(e,we.KEY_DOWN,i=>t(new Gs(i))))}onkeyup(e,t){this._register(F(e,we.KEY_UP,i=>t(new Gs(i))))}oninput(e,t){this._register(F(e,we.INPUT,t))}onblur(e,t){this._register(F(e,we.BLUR,t))}onfocus(e,t){this._register(F(e,we.FOCUS,t))}onchange(e,t){this._register(F(e,we.CHANGE,t))}ignoreGesture(e){return Da.ignoreTarget(e)}},ir=11,Ma=class extends Ps{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=ir+"px",this.domNode.style.height=ir+"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 pn),this._register(er(this.bgDomNode,we.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(er(this.domNode,we.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new ka),this._pointerdownScheduleRepeatTimer=this._register(new Ls)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ye(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},La=class ts{constructor(t,i,s,r,n,o,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),l+n>o&&(l=o-n),l<0&&(l=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,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,i){return new ts(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new ts(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,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,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:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:h}}},Ta=class extends U{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new R),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new La(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 s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new rr(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=rr.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},sr=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Mi(e,t){let i=t-e;return function(s){return e+i*Ia(s)}}function Pa(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var rr=class is{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,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,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),Pa(Mi(t,r),Mi(n,i),.33)}return Mi(t,i)}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 i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new sr(s,r,!1)}return new sr(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return is.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new is(t,i,r,s)}};function Aa(e){return Math.pow(e,3)}function Ia(e){return 1-Aa(1-e)}var Oa=class extends U{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Ls)}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":"")))}},Na=140,gn=class extends Ps{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 Oa(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new pn),this._shouldRender=!0,this.domNode=$t(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(F(this.domNode.domNode,we.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Ma(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=$t(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(F(this.slider.domNode,we.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.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,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=Ea(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(dn&&o>Na){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let l=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.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()}},mn=class ss{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new ss(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),l=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let a=Math.round(Math.max(20,Math.floor(s*l/r))),d=(l-a)/(r-s),c=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:d,computedSliderPosition:Math.round(c)}}_refreshComputedValues(){let t=ss._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 i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Ha=class extends gn{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new mn(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.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}},za=class extends gn{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new mn(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.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}},Fa=500,nr=50,Wa=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},rs=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,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Ds){let i=Ye(t.browserEvent),s=Zo(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new Wa(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=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]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),l=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),a=Math.max(Math.min(n,l),1),d=Math.max(r,o),c=Math.max(n,l);d%h===0&&c%a===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};rs.INSTANCE=new rs;var $a=rs,Ka=class extends Ps{constructor(e,t,i){super(),this._onScroll=this._register(new R),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new R),this.onWillScroll=this._onWillScroll.event,this._options=qa(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new za(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Ha(this._scrollable,this._options,s)),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=$t(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=$t(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=$t(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,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Ls),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=gt(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,Xe&&(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 Zs(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=gt(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Zs(i))};this._mouseWheelToDispose.push(F(this._listenOnDomNode,we.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=$a.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let l=!Xe&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),a={};if(n){let d=nr*n,c=h.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(a,c)}if(o){let d=nr*o,c=h.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(a,c)}a=this._scrollable.validateScrollPosition(a),(h.scrollLeft!==a.scrollLeft||h.scrollTop!==a.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(a):this._scrollable.setScrollPositionNow(a),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(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,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_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(),Fa)}},Ua=class extends Ka{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function qa(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,Xe&&(t.className+=" mac"),t}var ns=class extends U{constructor(e,t,i,s,r,n,o,l){super(),this._bufferService=i,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new R),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Ta({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:a=>Ts(s.window,a)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Ua(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(r.onProtocolChange(a=>{this._scrollableElement.updateOptions({handleMouseWheel:!(a&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ee.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ee(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ee(()=>this._styleElement.remove())),this._register(Ee.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
41
+ `)})),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(a=>this._handleScroll(a)))}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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};ns=le([L(2,Le),L(3,Qe),L(4,Gr),L(5,Ct),L(6,Te),L(7,et)],ns);var os=class extends U{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,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(n=>this._removeDecoration(n))),this._register(ee(()=>{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 s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*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()}};os=le([L(1,Le),L(2,Qe),L(3,Vt),L(4,et)],os);var ja=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ue={full:0,left:0,center:0,right:0},st={full:0,left:0,center:0,right:0},Lt={full:0,left:0,center:0,right:0},di=class extends U{constructor(e,t,i,s,r,n,o,l){var a;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new ja,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(),(a=this._viewportElement.parentElement)==null||a.insertBefore(this._canvas,this._viewportElement),this._register(ee(()=>{var d;return(d=this._canvas)==null?void 0:d.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);st.full=this._canvas.width,st.left=e,st.center=t,st.right=e,this._refreshDrawHeightConstants(),Lt.full=1,Lt.left=1,Lt.center=1+st.left,Lt.right=1+st.left+st.center}_refreshDrawHeightConstants(){Ue.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);Ue.left=t,Ue.center=t,Ue.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ue.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ue.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ue.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ue.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(Lt[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ue[e.position||"full"]/2),st[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ue[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}))}};di=le([L(2,Le),L(3,Vt),L(4,et),L(5,Te),L(6,Ct),L(7,Qe)],di);var w;(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=`
42
+ `,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=""))(w||(w={}));var ai;(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="Ÿ"))(ai||(ai={}));var vn;(e=>e.ST=`${w.ESC}\\`)(vn||(vn={}));var as=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${w.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),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};as=le([L(2,Le),L(3,Te),L(4,vt),L(5,et)],as);var be=0,ye=0,Ce=0,ae=0,or={css:"#00000000",rgba:0},ue;(e=>{function t(r,n,o,l){return l!==void 0?`#${ct(r)}${ct(n)}${ct(o)}${ct(l)}`:`#${ct(r)}${ct(n)}${ct(o)}`}e.toCss=t;function i(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}e.toRgba=i;function s(r,n,o,l){return{css:e.toCss(r,n,o,l),rgba:e.toRgba(r,n,o,l)}}e.toColor=s})(ue||(ue={}));var Z;(e=>{function t(h,a){if(ae=(a.rgba&255)/255,ae===1)return{css:a.css,rgba:a.rgba};let d=a.rgba>>24&255,c=a.rgba>>16&255,_=a.rgba>>8&255,u=h.rgba>>24&255,f=h.rgba>>16&255,p=h.rgba>>8&255;be=u+Math.round((d-u)*ae),ye=f+Math.round((c-f)*ae),Ce=p+Math.round((_-p)*ae);let b=ue.toCss(be,ye,Ce),g=ue.toRgba(be,ye,Ce);return{css:b,rgba:g}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,a,d){let c=li.ensureContrastRatio(h.rgba,a.rgba,d);if(c)return ue.toColor(c>>24&255,c>>16&255,c>>8&255)}e.ensureContrastRatio=s;function r(h){let a=(h.rgba|255)>>>0;return[be,ye,Ce]=li.toChannels(a),{css:ue.toCss(be,ye,Ce),rgba:a}}e.opaque=r;function n(h,a){return ae=Math.round(a*255),[be,ye,Ce]=li.toChannels(h.rgba),{css:ue.toCss(be,ye,Ce,ae),rgba:ue.toRgba(be,ye,Ce,ae)}}e.opacity=n;function o(h,a){return ae=h.rgba&255,n(h,ae*a/255)}e.multiplyOpacity=o;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(Z||(Z={}));var re;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return be=parseInt(r.slice(1,2).repeat(2),16),ye=parseInt(r.slice(2,3).repeat(2),16),Ce=parseInt(r.slice(3,4).repeat(2),16),ue.toColor(be,ye,Ce);case 5:return be=parseInt(r.slice(1,2).repeat(2),16),ye=parseInt(r.slice(2,3).repeat(2),16),Ce=parseInt(r.slice(3,4).repeat(2),16),ae=parseInt(r.slice(4,5).repeat(2),16),ue.toColor(be,ye,Ce,ae);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return be=parseInt(n[1]),ye=parseInt(n[2]),Ce=parseInt(n[3]),ae=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ue.toColor(be,ye,Ce,ae);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[be,ye,Ce,ae]=t.getImageData(0,0,1,1).data,ae!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ue.toRgba(be,ye,Ce,ae),css:r}}e.toColor=s})(re||(re={}));var Me;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,l=r/255,h=n/255,a=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),c=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return a*.2126+d*.7152+c*.0722}e.relativeLuminance2=i})(Me||(Me={}));var li;(e=>{function t(o,l){if(ae=(l&255)/255,ae===1)return l;let h=l>>24&255,a=l>>16&255,d=l>>8&255,c=o>>24&255,_=o>>16&255,u=o>>8&255;return be=c+Math.round((h-c)*ae),ye=_+Math.round((a-_)*ae),Ce=u+Math.round((d-u)*ae),ue.toRgba(be,ye,Ce)}e.blend=t;function i(o,l,h){let a=Me.relativeLuminance(o>>8),d=Me.relativeLuminance(l>>8);if(Je(a,d)<h){if(d<a){let u=s(o,l,h),f=Je(a,Me.relativeLuminance(u>>8));if(f<h){let p=r(o,l,h),b=Je(a,Me.relativeLuminance(p>>8));return f>b?u:p}return u}let c=r(o,l,h),_=Je(a,Me.relativeLuminance(c>>8));if(_<h){let u=s(o,l,h),f=Je(a,Me.relativeLuminance(u>>8));return _>f?c:u}return c}}e.ensureContrastRatio=i;function s(o,l,h){let a=o>>24&255,d=o>>16&255,c=o>>8&255,_=l>>24&255,u=l>>16&255,f=l>>8&255,p=Je(Me.relativeLuminance2(_,u,f),Me.relativeLuminance2(a,d,c));for(;p<h&&(_>0||u>0||f>0);)_-=Math.max(0,Math.ceil(_*.1)),u-=Math.max(0,Math.ceil(u*.1)),f-=Math.max(0,Math.ceil(f*.1)),p=Je(Me.relativeLuminance2(_,u,f),Me.relativeLuminance2(a,d,c));return(_<<24|u<<16|f<<8|255)>>>0}e.reduceLuminance=s;function r(o,l,h){let a=o>>24&255,d=o>>16&255,c=o>>8&255,_=l>>24&255,u=l>>16&255,f=l>>8&255,p=Je(Me.relativeLuminance2(_,u,f),Me.relativeLuminance2(a,d,c));for(;p<h&&(_<255||u<255||f<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),u=Math.min(255,u+Math.ceil((255-u)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),p=Je(Me.relativeLuminance2(_,u,f),Me.relativeLuminance2(a,d,c));return(_<<24|u<<16|f<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(li||(li={}));function ct(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Je(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Va=class extends jt{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}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()]}},ui=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new We}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 i=[],s=t.translateToString(!0),r=0,n=0,o=0,l=t.getFg(0),h=t.getBg(0);for(let a=0;a<t.getTrimmedLength();a++)if(t.loadCell(a,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(a-r>1){let d=this._getJoinedRanges(s,o,n,t,r);for(let c=0;c<d.length;c++)i.push(d[c])}r=a,o=n,l=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||ot.length}if(this._bufferService.cols-r>1){let a=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<a.length;d++)i.push(a[d])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(n);for(let a=0;a<h.length;a++)ui._mergeRanges(o,h[a])}catch(h){console.error(h)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let l=i;l<this._bufferService.cols;l++){let h=t.getWidth(l),a=t.getString(l).length||ot.length;if(h!==0){if(!r&&o[0]<=n&&(o[0]=l,r=!0),o[1]<=n){if(o[1]=l,o=e[++s],!o)break;o[0]<=n?(o[0]=l,r=!0):r=!1}n+=a}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};ui=le([L(0,Le)],ui);function Ya(e){return 57508<=e&&e<=57558}function Xa(e){return 9472<=e&&e<=9631}function Ga(e){return Ya(e)||Xa(e)}function Ja(){return{css:{canvas:ei(),cell:ei()},device:{canvas:ei(),cell:ei(),char:{width:0,height:0,left:0,top:0}}}}function ei(){return{width:0,height:0}}var ls=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new We,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,l,h,a,d){let c=[],_=this._characterJoinerService.getJoinedCharacters(t),u=this._themeService.colors,f=e.getNoBgTrimmedLength();i&&f<n+1&&(f=n+1);let p,b=0,g="",T=0,D=0,P=0,A=0,I=!1,N=0,$=!1,V=0,ne=0,W=[],B=a!==-1&&d!==-1;for(let y=0;y<f;y++){e.loadCell(y,this._workCell);let v=this._workCell.getWidth();if(v===0)continue;let S=!1,k=y>=ne,E=y,x=this._workCell;if(_.length>0&&y===_[0][0]&&k){let q=_.shift(),lt=this._isCellInSelection(q[0],t);for(T=q[0]+1;T<q[1];T++)k&&(k=lt===this._isCellInSelection(T,t));k&&(k=!i||n<q[0]||n>=q[1]),k?(S=!0,x=new Va(this._workCell,e.translateToString(!0,q[0],q[1]),q[1]-q[0]),E=q[1]-1,v=x.getWidth()):ne=q[1]}let H=this._isCellInSelection(y,t),Y=i&&y===n,te=B&&y>=a&&y<=d,Re=!1;this._decorationService.forEachDecorationAtCell(y,t,void 0,q=>{Re=!0});let G=x.getChars()||ot;if(G===" "&&(x.isUnderline()||x.isOverline())&&(G=" "),V=v*l-h.get(G,x.isBold(),x.isItalic()),!p)p=this._document.createElement("span");else if(b&&(H&&$||!H&&!$&&x.bg===D)&&(H&&$&&u.selectionForeground||x.fg===P)&&x.extended.ext===A&&te===I&&V===N&&!Y&&!S&&!Re&&k){x.isInvisible()?g+=ot:g+=G,b++;continue}else b&&(p.textContent=g),p=this._document.createElement("span"),b=0,g="";if(D=x.bg,P=x.fg,A=x.extended.ext,I=te,N=V,$=H,S&&n>=y&&n<=E&&(n=y),!this._coreService.isCursorHidden&&Y&&this._coreService.isCursorInitialized){if(W.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&W.push("xterm-cursor-blink"),W.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":W.push("xterm-cursor-outline");break;case"block":W.push("xterm-cursor-block");break;case"bar":W.push("xterm-cursor-bar");break;case"underline":W.push("xterm-cursor-underline");break}}if(x.isBold()&&W.push("xterm-bold"),x.isItalic()&&W.push("xterm-italic"),x.isDim()&&W.push("xterm-dim"),x.isInvisible()?g=ot:g=x.getChars()||ot,x.isUnderline()&&(W.push(`xterm-underline-${x.extended.underlineStyle}`),g===" "&&(g=" "),!x.isUnderlineColorDefault()))if(x.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${jt.toColorRGB(x.getUnderlineColor()).join(",")})`;else{let q=x.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&x.isBold()&&q<8&&(q+=8),p.style.textDecorationColor=u.ansi[q].css}x.isOverline()&&(W.push("xterm-overline"),g===" "&&(g=" ")),x.isStrikethrough()&&W.push("xterm-strikethrough"),te&&(p.style.textDecoration="underline");let ie=x.getFgColor(),J=x.getFgColorMode(),Q=x.getBgColor(),j=x.getBgColorMode(),tt=!!x.isInverse();if(tt){let q=ie;ie=Q,Q=q;let lt=J;J=j,j=lt}let ve,Pe,Se=!1;this._decorationService.forEachDecorationAtCell(y,t,void 0,q=>{q.options.layer!=="top"&&Se||(q.backgroundColorRGB&&(j=50331648,Q=q.backgroundColorRGB.rgba>>8&16777215,ve=q.backgroundColorRGB),q.foregroundColorRGB&&(J=50331648,ie=q.foregroundColorRGB.rgba>>8&16777215,Pe=q.foregroundColorRGB),Se=q.options.layer==="top")}),!Se&&H&&(ve=this._coreBrowserService.isFocused?u.selectionBackgroundOpaque:u.selectionInactiveBackgroundOpaque,Q=ve.rgba>>8&16777215,j=50331648,Se=!0,u.selectionForeground&&(J=50331648,ie=u.selectionForeground.rgba>>8&16777215,Pe=u.selectionForeground)),Se&&W.push("xterm-decoration-top");let he;switch(j){case 16777216:case 33554432:he=u.ansi[Q],W.push(`xterm-bg-${Q}`);break;case 50331648:he=ue.toColor(Q>>16,Q>>8&255,Q&255),this._addStyle(p,`background-color:#${ar((Q>>>0).toString(16),"0",6)}`);break;case 0:default:tt?(he=u.foreground,W.push("xterm-bg-257")):he=u.background}switch(ve||x.isDim()&&(ve=Z.multiplyOpacity(he,.5)),J){case 16777216:case 33554432:x.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(p,he,u.ansi[ie],x,ve,void 0)||W.push(`xterm-fg-${ie}`);break;case 50331648:let q=ue.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(p,he,q,x,ve,Pe)||this._addStyle(p,`color:#${ar(ie.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(p,he,u.foreground,x,ve,Pe)||tt&&W.push("xterm-fg-257")}W.length&&(p.className=W.join(" "),W.length=0),!Y&&!S&&!Re&&k?b++:p.textContent=g,V!==this.defaultSpacing&&(p.style.letterSpacing=`${V}px`),c.push(p),y=E}return p&&b&&(p.textContent=g),c}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ga(s.getCode()))return!1;let o=this._getContrastCache(s),l;if(!r&&!n&&(l=o.getColor(t.rgba,i.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);l=Z.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};ls=le([L(1,Qr),L(2,Te),L(3,Qe),L(4,vt),L(5,Vt),L(6,Ct)],ls);function ar(e,t,i){for(;e.length<i;)e=t+e;return e}var Za=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Qa=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,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,l=Math.max(n,0),h=Math.min(o,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function el(){return new Qa}var Li="xterm-dom-renderer-owner-",He="xterm-rows",ti="xterm-fg-",lr="xterm-bg-",Tt="xterm-focus",ii="xterm-selection",tl=1,hs=class extends U{constructor(e,t,i,s,r,n,o,l,h,a,d,c,_,u){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=a,this._bufferService=d,this._coreService=c,this._coreBrowserService=_,this._themeService=u,this._terminalClass=tl++,this._rowElements=[],this._selectionRenderModel=el(),this.onRequestRedraw=this._register(new R).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(He),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=Ja(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(f=>this._injectCss(f))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(ls,document),this._element.classList.add(Li+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(f=>this._handleLinkHover(f))),this._register(this._linkifier2.onHideLinkUnderline(f=>this._handleLinkLeave(f))),this._register(ee(()=>{this._element.classList.remove(Li+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Za(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${He} 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} .${He} { 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} .${He} .xterm-dim { color: ${Z.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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${He}.${Tt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${He}.${Tt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${He}.${Tt} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${He} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${He} .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[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${ti}${n} { color: ${o.css}; }${this._terminalSelector} .${ti}${n}.xterm-dim { color: ${Z.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${lr}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${ti}257 { color: ${Z.opaque(e.background).css}; }${this._terminalSelector} .${ti}257.xterm-dim { color: ${Z.multiplyOpacity(Z.opaque(e.background),.5).css}; }${this._terminalSelector} .${lr}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 i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(Tt),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Tt),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,a=n===r?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(n,h,a));let d=o-n-1;if(l.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==o){let c=r===o?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,c))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}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 i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let a=h+i.ydisp,d=this._rowElements[h],c=i.lines.get(a);if(!d||!c)break;d.replaceChildren(...this._rowFactory.createRow(c,a,a===s,o,l,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Li}${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,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,a=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,c=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let u=i;u<=s;++u){let f=u+l.ydisp,p=this._rowElements[u],b=l.lines.get(f);if(!p||!b)break;p.replaceChildren(...this._rowFactory.createRow(b,f,f===h,c,_,a,d,this.dimensions.css.cell.width,this._widthCache,n?u===i?e:0:-1,n?(u===s?t:r)-1:-1))}}};hs=le([L(7,Es),L(8,vi),L(9,Te),L(10,Le),L(11,vt),L(12,Qe),L(13,Ct)],hs);var cs=class extends U{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new R),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new sl(this._optionsService))}catch{this._measureStrategy=this._register(new il(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())}};cs=le([L(2,Te)],cs);var Sn=class extends U{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)}},il=class extends Sn{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},sl=class extends Sn{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}},rl=class extends U{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new nl(this._window)),this._onDprChange=this._register(new R),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new R),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ee.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(F(this._textarea,"focus",()=>this._isFocused=!0)),this._register(F(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}},nl=class extends U{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new yt),this._onDprChange=this._register(new R),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ee(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=F(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)}},ol=class extends U{constructor(){super(),this.linkProviders=[],this._register(ee(()=>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 As(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function al(e,t,i,s,r,n,o,l,h){if(!n)return;let a=As(e,t,i);if(a)return a[0]=Math.ceil((a[0]+(h?o/2:0))/o),a[1]=Math.ceil(a[1]/l),a[0]=Math.min(Math.max(a[0],1),s+(h?1:0)),a[1]=Math.min(Math.max(a[1],1),r),a}var ds=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return al(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=As(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};ds=le([L(0,et),L(1,vi)],ds);var ll=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,i){this._rowCount=i,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=[]}},wn={};vo(wn,{getSafariVersion:()=>cl,isChromeOS:()=>xn,isFirefox:()=>bn,isIpad:()=>dl,isIphone:()=>ul,isLegacyEdge:()=>hl,isLinux:()=>Is,isMac:()=>_i,isNode:()=>Si,isSafari:()=>yn,isWindows:()=>Cn});var Si=typeof process<"u"&&"title"in process,Yt=Si?"node":navigator.userAgent,Xt=Si?"node":navigator.platform,bn=Yt.includes("Firefox"),hl=Yt.includes("Edge"),yn=/^((?!chrome|android).)*safari/i.test(Yt);function cl(){if(!yn)return 0;let e=Yt.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var _i=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Xt),dl=Xt==="iPad",ul=Xt==="iPhone",Cn=["Windows","Win16","Win32","WinCE"].includes(Xt),Is=Xt.indexOf("Linux")>=0,xn=/\bCrOS\b/.test(Yt),kn=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,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},_l=class extends kn{_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())}}},fl=class extends kn{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fi=!Si&&"requestIdleCallback"in window?fl:_l,pl=class{constructor(){this._queue=new fi}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},us=class extends U{constructor(e,t,i,s,r,n,o,l,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new yt),this._pausedResizeTask=new pl,this._observerDisposable=this._register(new yt),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 R),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new R),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new R),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new R),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ll((a,d)=>this._renderRows(a,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new gl(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ee(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var a;return(a=this._renderer.value)==null?void 0:a.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(a=>this._registerIntersectionObserver(a,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=ee(()=>i.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,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(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 i;return(i=this._renderer.value)==null?void 0:i.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,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};us=le([L(2,Te),L(3,vi),L(4,vt),L(5,Vt),L(6,Le),L(7,Qe),L(8,Ct)],us);var gl=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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 ml(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return wl(r,n,e,t,i,s)+wi(n,t,i,s)+bl(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",Ut(Math.abs(r-e),Kt(o,s));o=n>t?"D":"C";let l=Math.abs(n-t),h=Sl(n>t?e:r,i)+(l-1)*i.cols+1+vl(n>t?r:e);return Ut(h,Kt(o,s))}function vl(e,t){return e-1}function Sl(e,t){return t.cols-e}function wl(e,t,i,s,r,n){return wi(t,s,r,n).length===0?"":Ut(Rn(e,t,e,t-mt(t,r),!1,r).length,Kt("D",n))}function wi(e,t,i,s){let r=e-mt(e,i),n=t-mt(t,i),o=Math.abs(r-n)-yl(e,t,i);return Ut(o,Kt(En(e,t),s))}function bl(e,t,i,s,r,n){let o;wi(t,s,r,n).length>0?o=s-mt(s,r):o=t;let l=s,h=Cl(e,t,i,s,r,n);return Ut(Rn(e,o,i,l,h==="C",r).length,Kt(h,n))}function yl(e,t,i){var o;let s=0,r=e-mt(e,i),n=t-mt(t,i);for(let l=0;l<Math.abs(r-n);l++){let h=En(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+h*l))!=null&&o.isWrapped&&s++}return s}function mt(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function Cl(e,t,i,s,r,n){let o;return wi(i,s,r,n).length>0?o=s-mt(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function En(e,t){return e>t?"A":"B"}function Rn(e,t,i,s,r,n){let o=e,l=t,h="";for(;(o!==i||l!==s)&&l>=0&&l<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(l,!1,0,e+1),o=n.cols-1,e=o,l--);return h+n.buffer.translateBufferLineToString(l,!1,e,o)}function Kt(e,t){let i=t?"O":"[";return w.ESC+i+e}function Ut(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var xl=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 hr(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 Ti=50,kl=15,El=50,Rl=500,Bl=" ",Dl=new RegExp(Bl,"g"),_s=class extends U{constructor(e,t,i,s,r,n,o,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new We,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new R),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new R),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new R),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new R),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=a=>this._handleMouseMove(a),this._mouseUpListener=a=>this._handleMouseUp(a),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(a=>this._handleTrim(a)),this._register(this._bufferService.buffers.onBufferActivate(a=>this._handleBufferActivate(a))),this.enable(),this._model=new xl(this._bufferService),this._activeSelectionMode=0,this._register(ee(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(a=>{a.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 i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let l=i.translateBufferLineToString(o,!0,r,n);s.push(l)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),l=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=l:s.push(l)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(Dl," ")).join(Cn?`\r
43
43
  `:`
44
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Ls&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=ar(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=Ms(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-Bi),Bi),t/=Bi,t/Math.abs(t)+Math.round(t*(Cl-1)))}shouldForceSelection(e){return di?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(),xl)}_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&&!(di&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<kl&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=pl(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(n,e[0]),h=l,a=e[0]-l,d=0,c=0,_=0,u=0;if(o.charAt(l)===" "){for(;l>0&&o.charAt(l-1)===" ";)l--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let y=e[0],v=e[0];n.getWidth(y)===0&&(d++,y--),n.getWidth(v)===2&&(c++,v++);let A=n.getString(v).length;for(A>1&&(u+=A-1,h+=A-1);y>0&&l>0&&!this._isCharWordSeparator(n.loadCell(y-1,this._workCell));){n.loadCell(y-1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,y--):T>1&&(_+=T-1,l-=T-1),l--,y--}for(;v<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(v+1,this._workCell));){n.loadCell(v+1,this._workCell);let T=this._workCell.getChars().length;this._workCell.getWidth()===2?(c++,v++):T>1&&(u+=T-1,h+=T-1),h++,v++}}h++;let f=l+a-d+_,p=Math.min(this._bufferService.cols,h-l+d+c-_-u);if(!(!t&&o.slice(l,h).trim()==="")){if(i&&f===0&&n.getCodePoint(0)!==32){let y=r.lines.get(e[1]-1);if(y&&n.isWrapped&&y.getCodePoint(this._bufferService.cols-1)!==32){let v=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(v){let A=this._bufferService.cols-v.start;f-=A,p+=A}}}if(s&&f+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let y=r.lines.get(e[1]+1);if(y!=null&&y.isWrapped&&y.getCodePoint(0)!==32){let v=this._getWordAt([0,e[1]+1],!1,!1,!0);v&&(p+=v.length)}}return{start:f,length:p}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=ar(i,this._bufferService.cols)}};hs=ae([D(3,Me),D(4,mt),D(5,Cs),D(6,Le),D(7,et),D(8,Qe)],hs);var lr=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},hr=class{constructor(){this._color=new lr,this._css=new lr}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},fe=Object.freeze((()=>{let e=[re.toColor("#2e3436"),re.toColor("#cc0000"),re.toColor("#4e9a06"),re.toColor("#c4a000"),re.toColor("#3465a4"),re.toColor("#75507b"),re.toColor("#06989a"),re.toColor("#d3d7cf"),re.toColor("#555753"),re.toColor("#ef2929"),re.toColor("#8ae234"),re.toColor("#fce94f"),re.toColor("#729fcf"),re.toColor("#ad7fa8"),re.toColor("#34e2e2"),re.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ue.toCss(s,r,n),rgba:ue.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ue.toCss(s,s,s),rgba:ue.toRgba(s,s,s)})}return e})()),ct=re.toColor("#ffffff"),Nt=re.toColor("#000000"),cr=re.toColor("#ffffff"),dr=Nt,Tt={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Bl=ct,cs=class extends q{constructor(e){super(),this._optionsService=e,this._contrastCache=new hr,this._halfContrastCache=new hr,this._onChangeColors=this._register(new b),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ct,background:Nt,cursor:cr,cursorAccent:dr,selectionForeground:void 0,selectionBackgroundTransparent:Tt,selectionBackgroundOpaque:Q.blend(Nt,Tt),selectionInactiveBackgroundTransparent:Tt,selectionInactiveBackgroundOpaque:Q.blend(Nt,Tt),scrollbarSliderBackground:Q.opacity(ct,.2),scrollbarSliderHoverBackground:Q.opacity(ct,.4),scrollbarSliderActiveBackground:Q.opacity(ct,.5),overviewRulerBorder:ct,ansi:fe.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=X(e.foreground,ct),t.background=X(e.background,Nt),t.cursor=Q.blend(t.background,X(e.cursor,cr)),t.cursorAccent=Q.blend(t.background,X(e.cursorAccent,dr)),t.selectionBackgroundTransparent=X(e.selectionBackground,Tt),t.selectionBackgroundOpaque=Q.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=X(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Q.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?X(e.selectionForeground,rr):void 0,t.selectionForeground===rr&&(t.selectionForeground=void 0),Q.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Q.opacity(t.selectionBackgroundTransparent,.3)),Q.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Q.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=X(e.scrollbarSliderBackground,Q.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=X(e.scrollbarSliderHoverBackground,Q.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=X(e.scrollbarSliderActiveBackground,Q.opacity(t.foreground,.5)),t.overviewRulerBorder=X(e.overviewRulerBorder,Bl),t.ansi=fe.slice(),t.ansi[0]=X(e.black,fe[0]),t.ansi[1]=X(e.red,fe[1]),t.ansi[2]=X(e.green,fe[2]),t.ansi[3]=X(e.yellow,fe[3]),t.ansi[4]=X(e.blue,fe[4]),t.ansi[5]=X(e.magenta,fe[5]),t.ansi[6]=X(e.cyan,fe[6]),t.ansi[7]=X(e.white,fe[7]),t.ansi[8]=X(e.brightBlack,fe[8]),t.ansi[9]=X(e.brightRed,fe[9]),t.ansi[10]=X(e.brightGreen,fe[10]),t.ansi[11]=X(e.brightYellow,fe[11]),t.ansi[12]=X(e.brightBlue,fe[12]),t.ansi[13]=X(e.brightMagenta,fe[13]),t.ansi[14]=X(e.brightCyan,fe[14]),t.ansi[15]=X(e.brightWhite,fe[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=X(e.extendedAnsi[s],fe[s+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()}}};cs=ae([D(0,Le)],cs);function X(e,t){if(e!==void 0)try{return re.toColor(e)}catch{}return t}var Dl=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Ml=class{constructor(){this._services=new Dl,this._services.set(ys,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=Co(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Ll={trace:0,debug:1,info:2,warn:3,error:4,off:5},Tl="xterm.js: ",ds=class extends q{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=Ll[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":Tl)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};ds=ae([D(0,Le)],ds);var ur=class extends q{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new b),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new b),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new b),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 i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},U=3,de=Object.freeze(new qt),ti=0,Di=2,Ht=class En{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*U);let r=i||We.fromCharData([0,Ur,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*U+0],s=i&2097151;return[this._data[t*U+1],i&2097152?this._combined[t]:s?nt(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*U+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*U+0]=t|2097152|i[2]<<22):this._data[t*U+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*U+0]>>22}hasWidth(t){return this._data[t*U+0]&12582912}getFg(t){return this._data[t*U+1]}getBg(t){return this._data[t*U+2]}hasContent(t){return this._data[t*U+0]&4194303}getCodePoint(t){let i=this._data[t*U+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*U+0]&2097152}getString(t){let i=this._data[t*U+0];return i&2097152?this._combined[t]:i&2097151?nt(i&2097151):""}isProtected(t){return this._data[t*U+2]&536870912}loadCell(t,i){return ti=t*U,i.content=this._data[ti+0],i.fg=this._data[ti+1],i.bg=this._data[ti+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*U+0]=i.content,this._data[t*U+1]=i.fg,this._data[t*U+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*U+0]=i|s<<22,this._data[t*U+1]=r.fg,this._data[t*U+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*U+0];r&2097152?this._combined[t]+=nt(i):r&2097151?(this._combined[t]=nt(r&2097151)+nt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*U+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new We;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new We;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Di<this._data.buffer.byteLength;let s=t*U;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let l=parseInt(r[o],10);l>=t&&delete this._combined[l]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let l=parseInt(n[o],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,s*4*Di<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Di<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new En(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*U+0]&4194303)return t+(this._data[t*U+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*U+0]&4194303||this._data[t*U+2]&50331648)return t+(this._data[t*U+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let a=0;a<U;a++)this._data[(s+h)*U+a]=o[(i+h)*U+a];o[(i+h)*U+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let a=0;a<U;a++)this._data[(s+h)*U+a]=o[(i+h)*U+a];o[(i+h)*U+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let a=parseInt(l[h],10);a>=i&&(this._combined[a-i+s]=t._combined[a])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*U+0],l=o&2097151,h=o&2097152?this._combined[i]:l?nt(l):ot;if(n+=h,r)for(let a=0;a<h.length;++a)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function Pl(e,t,i,s,r,n){let o=[];for(let l=0;l<e.length-1;l++){let h=l,a=e.get(++h);if(!a.isWrapped)continue;let d=[e.get(l)];for(;h<e.length&&a.isWrapped;)d.push(a),a=e.get(++h);if(!n&&s>=l&&s<h){l+=d.length-1;continue}let c=0,_=Ut(d,c,t),u=1,f=0;for(;u<d.length;){let y=Ut(d,u,t),v=y-f,A=i-_,T=Math.min(v,A);d[c].copyCellsFrom(d[u],f,_,T,!1),_+=T,_===i&&(c++,_=0),f+=T,f===y&&(u++,f=0),_===0&&c!==0&&d[c-1].getWidth(i-1)===2&&(d[c].copyCellsFrom(d[c-1],i-1,_++,1,!1),d[c-1].setCell(i-1,r))}d[c].replaceCells(_,i,r);let p=0;for(let y=d.length-1;y>0&&(y>c||d[y].getTrimmedLength()===0);y--)p++;p>0&&(o.push(l+d.length-p),o.push(p)),l+=d.length-1}return o}function Al(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let l=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:l}),o+=l-1,n+=l,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function Il(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Ol(e,t,i){let s=[],r=e.map((h,a)=>Ut(e,a,t)).reduce((h,a)=>h+a),n=0,o=0,l=0;for(;l<r;){if(r-l<i){s.push(r-l);break}n+=i;let h=Ut(e,o,t);n>h&&(n-=h,o++);let a=e[o].getWidth(n-1)===2;a&&n--;let d=a?i-1:i;s.push(d),l+=d}return s}function Ut(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var Rn=class Bn{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Bn._nextId++,this._onDispose=this.register(new b),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),pt(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Rn._nextId=1;var Nl=Rn,ge={},dt=ge.B;ge[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:"≥","{":"π","|":"≠","}":"£","~":"·"};ge.A={"#":"£"};ge.B=void 0;ge[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ge.C=ge[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ge.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ge.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ge.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ge.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ge.E=ge[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ge.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ge.H=ge[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ge["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var _r=4294967295,fr=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=de.clone(),this.savedCharset=dt,this.markers=[],this._nullCell=We.fromCharData([0,Ur,1,0]),this._whitespaceCell=We.fromCharData([0,ot,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ui,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ur(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 li),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 li),this._whitespaceCell}getBlankLine(e,t){return new Ht(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>_r?_r:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=de);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 ur(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(de),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)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 Ht(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Ht(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),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 n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.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 i=this._optionsService.rawOptions.reflowCursorLine,s=Pl(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(de),i);if(s.length>0){let r=Al(this.lines,s);Il(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(de),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Ht(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(de),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),h.unshift(l);if(!i){let T=this.ybase+this.y;if(T>=o&&T<o+h.length)continue}let a=h[h.length-1].getTrimmedLength(),d=Ol(h,this._cols,e),c=d.length-h.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+c):_=Math.max(0,this.lines.length-this.lines.maxLength+c);let u=[];for(let T=0;T<c;T++){let L=this.getBlankLine(de,!0);u.push(L)}u.length>0&&(r.push({start:o+h.length+n,newLines:u}),n+=u.length),h.push(...u);let f=d.length-1,p=d[f];p===0&&(f--,p=d[f]);let y=h.length-c-1,v=a;for(;y>=0;){let T=Math.min(v,p);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[y],v-T,p-T,T,!0),p-=T,p===0&&(f--,p=d[f]),v-=T,v===0){y--;let L=Math.max(y,0);v=Ut(h,L,this._cols)}}for(let T=0;T<h.length;T++)d[T]<e&&h[T].setCell(d[T],s);let A=c-_;for(;A-- >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+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+c,this.ybase+t-1)}if(r.length>0){let o=[],l=[];for(let p=0;p<this.lines.length;p++)l.push(this.lines.get(p));let h=this.lines.length,a=h-1,d=0,c=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let _=0;for(let p=Math.min(this.lines.maxLength-1,h+n-1);p>=0;p--)if(c&&c.start>a+_){for(let y=c.newLines.length-1;y>=0;y--)this.lines.set(p--,c.newLines[y]);p++,o.push({index:a+1,amount:c.newLines.length}),_+=c.newLines.length,c=r[++d]}else this.lines.set(p,l[a--]);let u=0;for(let p=o.length-1;p>=0;p--)o[p].index+=u,this.lines.onInsertEmitter.fire(o[p]),u+=o[p].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}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 Nl(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Hl=class extends q{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new b),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 fr(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new fr(!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)}},Dn=2,Mn=1,us=class extends q{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new b),this.onResize=this._onResize.event,this._onScroll=this._register(new b),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Dn),this.rows=Math.max(e.rawOptions.rows||0,Mn),this.buffers=this._register(new Hl(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};us=ae([D(0,Le)],us);var wt={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:di,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},zl=["normal","bold","100","200","300","400","500","600","700","800","900"],Fl=class extends q{constructor(e){super(),this._onOptionChange=this._register(new b),this.onOptionChange=this._onOptionChange.event;let t={...wt};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(te(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in wt))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in wt))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=wt[e]),!Wl(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=wt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=zl.includes(t)?t:wt[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 Wl(e){return e==="block"||e==="underline"||e==="bar"}function zt(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&zt(e[s],t-1);return i}var pr=Object.freeze({insertMode:!1}),gr=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),_s=class extends q{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new b),this.onData=this._onData.event,this._onUserInput=this._register(new b),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new b),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new b),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=zt(pr),this.decPrivateModes=zt(gr)}reset(){this.modes=zt(pr),this.decPrivateModes=zt(gr)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.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))}};_s=ae([D(0,Me),D(1,Xr),D(2,Le)],_s);var mr={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 Mi(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Li=String.fromCharCode,vr={DEFAULT:e=>{let t=[Mi(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Li(t[0])}${Li(t[1])}${Li(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Mi(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Mi(e,!0)};${e.x};${e.y}${t}`}},fs=class extends q{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new b),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(mr))this.addProtocol(s,mr[s]);for(let s of Object.keys(vr))this.addEncoding(s,vr[s]);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,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_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,i){if(i){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)}};fs=ae([D(0,Me),D(1,mt),D(2,Le)],fs);var Ti=[[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]],$l=[[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]],pe;function Kl(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var Ul=class{constructor(){if(this.version="6",!pe){pe=new Uint8Array(65536),pe.fill(1),pe[0]=0,pe.fill(0,1,32),pe.fill(0,127,160),pe.fill(2,4352,4448),pe[9001]=2,pe[9002]=2,pe.fill(2,11904,42192),pe[12351]=1,pe.fill(2,44032,55204),pe.fill(2,63744,64256),pe.fill(2,65040,65050),pe.fill(2,65072,65136),pe.fill(2,65280,65377),pe.fill(2,65504,65511);for(let e=0;e<Ti.length;++e)pe.fill(0,Ti[e][0],Ti[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?pe[e]:Kl(e,$l)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=ut.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return ut.createPropertyValue(0,i,s)}},ut=class ai{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new b,this.onChange=this._onChange.event;let t=new Ul;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,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?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 i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let a=t.charCodeAt(n);56320<=a&&a<=57343?o=(o-55296)*1024+a-56320+65536:i+=this.wcwidth(a)}let l=this.charProperties(o,s),h=ai.extractWidth(l);ai.extractShouldJoin(l)&&(h-=ai.extractWidth(s)),i+=h,s=l}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},ql=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 Sr(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var Pt=2147483647,jl=256,Ln=class ps{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>jl)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new ps;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new ps(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 i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}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>Pt?Pt: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>Pt?Pt:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,Pt):t}},At=[],Vl=class{constructor(){this._state=0,this._active=At,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=At}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=At,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||At,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",pi(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}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 i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=At,this._id=-1,this._state=0}}},Oe=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=pi(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},It=[],Yl=class{constructor(){this._handlers=Object.create(null),this._active=It,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=It}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=It,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||It,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",pi(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=It,this._ident=0}},Ft=new Ln;Ft.addParam(0);var wr=class{constructor(e){this._handler=e,this._data="",this._params=Ft,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ft,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=pi(e,t,i),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(i=>(this._params=Ft,this._data="",this._hitLimit=!1,i));return this._params=Ft,this._data="",this._hitLimit=!1,t}},Xl=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},Fe=160,Gl=(function(){let e=new Xl(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),i=(l,h)=>t.slice(l,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Fe,0,2,0),e.add(Fe,8,5,8),e.add(Fe,6,0,6),e.add(Fe,11,0,11),e.add(Fe,13,13,13),e})(),Jl=class extends q{constructor(e=Gl){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 Ln,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},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(te(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Vl),this._dcsParser=this._register(new Yl),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>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 r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===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(i===!1&&h>-1){for(;h>=0&&(o=l[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=l[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l<t;++l){switch(s=e[l],r=this._transitions.table[this.currentState<<8|(s<160?s:Fe)],r>>4){case 2:for(let _=l+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<Fe){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fe){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fe){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fe){this._printHandler(e,l,_),l=_-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],a=h?h.length-1:-1;for(;a>=0&&(o=h[a](this._params),o!==!0);a--)if(o instanceof Promise)return this._preserveStack(3,h,a,r,l),o;a<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++l<t&&(s=e[l])>47&&s<60);l--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let d=this._escHandlers[this._collect<<8|s],c=d?d.length-1:-1;for(;c>=0&&(o=d[c](),o!==!0);c--)if(o instanceof Promise)return this._preserveStack(4,d,c,r,l),o;c<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let _=l+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<Fe){this._dcsParser.put(e,l,_),l=_-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,l),o;s===27&&(r|=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 _=l+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<Fe){this._oscParser.put(e,l,_),l=_-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,l),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},Zl=/^([\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})$/,Ql=/^[\da-f]+$/;function br(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Zl.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Ql.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Pi(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function eh(e,t=16){let[i,s,r]=e;return`rgb:${Pi(i,t)}/${Pi(s,t)}/${Pi(r,t)}`}var th={"(":0,")":1,"*":2,"+":3,"-":1,".":2},rt=131072,yr=10;function Cr(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 xr=5e3,kr=0,ih=class extends q{constructor(e,t,i,s,r,n,o,l,h=new Jl){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new bo,this._utf8Decoder=new yo,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=de.clone(),this._eraseAttrDataInternal=de.clone(),this._onRequestBell=this._register(new b),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new b),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new b),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new b),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new b),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new b),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new b),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new b),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new b),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new b),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new b),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new b),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new b),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 gs(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(a=>this._activeBuffer=a.activeBuffer)),this._parser.setCsiHandlerFallback((a,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(a),params:d.toArray()})}),this._parser.setEscHandlerFallback(a=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(a)})}),this._parser.setExecuteHandlerFallback(a=>{this._logService.debug("Unknown EXECUTE code: ",{code:a})}),this._parser.setOscHandlerFallback((a,d,c)=>{this._logService.debug("Unknown OSC code: ",{identifier:a,action:d,data:c})}),this._parser.setDcsHandlerFallback((a,d,c)=>{d==="HOOK"&&(c=c.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(a),action:d,payload:c})}),this._parser.setPrintHandler((a,d,c)=>this.print(a,d,c)),this._parser.registerCsiHandler({final:"@"},a=>this.insertChars(a)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},a=>this.scrollLeft(a)),this._parser.registerCsiHandler({final:"A"},a=>this.cursorUp(a)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},a=>this.scrollRight(a)),this._parser.registerCsiHandler({final:"B"},a=>this.cursorDown(a)),this._parser.registerCsiHandler({final:"C"},a=>this.cursorForward(a)),this._parser.registerCsiHandler({final:"D"},a=>this.cursorBackward(a)),this._parser.registerCsiHandler({final:"E"},a=>this.cursorNextLine(a)),this._parser.registerCsiHandler({final:"F"},a=>this.cursorPrecedingLine(a)),this._parser.registerCsiHandler({final:"G"},a=>this.cursorCharAbsolute(a)),this._parser.registerCsiHandler({final:"H"},a=>this.cursorPosition(a)),this._parser.registerCsiHandler({final:"I"},a=>this.cursorForwardTab(a)),this._parser.registerCsiHandler({final:"J"},a=>this.eraseInDisplay(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},a=>this.eraseInDisplay(a,!0)),this._parser.registerCsiHandler({final:"K"},a=>this.eraseInLine(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},a=>this.eraseInLine(a,!0)),this._parser.registerCsiHandler({final:"L"},a=>this.insertLines(a)),this._parser.registerCsiHandler({final:"M"},a=>this.deleteLines(a)),this._parser.registerCsiHandler({final:"P"},a=>this.deleteChars(a)),this._parser.registerCsiHandler({final:"S"},a=>this.scrollUp(a)),this._parser.registerCsiHandler({final:"T"},a=>this.scrollDown(a)),this._parser.registerCsiHandler({final:"X"},a=>this.eraseChars(a)),this._parser.registerCsiHandler({final:"Z"},a=>this.cursorBackwardTab(a)),this._parser.registerCsiHandler({final:"`"},a=>this.charPosAbsolute(a)),this._parser.registerCsiHandler({final:"a"},a=>this.hPositionRelative(a)),this._parser.registerCsiHandler({final:"b"},a=>this.repeatPrecedingCharacter(a)),this._parser.registerCsiHandler({final:"c"},a=>this.sendDeviceAttributesPrimary(a)),this._parser.registerCsiHandler({prefix:">",final:"c"},a=>this.sendDeviceAttributesSecondary(a)),this._parser.registerCsiHandler({final:"d"},a=>this.linePosAbsolute(a)),this._parser.registerCsiHandler({final:"e"},a=>this.vPositionRelative(a)),this._parser.registerCsiHandler({final:"f"},a=>this.hVPosition(a)),this._parser.registerCsiHandler({final:"g"},a=>this.tabClear(a)),this._parser.registerCsiHandler({final:"h"},a=>this.setMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"h"},a=>this.setModePrivate(a)),this._parser.registerCsiHandler({final:"l"},a=>this.resetMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"l"},a=>this.resetModePrivate(a)),this._parser.registerCsiHandler({final:"m"},a=>this.charAttributes(a)),this._parser.registerCsiHandler({final:"n"},a=>this.deviceStatus(a)),this._parser.registerCsiHandler({prefix:"?",final:"n"},a=>this.deviceStatusPrivate(a)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},a=>this.softReset(a)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},a=>this.setCursorStyle(a)),this._parser.registerCsiHandler({final:"r"},a=>this.setScrollRegion(a)),this._parser.registerCsiHandler({final:"s"},a=>this.saveCursor(a)),this._parser.registerCsiHandler({final:"t"},a=>this.windowOptions(a)),this._parser.registerCsiHandler({final:"u"},a=>this.restoreCursor(a)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},a=>this.insertColumns(a)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},a=>this.deleteColumns(a)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},a=>this.selectProtected(a)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},a=>this.requestMode(a,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},a=>this.requestMode(a,!1)),this._parser.setExecuteHandler(S.BEL,()=>this.bell()),this._parser.setExecuteHandler(S.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(S.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(S.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(S.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(S.BS,()=>this.backspace()),this._parser.setExecuteHandler(S.HT,()=>this.tab()),this._parser.setExecuteHandler(S.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(S.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ni.IND,()=>this.index()),this._parser.setExecuteHandler(ni.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ni.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Oe(a=>(this.setTitle(a),this.setIconName(a),!0))),this._parser.registerOscHandler(1,new Oe(a=>this.setIconName(a))),this._parser.registerOscHandler(2,new Oe(a=>this.setTitle(a))),this._parser.registerOscHandler(4,new Oe(a=>this.setOrReportIndexedColor(a))),this._parser.registerOscHandler(8,new Oe(a=>this.setHyperlink(a))),this._parser.registerOscHandler(10,new Oe(a=>this.setOrReportFgColor(a))),this._parser.registerOscHandler(11,new Oe(a=>this.setOrReportBgColor(a))),this._parser.registerOscHandler(12,new Oe(a=>this.setOrReportCursorColor(a))),this._parser.registerOscHandler(104,new Oe(a=>this.restoreIndexedColor(a))),this._parser.registerOscHandler(110,new Oe(a=>this.restoreFgColor(a))),this._parser.registerOscHandler(111,new Oe(a=>this.restoreBgColor(a))),this._parser.registerOscHandler(112,new Oe(a=>this.restoreCursorColor(a))),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 a in ge)this._parser.registerEscHandler({intermediates:"(",final:a},()=>this.selectCharset("("+a)),this._parser.registerEscHandler({intermediates:")",final:a},()=>this.selectCharset(")"+a)),this._parser.registerEscHandler({intermediates:"*",final:a},()=>this.selectCharset("*"+a)),this._parser.registerEscHandler({intermediates:"+",final:a},()=>this.selectCharset("+"+a)),this._parser.registerEscHandler({intermediates:"-",final:a},()=>this.selectCharset("-"+a)),this._parser.registerEscHandler({intermediates:".",final:a},()=>this.selectCharset("."+a)),this._parser.registerEscHandler({intermediates:"/",final:a},()=>this.selectCharset("/"+a));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(a=>(this._logService.error("Parsing error: ",a),a)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new wr((a,d)=>this.requestStatusString(a,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),xr))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${xr} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>rt&&(n=this._parseStack.position+rt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,a=>String.fromCharCode(a)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(a=>a.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<rt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,rt))),o||this._dirtyRowTracker.clearRange(),e.length>rt)for(let a=n;a<e.length;a+=rt){let d=a+rt<e.length?a+rt:e.length,c=typeof e=="string"?this._stringDecoder.decode(e.substring(a,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(a,d),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,c))return this._preserveStack(s,r,c,a),this._logSlowResolvingAsync(i),i}else if(!o){let a=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,a))return this._preserveStack(s,r,a,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&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,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,a=this._coreService.modes.insertMode,d=this._curAttrData,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&c.getWidth(this._activeBuffer.x-1)===2&&c.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let _=this._parser.precedingJoinState;for(let u=t;u<i;++u){if(s=e[u],s<127&&n){let v=n[String.fromCharCode(s)];v&&(s=v.charCodeAt(0))}let f=this._unicodeService.charProperties(s,_);r=ut.extractWidth(f);let p=ut.extractShouldJoin(f),y=p?ut.extractWidth(_):0;if(_=f,o&&this._onA11yChar.fire(nt(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-y>l){if(h){let v=c,A=this._activeBuffer.x-y;for(this._activeBuffer.x=y,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),c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),y>0&&c instanceof Ht&&c.copyCellsFrom(v,A,0,y,!1);A<l;)v.setCellFromCodepoint(A++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(p&&this._activeBuffer.x){let v=c.getWidth(this._activeBuffer.x-1)?1:2;c.addCodepointToCell(this._activeBuffer.x-v,s,r);for(let A=r-y;--A>=0;)c.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(a&&(c.insertCells(this._activeBuffer.x,r-y,this._activeBuffer.getNullCell(d)),c.getWidth(l-1)===2&&c.setCellFromCodepoint(l-1,0,1,d)),c.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)c.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=_,this._activeBuffer.x<l&&i-t>0&&c.getWidth(this._activeBuffer.x)===0&&!c.hasContent(this._activeBuffer.x)&&c.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Cr(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new wr(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Oe(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,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,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}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 i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,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}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(de));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=e.params[0]||1,s=ut.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),l=0;for(let a=0;a<n.length;){let d=n.codePointAt(a)||0;o[l++]=d,a+=d>65535?2:1}let h=l;for(let a=1;a<i;++a)o.copyWithin(h,0,l),h+=l;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(S.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(S.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(S.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(S.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(S.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,dt),this._charsetService.setgCharset(1,dt),this._charsetService.setgCharset(2,dt),this._charsetService.setgCharset(3,dt);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){(p=>(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:a,alt:d}=l,c=this._optionsService.rawOptions,_=(p,y)=>(o.triggerDataEvent(`${S.ESC}[${t?"":"?"}${p};${y}$y`),!0),u=p=>p?1:2,f=e.params[0];return t?f===2?_(f,4):f===4?_(f,u(o.modes.insertMode)):f===12?_(f,3):f===20?_(f,u(c.convertEol)):_(f,0):f===1?_(f,u(s.applicationCursorKeys)):f===3?_(f,c.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?_(f,u(s.origin)):f===7?_(f,u(s.wraparound)):f===8?_(f,3):f===9?_(f,u(r==="X10")):f===12?_(f,u(c.cursorBlink)):f===25?_(f,u(!o.isCursorHidden)):f===45?_(f,u(s.reverseWraparound)):f===66?_(f,u(s.applicationKeypad)):f===67?_(f,4):f===1e3?_(f,u(r==="VT200")):f===1002?_(f,u(r==="DRAG")):f===1003?_(f,u(r==="ANY")):f===1004?_(f,u(s.sendFocus)):f===1005?_(f,4):f===1006?_(f,u(n==="SGR")):f===1015?_(f,4):f===1016?_(f,u(n==="SGR_PIXELS")):f===1048?_(f,1):f===47||f===1047||f===1049?_(f,u(a===d)):f===2004?_(f,u(s.bracketedPasteMode)):f===2026?_(f,u(s.synchronizedOutput)):_(f,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=qt.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),l=0;do s[1]===5&&(r=1),s[n+l+1+r]=o[l];while(++l<o.length&&l+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_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=de.fg,e.bg=de.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,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=de.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=de.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=de.fg&16777215,s.bg&=-67108864,s.bg|=de.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${S.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${S.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${S.ESC}[?${t};${i}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=de.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 i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Cr(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(`${S.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>yr&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>yr&&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=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Er(n))if(r==="?")t.push({type:0,index:n});else{let o=br(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=br(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}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=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Er(r)&&t.push({type:2,index:r})}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,dt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(th[e[0]],ge[e[1]]||dt),!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=de.clone(),this._eraseAttrDataInternal=de.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 We;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 i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${S.ESC}${o}${S.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},gs=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&&(kr=e,e=t,t=kr),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};gs=ae([D(0,Me)],gs);function Er(e){return 0<=e&&e<256}var sh=5e7,Rr=12,rh=50,nh=class extends q{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 b),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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>sh)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 i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=l=>performance.now()-i>=Rr?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(i,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Rr)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>rh&&(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()}},ms=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 i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}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 i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};ms=ae([D(0,Me)],ms);var Br=!1,oh=class extends q{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new yt),this._onBinary=this._register(new b),this.onBinary=this._onBinary.event,this._onData=this._register(new b),this.onData=this._onData.event,this._onLineFeed=this._register(new b),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new b),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new b),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new b),this._instantiationService=new Ml,this.optionsService=this._register(new Fl(e)),this._instantiationService.setService(Le,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(us)),this._instantiationService.setService(Me,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ds)),this._instantiationService.setService(Xr,this._logService),this.coreService=this._register(this._instantiationService.createInstance(_s)),this._instantiationService.setService(mt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(fs)),this._instantiationService.setService(Yr,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ut)),this._instantiationService.setService(Eo,this.unicodeService),this._charsetService=this._instantiationService.createInstance(ql),this._instantiationService.setService(ko,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ms),this._instantiationService.setService(Gr,this._oscLinkService),this._inputHandler=this._register(new ih(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ke.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ke.forward(this._bufferService.onResize,this._onResize)),this._register(ke.forward(this.coreService.onData,this._onData)),this._register(ke.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 nh((t,i)=>this._inputHandler.parse(t,i))),this._register(ke.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new b),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&&!Br&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Br=!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,Dn),t=Math.max(t,Mn),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(Sr.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Sr(this._bufferService),!1))),this._windowsWrappingHeuristics.value=te(()=>{for(let t of e)t.dispose()})}}},ah={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 lh(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(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?r.key=S.ESC+"OA":r.key=S.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=S.ESC+"OD":r.key=S.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=S.ESC+"OC":r.key=S.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=S.ESC+"OB":r.key=S.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":S.DEL,e.altKey&&(r.key=S.ESC+r.key);break;case 9:if(e.shiftKey){r.key=S.ESC+"[Z";break}r.key=S.HT,r.cancel=!0;break;case 13:r.key=e.altKey?S.ESC+S.CR:S.CR,r.cancel=!0;break;case 27:r.key=S.ESC,e.altKey&&(r.key=S.ESC+S.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=S.ESC+"[1;"+(n+1)+"D":t?r.key=S.ESC+"OD":r.key=S.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=S.ESC+"[1;"+(n+1)+"C":t?r.key=S.ESC+"OC":r.key=S.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=S.ESC+"[1;"+(n+1)+"A":t?r.key=S.ESC+"OA":r.key=S.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=S.ESC+"[1;"+(n+1)+"B":t?r.key=S.ESC+"OB":r.key=S.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=S.ESC+"[2~");break;case 46:n?r.key=S.ESC+"[3;"+(n+1)+"~":r.key=S.ESC+"[3~";break;case 36:n?r.key=S.ESC+"[1;"+(n+1)+"H":t?r.key=S.ESC+"OH":r.key=S.ESC+"[H";break;case 35:n?r.key=S.ESC+"[1;"+(n+1)+"F":t?r.key=S.ESC+"OF":r.key=S.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=S.ESC+"[5;"+(n+1)+"~":r.key=S.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=S.ESC+"[6;"+(n+1)+"~":r.key=S.ESC+"[6~";break;case 112:n?r.key=S.ESC+"[1;"+(n+1)+"P":r.key=S.ESC+"OP";break;case 113:n?r.key=S.ESC+"[1;"+(n+1)+"Q":r.key=S.ESC+"OQ";break;case 114:n?r.key=S.ESC+"[1;"+(n+1)+"R":r.key=S.ESC+"OR";break;case 115:n?r.key=S.ESC+"[1;"+(n+1)+"S":r.key=S.ESC+"OS";break;case 116:n?r.key=S.ESC+"[15;"+(n+1)+"~":r.key=S.ESC+"[15~";break;case 117:n?r.key=S.ESC+"[17;"+(n+1)+"~":r.key=S.ESC+"[17~";break;case 118:n?r.key=S.ESC+"[18;"+(n+1)+"~":r.key=S.ESC+"[18~";break;case 119:n?r.key=S.ESC+"[19;"+(n+1)+"~":r.key=S.ESC+"[19~";break;case 120:n?r.key=S.ESC+"[20;"+(n+1)+"~":r.key=S.ESC+"[20~";break;case 121:n?r.key=S.ESC+"[21;"+(n+1)+"~":r.key=S.ESC+"[21~";break;case 122:n?r.key=S.ESC+"[23;"+(n+1)+"~":r.key=S.ESC+"[23~";break;case 123:n?r.key=S.ESC+"[24;"+(n+1)+"~":r.key=S.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=S.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=S.DEL:e.keyCode===219?r.key=S.ESC:e.keyCode===220?r.key=S.FS:e.keyCode===221&&(r.key=S.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let l=(o=ah[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(l)r.key=S.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,a=String.fromCharCode(h);e.shiftKey&&(a=a.toUpperCase()),r.key=S.ESC+a}else if(e.keyCode===32)r.key=S.ESC+(e.ctrlKey?S.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=S.ESC+h,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=S.US),e.key==="@"&&(r.key=S.NUL));break}return r}var ce=0,hh=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ui,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ui,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((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,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||(ce=this._search(t),ce===-1)||this._getKey(this._array[ce])!==t)return!1;do if(this._array[ce]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ce),!0;while(++ce<this._array.length&&this._getKey(this._array[ce])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,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&&(ce=this._search(e),!(ce<0||ce>=this._array.length)&&this._getKey(this._array[ce])===e))do yield this._array[ce];while(++ce<this._array.length&&this._getKey(this._array[ce])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ce=this._search(e),!(ce<0||ce>=this._array.length)&&this._getKey(this._array[ce])===e))do t(this._array[ce]);while(++ce<this._array.length&&this._getKey(this._array[ce])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Ai=0,Dr=0,ch=class extends q{constructor(){super(),this._decorations=new hh(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new b),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new b),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(te(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new dh(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{Ai=r.options.x??0,Dr=Ai+(r.options.width??1),e>=Ai&&e<Dr&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},dh=class extends at{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new b),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new b),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=re.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=re.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},uh=1e3,_h=class{constructor(e,t=uh){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_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)}},Mr=20,_i=class extends q{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,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=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new _h(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
45
- `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(z(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(te(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Mr+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
46
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Mr+1&&(this._liveRegion.textContent+=Ni.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 i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],l=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),a=this._rowElements[r];a&&(l.length===0?(a.textContent=" ",this._rowColumns.set(a,[0,1])):(a.textContent=l,this._rowColumns.set(a,o)),a.setAttribute("aria-posinset",h),a.setAttribute("aria-setsize",s),this._alignRowWidth(a))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,l;if(t===0?(o=i,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=i,this._rowContainer.removeChild(o)),o.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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((l=s.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:a})=>{let d=h instanceof Text?h.parentNode:h,c=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(c))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(d);if(!_)return console.warn("columns is null. Race condition?"),null;let u=a<_.length?_[a]:_.slice(-1)[0]+1;return u>=this._terminal.cols&&(++c,u=0),{row:c,column:u}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.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 r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};_i=ae([D(1,ys),D(2,Qe),D(3,et)],_i);var vs=class extends q{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new b),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new b),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(te(()=>{var n;pt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(z(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(z(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(z(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(z(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 i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.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 s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,l=>{var a,d;if(this._isMouseOut)return;let h=l==null?void 0:l.map(c=>({link:c}));(a=this._activeProviderReplies)==null||a.set(n,h),i=this._checkLinkProviderResult(n,e,i),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],l=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let a=l;a<=h;a++){if(i.has(a)){r.splice(n--,1);break}i.add(a)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(l=>this._linkAtPosition(l.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let l=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(l){i=!0,this._handleNewLink(l);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&fh(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,pt(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 i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};vs=ae([D(1,Cs),D(2,et),D(3,Me),D(4,Zr)],vs);function fh(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 ph=class extends oh{constructor(e={}){super(e),this._linkifier=this._register(new yt),this.browser=vn,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new yt),this._onCursorMove=this._register(new b),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new b),this.onKey=this._onKey.event,this._onRender=this._register(new b),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new b),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new b),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new b),this.onBell=this._onBell.event,this._onFocus=this._register(new b),this._onBlur=this._register(new b),this._onA11yCharEmitter=this._register(new b),this._onA11yTabEmitter=this._register(new b),this._onWillOpen=this._register(new b),this._setup(),this._decorationService=this._instantiationService.createInstance(ch),this._instantiationService.setService(jt,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(rl),this._instantiationService.setService(Zr,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(zi)),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(ke.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ke.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ke.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ke.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(te(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.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 i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=Q.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${S.ESC}]${s};${eh(r)}${gn.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ue.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ue.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(_i,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(S.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(S.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(z(this.element,"copy",t=>{this.hasSelection()&&So(t,this._selectionService)}));let e=t=>wo(t,this.textarea,this.coreService,this.optionsService);this._register(z(this.textarea,"paste",e)),this._register(z(this.element,"paste",e)),Sn?this._register(z(this.element,"mousedown",t=>{t.button===2&&Fs(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(z(this.element,"contextmenu",t=>{Fs(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Ls&&this._register(z(this.element,"auxclick",t=>{t.button===1&&Kr(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(z(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(z(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(z(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(z(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(z(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(z(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(z(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;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"),((r=this.element)==null?void 0:r.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(z(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Oi.get()),yn||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(il,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Qe,this._coreBrowserService),this._register(z(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(z(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(os,this._document,this._helperContainer),this._instantiationService.setService(gi,this._charSizeService),this._themeService=this._instantiationService.createInstance(cs),this._instantiationService.setService(Ct,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ci),this._instantiationService.setService(Jr,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(ls,this.rows,this.screenElement)),this._instantiationService.setService(et,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(ss,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(as),this._instantiationService.setService(Cs,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(vs,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(ts,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(hs,this.element,this.screenElement,s)),this._instantiationService.setService(Bo,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(ke.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(is,this.screenElement)),this._register(z(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),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(_i,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(hi,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(hi,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ns,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var a,d,c,_,u;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let l,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,l=n.button<3?n.button:3;break;case"mousedown":h=1,l=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let f=n.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(n,(_=(c=(d=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:d.device)==null?void 0:c.cell)==null?void 0:_.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return!1;h=f<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:l,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(z(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(z(t,"wheel",n=>{var o,l,h,a,d;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(a=(h=(l=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:a.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(n,!0);let c=S.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(c,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.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){$r(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,i){this._selectionService.setSelection(e,t,i)}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 i;(i=this._selectionService)==null||i.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 i=lh(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===S.ETX||i.key===S.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(gh(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 i;(i=this._charSizeService)==null||i.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(de));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(S.ESC+"[I"):this.coreService.triggerDataEvent(S.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${S.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${S.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function gh(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var mh=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},vh=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 We)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Lr=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 vh(t)}getNullCell(){return new We}},Sh=class extends q{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new b),this.onBufferChange=this._onBufferChange.event,this._normal=new Lr(this._core.buffers.normal,"normal"),this._alternate=new Lr(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)}},wh=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.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)}},bh=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}},yh=["cols","rows"],qe=0,Ch=class extends q{constructor(e){super(),this._core=this._register(new ph(e)),this._addonManager=this._register(new mh),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(yh.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 wh(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new bh(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 Sh(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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
47
- `,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 Oi.get()},set promptLabel(e){Oi.set(e)},get tooMuchOutput(){return Ni.get()},set tooMuchOutput(e){Ni.set(e)}}}_verifyIntegers(...e){for(qe of e)if(qe===1/0||isNaN(qe)||qe%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qe of e)if(qe&&(qe===1/0||isNaN(qe)||qe%1!==0||qe<0))throw new Error("This API only accepts positive integers")}};const xh=Object.freeze(Object.defineProperty({__proto__:null,Terminal:Ch},Symbol.toStringTag,{value:"Module"})),kh=qn(xh);var Tr;function Eh(){if(Tr)return Xt;Tr=1;var e=jn(),t=kh,i=Vn();document.head.appendChild(document.createElement("style")).textContent=`/**
44
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Is&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=hr(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=As(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-Ti),Ti),t/=Ti,t/Math.abs(t)+Math.round(t*(kl-1)))}shouldForceSelection(e){return _i?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(),El)}_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&&!(_i&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<Rl&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=ml(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(n,e[0]),h=l,a=e[0]-l,d=0,c=0,_=0,u=0;if(o.charAt(l)===" "){for(;l>0&&o.charAt(l-1)===" ";)l--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let b=e[0],g=e[0];n.getWidth(b)===0&&(d++,b--),n.getWidth(g)===2&&(c++,g++);let T=n.getString(g).length;for(T>1&&(u+=T-1,h+=T-1);b>0&&l>0&&!this._isCharWordSeparator(n.loadCell(b-1,this._workCell));){n.loadCell(b-1,this._workCell);let D=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,b--):D>1&&(_+=D-1,l-=D-1),l--,b--}for(;g<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(g+1,this._workCell));){n.loadCell(g+1,this._workCell);let D=this._workCell.getChars().length;this._workCell.getWidth()===2?(c++,g++):D>1&&(u+=D-1,h+=D-1),h++,g++}}h++;let f=l+a-d+_,p=Math.min(this._bufferService.cols,h-l+d+c-_-u);if(!(!t&&o.slice(l,h).trim()==="")){if(i&&f===0&&n.getCodePoint(0)!==32){let b=r.lines.get(e[1]-1);if(b&&n.isWrapped&&b.getCodePoint(this._bufferService.cols-1)!==32){let g=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(g){let T=this._bufferService.cols-g.start;f-=T,p+=T}}}if(s&&f+p===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let b=r.lines.get(e[1]+1);if(b!=null&&b.isWrapped&&b.getCodePoint(0)!==32){let g=this._getWordAt([0,e[1]+1],!1,!1,!0);g&&(p+=g.length)}}return{start:f,length:p}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=hr(i,this._bufferService.cols)}};_s=le([L(3,Le),L(4,vt),L(5,Rs),L(6,Te),L(7,et),L(8,Qe)],_s);var cr=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},dr=class{constructor(){this._color=new cr,this._css=new cr}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},pe=Object.freeze((()=>{let e=[re.toColor("#2e3436"),re.toColor("#cc0000"),re.toColor("#4e9a06"),re.toColor("#c4a000"),re.toColor("#3465a4"),re.toColor("#75507b"),re.toColor("#06989a"),re.toColor("#d3d7cf"),re.toColor("#555753"),re.toColor("#ef2929"),re.toColor("#8ae234"),re.toColor("#fce94f"),re.toColor("#729fcf"),re.toColor("#ad7fa8"),re.toColor("#34e2e2"),re.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ue.toCss(s,r,n),rgba:ue.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ue.toCss(s,s,s),rgba:ue.toRgba(s,s,s)})}return e})()),dt=re.toColor("#ffffff"),Ht=re.toColor("#000000"),ur=re.toColor("#ffffff"),_r=Ht,Pt={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Ml=dt,fs=class extends U{constructor(e){super(),this._optionsService=e,this._contrastCache=new dr,this._halfContrastCache=new dr,this._onChangeColors=this._register(new R),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:dt,background:Ht,cursor:ur,cursorAccent:_r,selectionForeground:void 0,selectionBackgroundTransparent:Pt,selectionBackgroundOpaque:Z.blend(Ht,Pt),selectionInactiveBackgroundTransparent:Pt,selectionInactiveBackgroundOpaque:Z.blend(Ht,Pt),scrollbarSliderBackground:Z.opacity(dt,.2),scrollbarSliderHoverBackground:Z.opacity(dt,.4),scrollbarSliderActiveBackground:Z.opacity(dt,.5),overviewRulerBorder:dt,ansi:pe.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=X(e.foreground,dt),t.background=X(e.background,Ht),t.cursor=Z.blend(t.background,X(e.cursor,ur)),t.cursorAccent=Z.blend(t.background,X(e.cursorAccent,_r)),t.selectionBackgroundTransparent=X(e.selectionBackground,Pt),t.selectionBackgroundOpaque=Z.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=X(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Z.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?X(e.selectionForeground,or):void 0,t.selectionForeground===or&&(t.selectionForeground=void 0),Z.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Z.opacity(t.selectionBackgroundTransparent,.3)),Z.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Z.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=X(e.scrollbarSliderBackground,Z.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=X(e.scrollbarSliderHoverBackground,Z.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=X(e.scrollbarSliderActiveBackground,Z.opacity(t.foreground,.5)),t.overviewRulerBorder=X(e.overviewRulerBorder,Ml),t.ansi=pe.slice(),t.ansi[0]=X(e.black,pe[0]),t.ansi[1]=X(e.red,pe[1]),t.ansi[2]=X(e.green,pe[2]),t.ansi[3]=X(e.yellow,pe[3]),t.ansi[4]=X(e.blue,pe[4]),t.ansi[5]=X(e.magenta,pe[5]),t.ansi[6]=X(e.cyan,pe[6]),t.ansi[7]=X(e.white,pe[7]),t.ansi[8]=X(e.brightBlack,pe[8]),t.ansi[9]=X(e.brightRed,pe[9]),t.ansi[10]=X(e.brightGreen,pe[10]),t.ansi[11]=X(e.brightYellow,pe[11]),t.ansi[12]=X(e.brightBlue,pe[12]),t.ansi[13]=X(e.brightMagenta,pe[13]),t.ansi[14]=X(e.brightCyan,pe[14]),t.ansi[15]=X(e.brightWhite,pe[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=X(e.extendedAnsi[s],pe[s+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()}}};fs=le([L(0,Te)],fs);function X(e,t){if(e!==void 0)try{return re.toColor(e)}catch{}return t}var Ll=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Tl=class{constructor(){this._services=new Ll,this._services.set(Es,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=ko(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Pl={trace:0,debug:1,info:2,warn:3,error:4,off:5},Al="xterm.js: ",ps=class extends U{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=Pl[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":Al)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};ps=le([L(0,Te)],ps);var fr=class extends U{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new R),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new R),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new R),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 i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},K=3,de=Object.freeze(new jt),si=0,Pi=2,zt=class Bn{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*K);let r=i||We.fromCharData([0,jr,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*K+0],s=i&2097151;return[this._data[t*K+1],i&2097152?this._combined[t]:s?nt(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*K+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*K+0]=t|2097152|i[2]<<22):this._data[t*K+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*K+0]>>22}hasWidth(t){return this._data[t*K+0]&12582912}getFg(t){return this._data[t*K+1]}getBg(t){return this._data[t*K+2]}hasContent(t){return this._data[t*K+0]&4194303}getCodePoint(t){let i=this._data[t*K+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*K+0]&2097152}getString(t){let i=this._data[t*K+0];return i&2097152?this._combined[t]:i&2097151?nt(i&2097151):""}isProtected(t){return this._data[t*K+2]&536870912}loadCell(t,i){return si=t*K,i.content=this._data[si+0],i.fg=this._data[si+1],i.bg=this._data[si+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*K+0]=i.content,this._data[t*K+1]=i.fg,this._data[t*K+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*K+0]=i|s<<22,this._data[t*K+1]=r.fg,this._data[t*K+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*K+0];r&2097152?this._combined[t]+=nt(i):r&2097151?(this._combined[t]=nt(r&2097151)+nt(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*K+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new We;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new We;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Pi<this._data.buffer.byteLength;let s=t*K;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let l=parseInt(r[o],10);l>=t&&delete this._combined[l]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let l=parseInt(n[o],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,s*4*Pi<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Pi<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,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 i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new Bn(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*K+0]&4194303)return t+(this._data[t*K+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*K+0]&4194303||this._data[t*K+2]&50331648)return t+(this._data[t*K+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let a=0;a<K;a++)this._data[(s+h)*K+a]=o[(i+h)*K+a];o[(i+h)*K+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let a=0;a<K;a++)this._data[(s+h)*K+a]=o[(i+h)*K+a];o[(i+h)*K+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let a=parseInt(l[h],10);a>=i&&(this._combined[a-i+s]=t._combined[a])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*K+0],l=o&2097151,h=o&2097152?this._combined[i]:l?nt(l):ot;if(n+=h,r)for(let a=0;a<h.length;++a)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function Il(e,t,i,s,r,n){let o=[];for(let l=0;l<e.length-1;l++){let h=l,a=e.get(++h);if(!a.isWrapped)continue;let d=[e.get(l)];for(;h<e.length&&a.isWrapped;)d.push(a),a=e.get(++h);if(!n&&s>=l&&s<h){l+=d.length-1;continue}let c=0,_=qt(d,c,t),u=1,f=0;for(;u<d.length;){let b=qt(d,u,t),g=b-f,T=i-_,D=Math.min(g,T);d[c].copyCellsFrom(d[u],f,_,D,!1),_+=D,_===i&&(c++,_=0),f+=D,f===b&&(u++,f=0),_===0&&c!==0&&d[c-1].getWidth(i-1)===2&&(d[c].copyCellsFrom(d[c-1],i-1,_++,1,!1),d[c-1].setCell(i-1,r))}d[c].replaceCells(_,i,r);let p=0;for(let b=d.length-1;b>0&&(b>c||d[b].getTrimmedLength()===0);b--)p++;p>0&&(o.push(l+d.length-p),o.push(p)),l+=d.length-1}return o}function Ol(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let l=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:l}),o+=l-1,n+=l,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function Nl(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Hl(e,t,i){let s=[],r=e.map((h,a)=>qt(e,a,t)).reduce((h,a)=>h+a),n=0,o=0,l=0;for(;l<r;){if(r-l<i){s.push(r-l);break}n+=i;let h=qt(e,o,t);n>h&&(n-=h,o++);let a=e[o].getWidth(n-1)===2;a&&n--;let d=a?i-1:i;s.push(d),l+=d}return s}function qt(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var Dn=class Mn{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Mn._nextId++,this._onDispose=this.register(new R),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),gt(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Dn._nextId=1;var zl=Dn,me={},ut=me.B;me[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:"≥","{":"π","|":"≠","}":"£","~":"·"};me.A={"#":"£"};me.B=void 0;me[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};me.C=me[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};me.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};me.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};me.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};me.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};me.E=me[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};me.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};me.H=me[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};me["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var pr=4294967295,gr=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=de.clone(),this.savedCharset=ut,this.markers=[],this._nullCell=We.fromCharData([0,jr,1,0]),this._whitespaceCell=We.fromCharData([0,ot,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new fi,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new fr(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 ci),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 ci),this._whitespaceCell}getBlankLine(e,t){return new zt(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>pr?pr:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=de);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 fr(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(de),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)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 zt(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new zt(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),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 n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.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 i=this._optionsService.rawOptions.reflowCursorLine,s=Il(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(de),i);if(s.length>0){let r=Ol(this.lines,s);Nl(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(de),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new zt(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(de),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),h.unshift(l);if(!i){let D=this.ybase+this.y;if(D>=o&&D<o+h.length)continue}let a=h[h.length-1].getTrimmedLength(),d=Hl(h,this._cols,e),c=d.length-h.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+c):_=Math.max(0,this.lines.length-this.lines.maxLength+c);let u=[];for(let D=0;D<c;D++){let P=this.getBlankLine(de,!0);u.push(P)}u.length>0&&(r.push({start:o+h.length+n,newLines:u}),n+=u.length),h.push(...u);let f=d.length-1,p=d[f];p===0&&(f--,p=d[f]);let b=h.length-c-1,g=a;for(;b>=0;){let D=Math.min(g,p);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[b],g-D,p-D,D,!0),p-=D,p===0&&(f--,p=d[f]),g-=D,g===0){b--;let P=Math.max(b,0);g=qt(h,P,this._cols)}}for(let D=0;D<h.length;D++)d[D]<e&&h[D].setCell(d[D],s);let T=c-_;for(;T-- >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+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+c,this.ybase+t-1)}if(r.length>0){let o=[],l=[];for(let p=0;p<this.lines.length;p++)l.push(this.lines.get(p));let h=this.lines.length,a=h-1,d=0,c=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let _=0;for(let p=Math.min(this.lines.maxLength-1,h+n-1);p>=0;p--)if(c&&c.start>a+_){for(let b=c.newLines.length-1;b>=0;b--)this.lines.set(p--,c.newLines[b]);p++,o.push({index:a+1,amount:c.newLines.length}),_+=c.newLines.length,c=r[++d]}else this.lines.set(p,l[a--]);let u=0;for(let p=o.length-1;p>=0;p--)o[p].index+=u,this.lines.onInsertEmitter.fire(o[p]),u+=o[p].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}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 zl(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Fl=class extends U{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new R),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 gr(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new gr(!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)}},Ln=2,Tn=1,gs=class extends U{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new R),this.onResize=this._onResize.event,this._onScroll=this._register(new R),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Ln),this.rows=Math.max(e.rawOptions.rows||0,Tn),this.buffers=this._register(new Fl(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};gs=le([L(0,Te)],gs);var wt={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:_i,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Wl=["normal","bold","100","200","300","400","500","600","700","800","900"],$l=class extends U{constructor(e){super(),this._onOptionChange=this._register(new R),this.onOptionChange=this._onOptionChange.event;let t={...wt};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ee(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in wt))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in wt))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=wt[e]),!Kl(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=wt[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Wl.includes(t)?t:wt[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 Kl(e){return e==="block"||e==="underline"||e==="bar"}function Ft(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&Ft(e[s],t-1);return i}var mr=Object.freeze({insertMode:!1}),vr=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),ms=class extends U{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new R),this.onData=this._onData.event,this._onUserInput=this._register(new R),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new R),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new R),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ft(mr),this.decPrivateModes=Ft(vr)}reset(){this.modes=Ft(mr),this.decPrivateModes=Ft(vr)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.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))}};ms=le([L(0,Le),L(1,Jr),L(2,Te)],ms);var Sr={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 Ai(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Ii=String.fromCharCode,wr={DEFAULT:e=>{let t=[Ai(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ii(t[0])}${Ii(t[1])}${Ii(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ai(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ai(e,!0)};${e.x};${e.y}${t}`}},vs=class extends U{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new R),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Sr))this.addProtocol(s,Sr[s]);for(let s of Object.keys(wr))this.addEncoding(s,wr[s]);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,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_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,i){if(i){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)}};vs=le([L(0,Le),L(1,vt),L(2,Te)],vs);var Oi=[[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]],Ul=[[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]],ge;function ql(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var jl=class{constructor(){if(this.version="6",!ge){ge=new Uint8Array(65536),ge.fill(1),ge[0]=0,ge.fill(0,1,32),ge.fill(0,127,160),ge.fill(2,4352,4448),ge[9001]=2,ge[9002]=2,ge.fill(2,11904,42192),ge[12351]=1,ge.fill(2,44032,55204),ge.fill(2,63744,64256),ge.fill(2,65040,65050),ge.fill(2,65072,65136),ge.fill(2,65280,65377),ge.fill(2,65504,65511);for(let e=0;e<Oi.length;++e)ge.fill(0,Oi[e][0],Oi[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ge[e]:ql(e,Ul)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=_t.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return _t.createPropertyValue(0,i,s)}},_t=class hi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new R,this.onChange=this._onChange.event;let t=new jl;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,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?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 i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let a=t.charCodeAt(n);56320<=a&&a<=57343?o=(o-55296)*1024+a-56320+65536:i+=this.wcwidth(a)}let l=this.charProperties(o,s),h=hi.extractWidth(l);hi.extractShouldJoin(l)&&(h-=hi.extractWidth(s)),i+=h,s=l}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Vl=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 br(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var At=2147483647,Yl=256,Pn=class Ss{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>Yl)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Ss;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Ss(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 i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}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>At?At: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>At?At:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,At):t}},It=[],Xl=class{constructor(){this._state=0,this._active=It,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=It}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=It,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||It,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",mi(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}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 i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=It,this._id=-1,this._state=0}}},Ne=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=mi(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Ot=[],Gl=class{constructor(){this._handlers=Object.create(null),this._active=Ot,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ot}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=Ot,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ot,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",mi(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ot,this._ident=0}},Wt=new Pn;Wt.addParam(0);var yr=class{constructor(e){this._handler=e,this._data="",this._params=Wt,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Wt,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=mi(e,t,i),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(i=>(this._params=Wt,this._data="",this._hitLimit=!1,i));return this._params=Wt,this._data="",this._hitLimit=!1,t}},Jl=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},Fe=160,Zl=(function(){let e=new Jl(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),i=(l,h)=>t.slice(l,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Fe,0,2,0),e.add(Fe,8,5,8),e.add(Fe,6,0,6),e.add(Fe,11,0,11),e.add(Fe,13,13,13),e})(),Ql=class extends U{constructor(e=Zl){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 Pn,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},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(ee(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Xl),this._dcsParser=this._register(new Gl),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>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 r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===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(i===!1&&h>-1){for(;h>=0&&(o=l[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=l[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l<t;++l){switch(s=e[l],r=this._transitions.table[this.currentState<<8|(s<160?s:Fe)],r>>4){case 2:for(let _=l+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<Fe){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fe){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fe){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Fe){this._printHandler(e,l,_),l=_-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],a=h?h.length-1:-1;for(;a>=0&&(o=h[a](this._params),o!==!0);a--)if(o instanceof Promise)return this._preserveStack(3,h,a,r,l),o;a<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++l<t&&(s=e[l])>47&&s<60);l--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let d=this._escHandlers[this._collect<<8|s],c=d?d.length-1:-1;for(;c>=0&&(o=d[c](),o!==!0);c--)if(o instanceof Promise)return this._preserveStack(4,d,c,r,l),o;c<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let _=l+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<Fe){this._dcsParser.put(e,l,_),l=_-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,l),o;s===27&&(r|=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 _=l+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<Fe){this._oscParser.put(e,l,_),l=_-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,l),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},eh=/^([\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})$/,th=/^[\da-f]+$/;function Cr(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=eh.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),th.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Ni(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function ih(e,t=16){let[i,s,r]=e;return`rgb:${Ni(i,t)}/${Ni(s,t)}/${Ni(r,t)}`}var sh={"(":0,")":1,"*":2,"+":3,"-":1,".":2},rt=131072,xr=10;function kr(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 Er=5e3,Rr=0,rh=class extends U{constructor(e,t,i,s,r,n,o,l,h=new Ql){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Co,this._utf8Decoder=new xo,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=de.clone(),this._eraseAttrDataInternal=de.clone(),this._onRequestBell=this._register(new R),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new R),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new R),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new R),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new R),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new R),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new R),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new R),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new R),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new R),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new R),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new R),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new R),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 ws(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(a=>this._activeBuffer=a.activeBuffer)),this._parser.setCsiHandlerFallback((a,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(a),params:d.toArray()})}),this._parser.setEscHandlerFallback(a=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(a)})}),this._parser.setExecuteHandlerFallback(a=>{this._logService.debug("Unknown EXECUTE code: ",{code:a})}),this._parser.setOscHandlerFallback((a,d,c)=>{this._logService.debug("Unknown OSC code: ",{identifier:a,action:d,data:c})}),this._parser.setDcsHandlerFallback((a,d,c)=>{d==="HOOK"&&(c=c.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(a),action:d,payload:c})}),this._parser.setPrintHandler((a,d,c)=>this.print(a,d,c)),this._parser.registerCsiHandler({final:"@"},a=>this.insertChars(a)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},a=>this.scrollLeft(a)),this._parser.registerCsiHandler({final:"A"},a=>this.cursorUp(a)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},a=>this.scrollRight(a)),this._parser.registerCsiHandler({final:"B"},a=>this.cursorDown(a)),this._parser.registerCsiHandler({final:"C"},a=>this.cursorForward(a)),this._parser.registerCsiHandler({final:"D"},a=>this.cursorBackward(a)),this._parser.registerCsiHandler({final:"E"},a=>this.cursorNextLine(a)),this._parser.registerCsiHandler({final:"F"},a=>this.cursorPrecedingLine(a)),this._parser.registerCsiHandler({final:"G"},a=>this.cursorCharAbsolute(a)),this._parser.registerCsiHandler({final:"H"},a=>this.cursorPosition(a)),this._parser.registerCsiHandler({final:"I"},a=>this.cursorForwardTab(a)),this._parser.registerCsiHandler({final:"J"},a=>this.eraseInDisplay(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},a=>this.eraseInDisplay(a,!0)),this._parser.registerCsiHandler({final:"K"},a=>this.eraseInLine(a,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},a=>this.eraseInLine(a,!0)),this._parser.registerCsiHandler({final:"L"},a=>this.insertLines(a)),this._parser.registerCsiHandler({final:"M"},a=>this.deleteLines(a)),this._parser.registerCsiHandler({final:"P"},a=>this.deleteChars(a)),this._parser.registerCsiHandler({final:"S"},a=>this.scrollUp(a)),this._parser.registerCsiHandler({final:"T"},a=>this.scrollDown(a)),this._parser.registerCsiHandler({final:"X"},a=>this.eraseChars(a)),this._parser.registerCsiHandler({final:"Z"},a=>this.cursorBackwardTab(a)),this._parser.registerCsiHandler({final:"`"},a=>this.charPosAbsolute(a)),this._parser.registerCsiHandler({final:"a"},a=>this.hPositionRelative(a)),this._parser.registerCsiHandler({final:"b"},a=>this.repeatPrecedingCharacter(a)),this._parser.registerCsiHandler({final:"c"},a=>this.sendDeviceAttributesPrimary(a)),this._parser.registerCsiHandler({prefix:">",final:"c"},a=>this.sendDeviceAttributesSecondary(a)),this._parser.registerCsiHandler({final:"d"},a=>this.linePosAbsolute(a)),this._parser.registerCsiHandler({final:"e"},a=>this.vPositionRelative(a)),this._parser.registerCsiHandler({final:"f"},a=>this.hVPosition(a)),this._parser.registerCsiHandler({final:"g"},a=>this.tabClear(a)),this._parser.registerCsiHandler({final:"h"},a=>this.setMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"h"},a=>this.setModePrivate(a)),this._parser.registerCsiHandler({final:"l"},a=>this.resetMode(a)),this._parser.registerCsiHandler({prefix:"?",final:"l"},a=>this.resetModePrivate(a)),this._parser.registerCsiHandler({final:"m"},a=>this.charAttributes(a)),this._parser.registerCsiHandler({final:"n"},a=>this.deviceStatus(a)),this._parser.registerCsiHandler({prefix:"?",final:"n"},a=>this.deviceStatusPrivate(a)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},a=>this.softReset(a)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},a=>this.setCursorStyle(a)),this._parser.registerCsiHandler({final:"r"},a=>this.setScrollRegion(a)),this._parser.registerCsiHandler({final:"s"},a=>this.saveCursor(a)),this._parser.registerCsiHandler({final:"t"},a=>this.windowOptions(a)),this._parser.registerCsiHandler({final:"u"},a=>this.restoreCursor(a)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},a=>this.insertColumns(a)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},a=>this.deleteColumns(a)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},a=>this.selectProtected(a)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},a=>this.requestMode(a,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},a=>this.requestMode(a,!1)),this._parser.setExecuteHandler(w.BEL,()=>this.bell()),this._parser.setExecuteHandler(w.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(w.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(w.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(w.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(w.BS,()=>this.backspace()),this._parser.setExecuteHandler(w.HT,()=>this.tab()),this._parser.setExecuteHandler(w.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(w.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ai.IND,()=>this.index()),this._parser.setExecuteHandler(ai.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ai.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ne(a=>(this.setTitle(a),this.setIconName(a),!0))),this._parser.registerOscHandler(1,new Ne(a=>this.setIconName(a))),this._parser.registerOscHandler(2,new Ne(a=>this.setTitle(a))),this._parser.registerOscHandler(4,new Ne(a=>this.setOrReportIndexedColor(a))),this._parser.registerOscHandler(8,new Ne(a=>this.setHyperlink(a))),this._parser.registerOscHandler(10,new Ne(a=>this.setOrReportFgColor(a))),this._parser.registerOscHandler(11,new Ne(a=>this.setOrReportBgColor(a))),this._parser.registerOscHandler(12,new Ne(a=>this.setOrReportCursorColor(a))),this._parser.registerOscHandler(104,new Ne(a=>this.restoreIndexedColor(a))),this._parser.registerOscHandler(110,new Ne(a=>this.restoreFgColor(a))),this._parser.registerOscHandler(111,new Ne(a=>this.restoreBgColor(a))),this._parser.registerOscHandler(112,new Ne(a=>this.restoreCursorColor(a))),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 a in me)this._parser.registerEscHandler({intermediates:"(",final:a},()=>this.selectCharset("("+a)),this._parser.registerEscHandler({intermediates:")",final:a},()=>this.selectCharset(")"+a)),this._parser.registerEscHandler({intermediates:"*",final:a},()=>this.selectCharset("*"+a)),this._parser.registerEscHandler({intermediates:"+",final:a},()=>this.selectCharset("+"+a)),this._parser.registerEscHandler({intermediates:"-",final:a},()=>this.selectCharset("-"+a)),this._parser.registerEscHandler({intermediates:".",final:a},()=>this.selectCharset("."+a)),this._parser.registerEscHandler({intermediates:"/",final:a},()=>this.selectCharset("/"+a));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(a=>(this._logService.error("Parsing error: ",a),a)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new yr((a,d)=>this.requestStatusString(a,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Er))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Er} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>rt&&(n=this._parseStack.position+rt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,a=>String.fromCharCode(a)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(a=>a.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<rt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,rt))),o||this._dirtyRowTracker.clearRange(),e.length>rt)for(let a=n;a<e.length;a+=rt){let d=a+rt<e.length?a+rt:e.length,c=typeof e=="string"?this._stringDecoder.decode(e.substring(a,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(a,d),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,c))return this._preserveStack(s,r,c,a),this._logSlowResolvingAsync(i),i}else if(!o){let a=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,a))return this._preserveStack(s,r,a,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&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,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,a=this._coreService.modes.insertMode,d=this._curAttrData,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&c.getWidth(this._activeBuffer.x-1)===2&&c.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let _=this._parser.precedingJoinState;for(let u=t;u<i;++u){if(s=e[u],s<127&&n){let g=n[String.fromCharCode(s)];g&&(s=g.charCodeAt(0))}let f=this._unicodeService.charProperties(s,_);r=_t.extractWidth(f);let p=_t.extractShouldJoin(f),b=p?_t.extractWidth(_):0;if(_=f,o&&this._onA11yChar.fire(nt(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-b>l){if(h){let g=c,T=this._activeBuffer.x-b;for(this._activeBuffer.x=b,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),c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),b>0&&c instanceof zt&&c.copyCellsFrom(g,T,0,b,!1);T<l;)g.setCellFromCodepoint(T++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(p&&this._activeBuffer.x){let g=c.getWidth(this._activeBuffer.x-1)?1:2;c.addCodepointToCell(this._activeBuffer.x-g,s,r);for(let T=r-b;--T>=0;)c.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(a&&(c.insertCells(this._activeBuffer.x,r-b,this._activeBuffer.getNullCell(d)),c.getWidth(l-1)===2&&c.setCellFromCodepoint(l-1,0,1,d)),c.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)c.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=_,this._activeBuffer.x<l&&i-t>0&&c.getWidth(this._activeBuffer.x)===0&&!c.hasContent(this._activeBuffer.x)&&c.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>kr(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new yr(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ne(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,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,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}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 i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,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}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(de));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=e.params[0]||1,s=_t.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),l=0;for(let a=0;a<n.length;){let d=n.codePointAt(a)||0;o[l++]=d,a+=d>65535?2:1}let h=l;for(let a=1;a<i;++a)o.copyWithin(h,0,l),h+=l;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(w.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(w.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(w.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(w.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(w.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,ut),this._charsetService.setgCharset(1,ut),this._charsetService.setgCharset(2,ut),this._charsetService.setgCharset(3,ut);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){(p=>(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:a,alt:d}=l,c=this._optionsService.rawOptions,_=(p,b)=>(o.triggerDataEvent(`${w.ESC}[${t?"":"?"}${p};${b}$y`),!0),u=p=>p?1:2,f=e.params[0];return t?f===2?_(f,4):f===4?_(f,u(o.modes.insertMode)):f===12?_(f,3):f===20?_(f,u(c.convertEol)):_(f,0):f===1?_(f,u(s.applicationCursorKeys)):f===3?_(f,c.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?_(f,u(s.origin)):f===7?_(f,u(s.wraparound)):f===8?_(f,3):f===9?_(f,u(r==="X10")):f===12?_(f,u(c.cursorBlink)):f===25?_(f,u(!o.isCursorHidden)):f===45?_(f,u(s.reverseWraparound)):f===66?_(f,u(s.applicationKeypad)):f===67?_(f,4):f===1e3?_(f,u(r==="VT200")):f===1002?_(f,u(r==="DRAG")):f===1003?_(f,u(r==="ANY")):f===1004?_(f,u(s.sendFocus)):f===1005?_(f,4):f===1006?_(f,u(n==="SGR")):f===1015?_(f,4):f===1016?_(f,u(n==="SGR_PIXELS")):f===1048?_(f,1):f===47||f===1047||f===1049?_(f,u(a===d)):f===2004?_(f,u(s.bracketedPasteMode)):f===2026?_(f,u(s.synchronizedOutput)):_(f,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=jt.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),l=0;do s[1]===5&&(r=1),s[n+l+1+r]=o[l];while(++l<o.length&&l+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_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=de.fg,e.bg=de.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,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=de.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=de.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=de.fg&16777215,s.bg&=-67108864,s.bg|=de.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${w.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${w.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${w.ESC}[?${t};${i}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=de.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 i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!kr(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(`${w.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>xr&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>xr&&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=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Br(n))if(r==="?")t.push({type:0,index:n});else{let o=Cr(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Cr(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}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=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);Br(r)&&t.push({type:2,index:r})}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,ut),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(sh[e[0]],me[e[1]]||ut),!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=de.clone(),this._eraseAttrDataInternal=de.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 We;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 i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${w.ESC}${o}${w.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},ws=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&&(Rr=e,e=t,t=Rr),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ws=le([L(0,Le)],ws);function Br(e){return 0<=e&&e<256}var nh=5e7,Dr=12,oh=50,ah=class extends U{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 R),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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>nh)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 i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=l=>performance.now()-i>=Dr?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(i,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Dr)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>oh&&(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()}},bs=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 i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}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 i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};bs=le([L(0,Le)],bs);var Mr=!1,lh=class extends U{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new yt),this._onBinary=this._register(new R),this.onBinary=this._onBinary.event,this._onData=this._register(new R),this.onData=this._onData.event,this._onLineFeed=this._register(new R),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new R),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new R),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new R),this._instantiationService=new Tl,this.optionsService=this._register(new $l(e)),this._instantiationService.setService(Te,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(gs)),this._instantiationService.setService(Le,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ps)),this._instantiationService.setService(Jr,this._logService),this.coreService=this._register(this._instantiationService.createInstance(ms)),this._instantiationService.setService(vt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(vs)),this._instantiationService.setService(Gr,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(_t)),this._instantiationService.setService(Bo,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Vl),this._instantiationService.setService(Ro,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(bs),this._instantiationService.setService(Zr,this._oscLinkService),this._inputHandler=this._register(new rh(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ee.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ee.forward(this._bufferService.onResize,this._onResize)),this._register(Ee.forward(this.coreService.onData,this._onData)),this._register(Ee.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 ah((t,i)=>this._inputHandler.parse(t,i))),this._register(Ee.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new R),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&&!Mr&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Mr=!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,Ln),t=Math.max(t,Tn),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(br.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(br(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ee(()=>{for(let t of e)t.dispose()})}}},hh={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 ch(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(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?r.key=w.ESC+"OA":r.key=w.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=w.ESC+"OD":r.key=w.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=w.ESC+"OC":r.key=w.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=w.ESC+"OB":r.key=w.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":w.DEL,e.altKey&&(r.key=w.ESC+r.key);break;case 9:if(e.shiftKey){r.key=w.ESC+"[Z";break}r.key=w.HT,r.cancel=!0;break;case 13:r.key=e.altKey?w.ESC+w.CR:w.CR,r.cancel=!0;break;case 27:r.key=w.ESC,e.altKey&&(r.key=w.ESC+w.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=w.ESC+"[1;"+(n+1)+"D":t?r.key=w.ESC+"OD":r.key=w.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=w.ESC+"[1;"+(n+1)+"C":t?r.key=w.ESC+"OC":r.key=w.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=w.ESC+"[1;"+(n+1)+"A":t?r.key=w.ESC+"OA":r.key=w.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=w.ESC+"[1;"+(n+1)+"B":t?r.key=w.ESC+"OB":r.key=w.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=w.ESC+"[2~");break;case 46:n?r.key=w.ESC+"[3;"+(n+1)+"~":r.key=w.ESC+"[3~";break;case 36:n?r.key=w.ESC+"[1;"+(n+1)+"H":t?r.key=w.ESC+"OH":r.key=w.ESC+"[H";break;case 35:n?r.key=w.ESC+"[1;"+(n+1)+"F":t?r.key=w.ESC+"OF":r.key=w.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=w.ESC+"[5;"+(n+1)+"~":r.key=w.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=w.ESC+"[6;"+(n+1)+"~":r.key=w.ESC+"[6~";break;case 112:n?r.key=w.ESC+"[1;"+(n+1)+"P":r.key=w.ESC+"OP";break;case 113:n?r.key=w.ESC+"[1;"+(n+1)+"Q":r.key=w.ESC+"OQ";break;case 114:n?r.key=w.ESC+"[1;"+(n+1)+"R":r.key=w.ESC+"OR";break;case 115:n?r.key=w.ESC+"[1;"+(n+1)+"S":r.key=w.ESC+"OS";break;case 116:n?r.key=w.ESC+"[15;"+(n+1)+"~":r.key=w.ESC+"[15~";break;case 117:n?r.key=w.ESC+"[17;"+(n+1)+"~":r.key=w.ESC+"[17~";break;case 118:n?r.key=w.ESC+"[18;"+(n+1)+"~":r.key=w.ESC+"[18~";break;case 119:n?r.key=w.ESC+"[19;"+(n+1)+"~":r.key=w.ESC+"[19~";break;case 120:n?r.key=w.ESC+"[20;"+(n+1)+"~":r.key=w.ESC+"[20~";break;case 121:n?r.key=w.ESC+"[21;"+(n+1)+"~":r.key=w.ESC+"[21~";break;case 122:n?r.key=w.ESC+"[23;"+(n+1)+"~":r.key=w.ESC+"[23~";break;case 123:n?r.key=w.ESC+"[24;"+(n+1)+"~":r.key=w.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=w.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=w.DEL:e.keyCode===219?r.key=w.ESC:e.keyCode===220?r.key=w.FS:e.keyCode===221&&(r.key=w.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let l=(o=hh[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(l)r.key=w.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,a=String.fromCharCode(h);e.shiftKey&&(a=a.toUpperCase()),r.key=w.ESC+a}else if(e.keyCode===32)r.key=w.ESC+(e.ctrlKey?w.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=w.ESC+h,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=w.US),e.key==="@"&&(r.key=w.NUL));break}return r}var ce=0,dh=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new fi,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new fi,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((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,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||(ce=this._search(t),ce===-1)||this._getKey(this._array[ce])!==t)return!1;do if(this._array[ce]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ce),!0;while(++ce<this._array.length&&this._getKey(this._array[ce])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,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&&(ce=this._search(e),!(ce<0||ce>=this._array.length)&&this._getKey(this._array[ce])===e))do yield this._array[ce];while(++ce<this._array.length&&this._getKey(this._array[ce])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ce=this._search(e),!(ce<0||ce>=this._array.length)&&this._getKey(this._array[ce])===e))do t(this._array[ce]);while(++ce<this._array.length&&this._getKey(this._array[ce])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Hi=0,Lr=0,uh=class extends U{constructor(){super(),this._decorations=new dh(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new R),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new R),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ee(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new _h(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{Hi=r.options.x??0,Lr=Hi+(r.options.width??1),e>=Hi&&e<Lr&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},_h=class extends at{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new R),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new R),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=re.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=re.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},fh=1e3,ph=class{constructor(e,t=fh){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,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 s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_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)}},Tr=20,pi=class extends U{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,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=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new ph(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
45
+ `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(F(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ee(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Tr+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
46
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Tr+1&&(this._liveRegion.textContent+=Wi.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 i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],l=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),a=this._rowElements[r];a&&(l.length===0?(a.textContent=" ",this._rowColumns.set(a,[0,1])):(a.textContent=l,this._rowColumns.set(a,o)),a.setAttribute("aria-posinset",h),a.setAttribute("aria-setsize",s),this._alignRowWidth(a))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,l;if(t===0?(o=i,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=i,this._rowContainer.removeChild(o)),o.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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((l=s.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:a})=>{let d=h instanceof Text?h.parentNode:h,c=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(c))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(d);if(!_)return console.warn("columns is null. Race condition?"),null;let u=a<_.length?_[a]:_.slice(-1)[0]+1;return u>=this._terminal.cols&&(++c,u=0),{row:c,column:u}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.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 r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};pi=le([L(1,Es),L(2,Qe),L(3,et)],pi);var ys=class extends U{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new R),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new R),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ee(()=>{var n;gt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(F(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(F(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(F(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(F(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 i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.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 s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,l=>{var a,d;if(this._isMouseOut)return;let h=l==null?void 0:l.map(c=>({link:c}));(a=this._activeProviderReplies)==null||a.set(n,h),i=this._checkLinkProviderResult(n,e,i),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],l=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let a=l;a<=h;a++){if(i.has(a)){r.splice(n--,1);break}i.add(a)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(l=>this._linkAtPosition(l.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let l=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(l){i=!0,this._handleNewLink(l);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&gh(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,gt(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 i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};ys=le([L(1,Rs),L(2,et),L(3,Le),L(4,en)],ys);function gh(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 mh=class extends lh{constructor(e={}){super(e),this._linkifier=this._register(new yt),this.browser=wn,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new yt),this._onCursorMove=this._register(new R),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new R),this.onKey=this._onKey.event,this._onRender=this._register(new R),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new R),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new R),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new R),this.onBell=this._onBell.event,this._onFocus=this._register(new R),this._onBlur=this._register(new R),this._onA11yCharEmitter=this._register(new R),this._onA11yTabEmitter=this._register(new R),this._onWillOpen=this._register(new R),this._setup(),this._decorationService=this._instantiationService.createInstance(uh),this._instantiationService.setService(Vt,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ol),this._instantiationService.setService(en,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Ki)),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(Ee.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ee.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ee.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ee.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ee(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.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 i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=Z.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${w.ESC}]${s};${ih(r)}${vn.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ue.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ue.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(pi,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(w.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(w.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(F(this.element,"copy",t=>{this.hasSelection()&&bo(t,this._selectionService)}));let e=t=>yo(t,this.textarea,this.coreService,this.optionsService);this._register(F(this.textarea,"paste",e)),this._register(F(this.element,"paste",e)),bn?this._register(F(this.element,"mousedown",t=>{t.button===2&&$s(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(F(this.element,"contextmenu",t=>{$s(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Is&&this._register(F(this.element,"auxclick",t=>{t.button===1&&qr(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(F(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(F(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(F(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(F(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(F(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(F(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(F(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;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"),((r=this.element)==null?void 0:r.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(F(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Fi.get()),xn||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(rl,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Qe,this._coreBrowserService),this._register(F(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(F(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(cs,this._document,this._helperContainer),this._instantiationService.setService(vi,this._charSizeService),this._themeService=this._instantiationService.createInstance(fs),this._instantiationService.setService(Ct,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ui),this._instantiationService.setService(Qr,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(us,this.rows,this.screenElement)),this._instantiationService.setService(et,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(as,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ds),this._instantiationService.setService(Rs,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(ys,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(ns,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(_s,this.element,this.screenElement,s)),this._instantiationService.setService(Mo,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Ee.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(os,this.screenElement)),this._register(F(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),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(pi,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(di,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(di,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(hs,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var a,d,c,_,u;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let l,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,l=n.button<3?n.button:3;break;case"mousedown":h=1,l=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let f=n.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(n,(_=(c=(d=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:d.device)==null?void 0:c.cell)==null?void 0:_.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return!1;h=f<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:l,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(F(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(F(t,"wheel",n=>{var o,l,h,a,d;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(a=(h=(l=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:a.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(n,!0);let c=w.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(c,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.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){Ur(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,i){this._selectionService.setSelection(e,t,i)}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 i;(i=this._selectionService)==null||i.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 i=ch(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===w.ETX||i.key===w.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(vh(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 i;(i=this._charSizeService)==null||i.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(de));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(w.ESC+"[I"):this.coreService.triggerDataEvent(w.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${w.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${w.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function vh(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Sh=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},wh=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 We)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Pr=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 wh(t)}getNullCell(){return new We}},bh=class extends U{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new R),this.onBufferChange=this._onBufferChange.event,this._normal=new Pr(this._core.buffers.normal,"normal"),this._alternate=new Pr(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)}},yh=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.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)}},Ch=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}},xh=["cols","rows"],qe=0,kh=class extends U{constructor(e){super(),this._core=this._register(new mh(e)),this._addonManager=this._register(new Sh),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(xh.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 yh(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Ch(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 bh(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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
47
+ `,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 Fi.get()},set promptLabel(e){Fi.set(e)},get tooMuchOutput(){return Wi.get()},set tooMuchOutput(e){Wi.set(e)}}}_verifyIntegers(...e){for(qe of e)if(qe===1/0||isNaN(qe)||qe%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qe of e)if(qe&&(qe===1/0||isNaN(qe)||qe%1!==0||qe<0))throw new Error("This API only accepts positive integers")}};const Eh=Object.freeze(Object.defineProperty({__proto__:null,Terminal:kh},Symbol.toStringTag,{value:"Module"})),Rh=Vn(Eh);var Ar;function Bh(){if(Ar)return Jt;Ar=1;var e=Yn(),t=Rh,i=Xn();document.head.appendChild(document.createElement("style")).textContent=`/**
48
48
  * Copyright (c) 2014 The xterm.js authors. All rights reserved.
49
49
  * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
50
50
  * https://github.com/chjj/term.js
@@ -262,6 +262,6 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
262
262
  z-index: 2;
263
263
  position: relative;
264
264
  }
265
- `;function s({options:n,addons:o,listeners:l}={}){const h=i.useRef(null),a=i.useRef(l),[d,c]=i.useState(null);return i.useEffect(()=>{a.current=l},[l]),i.useEffect(()=>{const _=new t.Terminal({fontFamily:"operator mono,SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace",fontSize:14,theme:{background:"#101420"},cursorStyle:"underline",cursorBlink:!1,...n});o==null||o.forEach(f=>_.loadAddon(f));const u=a.current;return u!=null&&u.onBinary&&_.onBinary(u.onBinary),u!=null&&u.onCursorMove&&_.onCursorMove(u.onCursorMove),u!=null&&u.onLineFeed&&_.onLineFeed(u.onLineFeed),u!=null&&u.onScroll&&_.onScroll(u.onScroll),u!=null&&u.onSelectionChange&&_.onSelectionChange(u.onSelectionChange),u!=null&&u.onRender&&_.onRender(u.onRender),u!=null&&u.onResize&&_.onResize(u.onResize),u!=null&&u.onTitleChange&&_.onTitleChange(u.onTitleChange),u!=null&&u.onKey&&_.onKey(u.onKey),u!=null&&u.onData&&_.onData(u.onData),u!=null&&u.customKeyEventHandler&&_.attachCustomKeyEventHandler(u.customKeyEventHandler),h.current&&(_.open(h.current),_.focus()),c(_),()=>{_.dispose(),c(null)}},[n,o]),{ref:h,instance:d}}function r({className:n="",options:o,addons:l,listeners:h,...a}){const{ref:d}=s({options:o,addons:l,listeners:h});return e.jsx("div",{className:n,ref:d,...a})}return Xt.XTerm=r,Xt.useXTerm=s,Xt}var Rh=Eh();const Tn={background:"#e1e1e1",foreground:"#616161",cursor:"#616161",selectionBackground:"rgba(97, 97, 97, 0.25)",black:"#171717",red:"#bf2172",green:"#009799",yellow:"#9a7200",blue:"#007299",magenta:"#9b1d72",cyan:"#007173",white:"#d9d9d9",brightBlack:"#4e4e4e",brightRed:"#e12672",brightGreen:"#00bddf",brightYellow:"#ffdd00",brightBlue:"#7299bc",brightMagenta:"#e17899",brightCyan:"#6fbcbd",brightWhite:"#f1f1f1"},Pn={background:"#262626",foreground:"#d0d0d0",cursor:"#c5c5c5",selectionBackground:"rgba(197, 197, 197, 0.25)",black:"#000000",red:"#ba3c3c",green:"#5d876d",yellow:"#d5a54e",blue:"#887c8d",magenta:"#cd6d6d",cyan:"#618484",white:"#cfcdc3",brightBlack:"#000000",brightRed:"#ea7171",brightGreen:"#7aab7a",brightYellow:"#d1d194",brightBlue:"#afa3b5",brightMagenta:"#e29f9f",brightCyan:"#a0aea3",brightWhite:"#d0d0d0"},Bh='"JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", "Source Han Mono SC", "Sarasa Mono SC", "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", monospace';var Ii={exports:{}},Pr;function Dh(){return Pr||(Pr=1,(function(e,t){(function(i,s){e.exports=s()})(self,(()=>(()=>{var i={};return(()=>{var s=i;Object.defineProperty(s,"__esModule",{value:!0}),s.FitAddon=void 0,s.FitAddon=class{activate(r){this._terminal=r}dispose(){}fit(){const r=this.proposeDimensions();if(!r||!this._terminal||isNaN(r.cols)||isNaN(r.rows))return;const n=this._terminal._core;this._terminal.rows===r.rows&&this._terminal.cols===r.cols||(n._renderService.clear(),this._terminal.resize(r.cols,r.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const r=this._terminal._core,n=r._renderService.dimensions;if(n.css.cell.width===0||n.css.cell.height===0)return;const o=this._terminal.options.scrollback===0?0:r.viewport.scrollBarWidth,l=window.getComputedStyle(this._terminal.element.parentElement),h=parseInt(l.getPropertyValue("height")),a=Math.max(0,parseInt(l.getPropertyValue("width"))),d=window.getComputedStyle(this._terminal.element),c=h-(parseInt(d.getPropertyValue("padding-top"))+parseInt(d.getPropertyValue("padding-bottom"))),_=a-(parseInt(d.getPropertyValue("padding-right"))+parseInt(d.getPropertyValue("padding-left")))-o;return{cols:Math.max(2,Math.floor(_/n.css.cell.width)),rows:Math.max(1,Math.floor(c/n.css.cell.height))}}}})(),i})()))})(Ii)),Ii.exports}var Mh=Dh();function Lh({deviceId:e,paneId:t,deviceConnected:i,isSelectionInvalid:s,onResize:r,onSync:n,getContainerRect:o}){const l=w.useRef(null),h=w.useRef(null),a=w.useRef(null),d=w.useRef(null),c=w.useRef(0),_=w.useRef([]),u=w.useRef(null),f=w.useRef(null),p=w.useRef(r),y=w.useRef(n);w.useEffect(()=>{p.current=r},[r]),w.useEffect(()=>{y.current=n},[n]);const v=w.useCallback((H,V=!1)=>{var M,x,j,G,le,Ee,J,ie;if(!e||!t||!i||s&&H!=="sync"||!V&&Date.now()<c.current)return!1;const I=f.current,$=u.current;if(!I||!$||!I.element)return!1;let F,C;try{$.fit(),F=Math.max(2,I.cols)}catch{const Z=I._core,ee=((G=(j=(x=(M=Z==null?void 0:Z._renderService)==null?void 0:M.dimensions)==null?void 0:x.css)==null?void 0:j.cell)==null?void 0:G.width)??9,Y=o==null?void 0:o();if(!Y||Y.width===0)return!1;F=Math.max(2,Math.floor(Y.width/ee))}const m=o==null?void 0:o();if(!m||m.height===0)return!1;const k=I._core,E=((ie=(J=(Ee=(le=k==null?void 0:k._renderService)==null?void 0:le.dimensions)==null?void 0:Ee.css)==null?void 0:J.cell)==null?void 0:ie.height)??17;C=Math.max(2,Math.floor(m.height/E));const R=a.current;return!V&&R&&R.cols===F&&R.rows===C||(H==="sync"?y.current(F,C):p.current(F,C),a.current={cols:F,rows:C},d.current={cols:F,rows:C,at:Date.now()}),!0},[e,t,i,s]),A=w.useCallback((H="resize",V={})=>{const{immediate:I=!1,force:$=!1}=V;h.current!==null&&(window.clearTimeout(h.current),h.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);const F=()=>{l.current=requestAnimationFrame(()=>{l.current=null,v(H,$)})};if(I){F();return}h.current=window.setTimeout(()=>{h.current=null,F()},150)},[v]),T=w.useCallback(()=>{_.current.forEach(H=>window.clearTimeout(H)),_.current=[]},[]),L=w.useCallback(()=>{var V;T(),A("sync",{immediate:!0,force:!0});const H=window.setTimeout(()=>{A("sync",{immediate:!0,force:!0})},60);_.current.push(H),typeof document<"u"&&"fonts"in document&&((V=document.fonts)!=null&&V.ready)&&document.fonts.ready.then(()=>{A("sync",{immediate:!0,force:!0})}).catch(()=>{})},[T,A]);w.useEffect(()=>{let H=null;const V=()=>{H!==null&&cancelAnimationFrame(H),H=requestAnimationFrame(()=>{H=null,A("resize")})};return window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),H!==null&&cancelAnimationFrame(H)}},[A]),w.useEffect(()=>{const H=()=>{document.visibilityState==="visible"&&A("sync",{force:!0})},V=()=>{A("sync",{force:!0})};return document.addEventListener("visibilitychange",H),window.addEventListener("focus",V),()=>{document.removeEventListener("visibilitychange",H),window.removeEventListener("focus",V)}},[A]),w.useEffect(()=>()=>{T(),h.current!==null&&window.clearTimeout(h.current),l.current!==null&&cancelAnimationFrame(l.current)},[T]);const O=w.useCallback(H=>{u.current=H},[]),W=w.useCallback(H=>{f.current=H},[]);return{scheduleResize:A,runPostSelectResize:L,clearPostSelectResizeTimers:T,setFitAddon:O,setTerminal:W,lastReportedSize:a,pendingLocalSize:d,suppressLocalResizeUntil:c}}function Th(e){return e&&e.replace(/\r?\n/g,`\r
266
- `)}function Ar(e,t){let i=t,s=0;for(const l of e)l===10&&!i&&(s+=1),i=l===13;const r=i;if(s===0)return{normalized:e,endedWithCR:r};const n=new Uint8Array(e.length+s);let o=0;i=t;for(const l of e)l===10&&!i&&(n[o]=13,o+=1),n[o]=l,o+=1,i=l===13;return{normalized:n,endedWithCR:r}}const Ph={fontFamily:Bh,fontSize:13,convertEol:!0,scrollSensitivity:2,smoothScrollDuration:120,letterSpacing:0,cursorBlink:!0,allowProposedApi:!0,scrollback:1e4},An=w.forwardRef(({deviceId:e,paneId:t,theme:i,inputMode:s,deviceConnected:r,isSelectionInvalid:n,onResize:o,onSync:l},h)=>{const{instance:a,ref:d}=Rh.useXTerm({options:Ph}),c=w.useMemo(()=>{switch(i){case"light":return Tn;case"dark":default:return Pn}},[i]),_=Ae(I=>I.sendInput),u=w.useRef(null),f=w.useRef(e),p=w.useRef(t),y=w.useRef(r&&!n),v=w.useRef(!1),A=w.useRef(null),T=w.useRef(null);w.useEffect(()=>{f.current=e,p.current=t},[e,t]),w.useEffect(()=>{y.current=r&&!n},[r,n]);const{scheduleResize:L,runPostSelectResize:O,setFitAddon:W,setTerminal:H}=Lh({deviceId:e,paneId:t,deviceConnected:r,isSelectionInvalid:n,onResize:o,onSync:l,getContainerRect:()=>{const I=u.current;if(!I)return null;const $=I.getBoundingClientRect();return{width:$.width,height:$.height}}});w.useEffect(()=>{a&&(a.options.theme=c)},[a,c]),w.useEffect(()=>{a&&(a.options.disableStdin=s==="editor")},[a,s]);const V=w.useMemo(()=>a?{onResetTerminal:I=>{f.current===I&&(a.reset(),v.current=!1,O())},onApplyHistory:(I,$)=>{f.current===I&&a.write(Th($))},onFlushBuffer:(I,$)=>{if(f.current===I)for(const F of $){const C=Ar(F,v.current);v.current=C.endedWithCR,a.write(C.normalized)}},onOutput:(I,$,F)=>{if(f.current!==I||p.current!==$||!y.current)return;const C=Ar(F,v.current);v.current=C.endedWithCR,a.write(C.normalized)}}:{},[a,O]);return w.useEffect(()=>{a?A.current!==a&&(v.current=!1,a.reset(),A.current=a):A.current=null},[a]),w.useEffect(()=>{},[a]),w.useEffect(()=>{Os(V)},[V]),w.useEffect(()=>()=>{Os({})},[]),w.useEffect(()=>{if(!a){T.current=null,W(null),H(null);return}const I=new Mh.FitAddon;return a.loadAddon(I),T.current=I,W(I),H(a),L("sync",{immediate:!0,force:!0}),()=>{try{I.dispose()}finally{T.current=null,W(null),H(null)}}},[a,L,W,H]),w.useEffect(()=>{const I=u.current;if(!I)return;let $=null;const F=new ResizeObserver(()=>{$!==null&&cancelAnimationFrame($),$=requestAnimationFrame(()=>{$=null,L("resize")})});return F.observe(I),()=>{F.disconnect(),$!==null&&cancelAnimationFrame($)}},[L]),w.useEffect(()=>{if(!a||!e||!t)return;const I=a.onData($=>{!r||n||_(e,t,$,!1)});return a.attachCustomKeyEventHandler($=>!r||n||$.type!=="keydown"||s!=="direct"?!0:$.shiftKey&&$.key==="Enter"?($.preventDefault(),_(e,t,"\x1B[13;2u",!1),!1):!0),()=>{I.dispose(),a.attachCustomKeyEventHandler(()=>!0)}},[a,e,t,r,n,s,_]),w.useImperativeHandle(h,()=>({write:I=>a==null?void 0:a.write(I),reset:()=>{a==null||a.reset(),v.current=!1},scrollToBottom:()=>a==null?void 0:a.scrollToBottom(),resize:(I,$)=>a==null?void 0:a.resize(I,$),getTerminal:()=>a??null,getSize:()=>a?{cols:Math.max(2,a.cols),rows:Math.max(2,a.rows)}:null,runPostSelectResize:()=>O(),scheduleResize:(I,$)=>L(I,$),calculateSizeFromContainer:()=>{var M,x,j,G,le,Ee,J,ie,Z,ee,Y,tt,me,Te,ve,he;const I=u.current,$=a,F=T.current;if(!I||!$)return null;const C=I.getBoundingClientRect();if(C.width===0||C.height===0)return null;const m=$._core;let k;if(F)try{const K=F.proposeDimensions();if(K)k=Math.max(2,K.cols);else{const vt=((G=(j=(x=(M=m==null?void 0:m._renderService)==null?void 0:M.dimensions)==null?void 0:x.css)==null?void 0:j.cell)==null?void 0:G.width)??9;k=Math.max(2,Math.floor(C.width/vt))}}catch{const K=((ie=(J=(Ee=(le=m==null?void 0:m._renderService)==null?void 0:le.dimensions)==null?void 0:Ee.css)==null?void 0:J.cell)==null?void 0:ie.width)??9;k=Math.max(2,Math.floor(C.width/K))}else{const K=((tt=(Y=(ee=(Z=m==null?void 0:m._renderService)==null?void 0:Z.dimensions)==null?void 0:ee.css)==null?void 0:Y.cell)==null?void 0:tt.width)??9;k=Math.max(2,Math.floor(C.width/K))}const E=((he=(ve=(Te=(me=m==null?void 0:m._renderService)==null?void 0:me.dimensions)==null?void 0:Te.css)==null?void 0:ve.cell)==null?void 0:he.height)??17,R=Math.max(2,Math.floor(C.height/E));return{cols:k,rows:R}}}),[a,O,L]),B.jsx("div",{ref:u,className:"h-full w-full relative",style:{backgroundColor:c.background},children:B.jsx("div",{ref:d,className:"absolute inset-0"})})});An.displayName="Terminal";function Ah(){const e=Ss.getState().settings;return(e==null?void 0:e.siteName)||"tmex"}function Ir(e){const t=e==null?void 0:e.trim();return t&&t.length>0?t:"?"}function In({paneIdx:e,windowIdx:t,paneTitle:i,windowName:s,deviceName:r}){const n=t??"?",o=e??"?",l=Ir(i??s),h=Ir(r);return`${n}/${o}: ${l}@${h}`}function Ih(e){const t=Ah();return e!=null&&e.trim()?`[${t}]${e}`:t}function Oh(){if(typeof navigator>"u")return!1;const e=navigator.userAgent,t=/iPad|iPhone|iPod/.test(e),i=navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;return t||i}const Nh=[{key:"enter",label:"ENTER",payload:"\r"},{key:"ctrl-c",label:"CTRL-C",payload:""},{key:"ctrl-d",label:"CTRL-D",payload:""},{key:"up",label:"↑",payload:"\x1B[A"},{key:"down",label:"↓",payload:"\x1B[B"},{key:"left",label:"←",payload:"\x1B[D"},{key:"right",label:"→",payload:"\x1B[C"},{key:"shift-enter",label:"SHIFT+ENTER",payload:"\x1B[13;2u"},{key:"tab",label:"TAB",payload:" "},{key:"backspace",label:"BACKSPACE",payload:"\b"},{key:"esc",label:"ESC",payload:"\x1B"},{key:"delete",label:"DELETE",payload:""},{key:":",label:":",payload:":"},{key:"/",label:"/",payload:"/"},{key:"'",label:"'",payload:"'"},{key:'"',label:'"',payload:'"'},{key:"`",label:"`",payload:"`"}],Or=w.memo(function({onSend:t,onFocusEditor:i,disabled:s,isMobile:r,inputMode:n}){return B.jsx("div",{className:"terminal-shortcuts-strip my-2 bg-muted rounded-xl","data-testid":"terminal-shortcuts-strip",children:B.jsx("div",{className:"shortcut-row flex items-center gap-1.5 p-2 overflow-x-auto scrollbar-thin","data-testid":"editor-shortcuts-row",children:Nh.map(o=>B.jsx(_t,{variant:"secondary",size:"sm",className:"h-7 min-w-9 px-2.5 rounded-full text-[11px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3",title:o.label,"aria-label":o.label,"data-testid":`editor-shortcut-${o.key}`,onPointerDown:l=>l.preventDefault(),onClick:()=>{t(o.payload),r&&n==="editor"&&(i==null||i())},disabled:s,children:o.label},o.key))})})});function qh(){var Is;const{t:e}=Fr(),{deviceId:t,windowId:i,paneId:s}=ws(),r=Yn(),n=w.useRef(null),o=w.useRef(null),l=w.useRef(null),h=w.useRef(null),a=w.useRef(!1),d=w.useRef(!1),c=w.useRef(null),_=Ae(g=>g.selectPane),u=Ae(g=>t?g.snapshots[t]:void 0),f=Ae(g=>{var P;return t?(P=g.deviceErrors)==null?void 0:P[t]:void 0}),p=Ae(g=>{var P;return t?((P=g.deviceConnected)==null?void 0:P[t])??!1:!1}),y=Ss(g=>{var P;return((P=g.settings)==null?void 0:P.siteName)??"tmex"}),v=w.useMemo(()=>bs(s),[s]),A=w.useMemo(()=>t&&v?`${t}:${v}`:null,[t,v]),[T,L]=w.useState(!1),[O,W]=w.useState(""),[H,V]=w.useState(!1),I=w.useRef(!1),$=!p||!v,[F,C]=w.useState(0),[m,k]=w.useState(0),[E,R]=w.useState(!1),M=Ve(g=>g.inputMode),x=Ve(g=>g.theme),j=Ve(g=>g.editorSendWithEnter),G=Ve(g=>g.setEditorSendWithEnter),le=Ve(g=>g.addEditorHistory),Ee=Ve(g=>g.setEditorDraft),J=Ve(g=>g.removeEditorDraft),ie=Ve(g=>A?g.editorDrafts[A]??"":""),Z=w.useMemo(()=>Oh(),[]),ee=T&&M==="editor"&&Z&&H,Y=(Is=u==null?void 0:u.session)==null?void 0:Is.windows,tt=x==="light"?Tn:Pn,{data:me}=Xn({queryKey:["devices"],queryFn:async()=>{const g=await fetch("/api/devices");if(!g.ok)throw new Error("Failed to fetch devices");return g.json()},throwOnError:!1}),Te=w.useMemo(()=>{if(t)return me==null?void 0:me.devices.find(g=>g.id===t)},[t,me==null?void 0:me.devices]),ve=w.useMemo(()=>{if(!(!i||!Y))return Y.find(g=>g.id===i)},[i,Y]),he=w.useMemo(()=>{if(!(!v||!ve))return ve.panes.find(g=>g.id===v)},[v,ve]),K=!!Y,Ts=!!(K&&!!i&&!ve||K&&!!i&&!!v&&!!ve&&!he?e("wsError.checkGateway"):null),Ne=!!(p&&v&&!Ts),Ps=w.useMemo(()=>{if(!ve||!he)return null;const g=(Te==null?void 0:Te.name)??t;return In({paneIdx:he.index,windowIdx:ve.index,paneTitle:he.title,windowName:ve.name,deviceName:g})},[Te==null?void 0:Te.name,t,he,ve]),On=w.useCallback((g,P)=>{!t||!v||Ae.getState().resizePane(t,v,g,P)},[t,v]),Nn=w.useCallback((g,P)=>{!t||!v||Ae.getState().syncPaneSize(t,v,g,P)},[t,v]);w.useEffect(()=>{const g=()=>{L(window.innerWidth<768||"ontouchstart"in window)};return g(),window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[]),w.useEffect(()=>{if(!T||!Z||d.current)return;d.current=!0;const g=()=>{window.scrollTo(0,1)},P=window.requestAnimationFrame(g),N=window.setTimeout(g,120),_e=window.setTimeout(g,420);return()=>{window.cancelAnimationFrame(P),window.clearTimeout(N),window.clearTimeout(_e)}},[Z,T]),w.useEffect(()=>{M!=="editor"&&V(!1)},[M]),w.useEffect(()=>{var _e,ne;if(!(T&&Z&&M==="editor"&&H)){C(0);return}let g=null;const P=()=>{const $e=window.visualViewport,lt=($e==null?void 0:$e.height)??window.innerHeight,Bt=($e==null?void 0:$e.offsetTop)??0,Un=Math.max(0,Math.round(window.innerHeight-lt-Bt));C(Un)},N=()=>{g===null&&(g=window.requestAnimationFrame(()=>{g=null,P()}))};return P(),(_e=window.visualViewport)==null||_e.addEventListener("resize",N),(ne=window.visualViewport)==null||ne.addEventListener("scroll",N),window.addEventListener("resize",N),()=>{var $e,lt;($e=window.visualViewport)==null||$e.removeEventListener("resize",N),(lt=window.visualViewport)==null||lt.removeEventListener("scroll",N),window.removeEventListener("resize",N),g!==null&&window.cancelAnimationFrame(g)}},[M,H,Z,T]),w.useEffect(()=>{if(!ee){k(0);return}const g=o.current;if(!g)return;const P=()=>{k(Math.ceil(g.getBoundingClientRect().height))};P();const N=new ResizeObserver(P);return N.observe(g),()=>N.disconnect()},[ee]),w.useEffect(()=>{t&&(a.current=!1,Et.current=null,Rt.current=null,c.current=null,kt.current=[])},[t]),w.useEffect(()=>{p||(a.current=!1)},[p]),w.useEffect(()=>{if(!t||!p||!i||!Y)return;if(Y.length===0){r("/devices",{replace:!0});return}const g=Y.find(N=>N.id===i);if(!g)return;if(!v){const N=g.panes.find(_e=>_e.active)??g.panes[0];N&&r(`/devices/${t}/windows/${i}/panes/${Dt(N.id)}`,{replace:!0});return}if(!g.panes.find(N=>N.id===v)){const N=g.panes.find(_e=>_e.active)??g.panes[0];N&&r(`/devices/${t}/windows/${i}/panes/${Dt(N.id)}`,{replace:!0});return}},[t,p,Y,i,v,r]),w.useEffect(()=>{if(!t||!p||!Y||Y.length===0||i&&v||a.current)return;const g=Y.find(N=>N.active)??Y[0],P=g.panes.find(N=>N.active)??g.panes[0];P&&(a.current=!0,r(`/devices/${t}/windows/${g.id}/panes/${Dt(P.id)}`,{replace:!0}))},[p,t,r,v,i,Y]),w.useEffect(()=>{var N;if(!t||!i||!v||$||!p)return;const g=Ae.getState().selectedPanes[t];if(g&&g.windowId===i&&g.paneId===v)return;const P=((N=h.current)==null?void 0:N.calculateSizeFromContainer())??void 0;Si(i,v),_(t,i,v,P)},[p,t,$,v,_,i]);const kt=w.useRef([]),Si=w.useCallback((g,P)=>{const N=Date.now(),_e=[...kt.current.filter(ne=>N-ne.at<2e3),{windowId:g,paneId:P,at:N}];kt.current=_e.slice(-8)},[]),Be=Ae(g=>t?g.activePaneFromEvent[t]:void 0),Et=w.useRef(null);w.useEffect(()=>{var P;if(!t||!p||!i||!v||!Be)return;{const N=Date.now();if(kt.current.some(ne=>ne.windowId===Be.windowId&&ne.paneId===Be.paneId&&N-ne.at<1200))return}if(Be.windowId===i&&Be.paneId===v||Et.current&&Et.current.windowId===Be.windowId&&Et.current.paneId===Be.paneId)return;Et.current={...Be};const g=((P=h.current)==null?void 0:P.calculateSizeFromContainer())??void 0;Si(Be.windowId,Be.paneId),_(t,Be.windowId,Be.paneId,g),r(`/devices/${t}/windows/${Be.windowId}/panes/${Dt(Be.paneId)}`,{replace:!0})},[t,p,i,v,Be,_,r]);const Rt=w.useRef(null);w.useEffect(()=>{var lt;if(!t||!p||!Y||Y.length===0||c.current)return;const g=kt.current,P=g.length>0?g[g.length-1]:null;if(P&&Date.now()-P.at<1200)return;const N=Y.find(Bt=>Bt.active);if(!N)return;const _e=N.panes.find(Bt=>Bt.active);if(!_e)return;const ne={windowId:N.id,paneId:_e.id};if(Rt.current&&Rt.current.windowId===ne.windowId&&Rt.current.paneId===ne.paneId||(Rt.current={...ne},i===ne.windowId&&v===ne.paneId))return;const $e=((lt=h.current)==null?void 0:lt.calculateSizeFromContainer())??void 0;Si(ne.windowId,ne.paneId),_(t,ne.windowId,ne.paneId,$e),r(`/devices/${t}/windows/${ne.windowId}/panes/${Dt(ne.paneId)}`,{replace:!0})},[t,p,Y,i,v,_,r]),w.useEffect(()=>{var _e;if(!Ne||!he||$)return;const g=(_e=h.current)==null?void 0:_e.getTerminal();if(!g)return;const P=Math.max(2,Math.floor(he.width||0)),N=Math.max(2,Math.floor(he.height||0));!P||!N||g.cols===P&&g.rows===N||g.resize(P,N)},[Ne,$,he]),w.useEffect(()=>{const g=window.requestAnimationFrame(()=>{var N;(N=h.current)==null||N.scrollToBottom()}),P=window.setTimeout(()=>{var N;(N=h.current)==null||N.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(g),window.clearTimeout(P)}},[M]),w.useEffect(()=>{f!=null&&f.message&&wi.error(f.message)},[f==null?void 0:f.message]),w.useEffect(()=>(document.title=Ih(Ps),()=>{document.title=y}),[y,Ps]),w.useEffect(()=>{const g=()=>{var P;(P=h.current)==null||P.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",g),()=>{window.removeEventListener("tmex:jump-to-latest",g)}},[]),w.useEffect(()=>{const g=P=>{const{deviceId:N,windowId:_e,paneId:ne}=P.detail;N===t&&(c.current={windowId:_e,paneId:ne})};return window.addEventListener("tmex:user-initiated-selection",g),()=>{window.removeEventListener("tmex:user-initiated-selection",g)}},[t]),w.useEffect(()=>{W(ie)},[ie]);const As=w.useCallback(g=>{if(!t||!v||!Ne)return;Ae.getState().sendInput(t,v,g,!1)},[Ne,t,v]),Hn=w.useCallback(()=>{if(!Ne){wi.error(e("wsError.checkGateway"));return}if(!t||!v||!O.trim())return;R(!0),window.setTimeout(()=>R(!1),150);const g=j?`${O}\r`:O;Ae.getState().sendInput(t,v,g,!1),le(O),A&&J(A),W("")},[le,Ne,t,A,j,O,J,v,e]),zn=w.useCallback(()=>{if(!Ne){wi.error(e("wsError.checkGateway"));return}if(!t||!v||!O.trim())return;R(!0),window.setTimeout(()=>R(!1),150);const g=O.split(/\r?\n/),P=Ae.getState();for(const N of g)N.trim()&&P.sendInput(t,v,`${N}\r`,!1);le(O),A&&J(A),W("")},[le,Ne,t,A,O,J,v,e]),Fn=w.useCallback(g=>{if(V(!0),!(T&&Z))return;const P=g.currentTarget;window.requestAnimationFrame(()=>{P.scrollIntoView({block:"nearest",inline:"nearest"})}),window.setTimeout(()=>{window.scrollTo(0,1)},60)},[Z,T]),Wn=w.useCallback(()=>{V(!1)},[]),$n=w.useCallback(()=>{var g;(g=l.current)==null||g.focus({preventScroll:!0})},[]);if(!t)return B.jsx("div",{className:"flex h-full items-center justify-center p-4",children:B.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:e("device.noDevices")})});const Kn=!p&&!f;return B.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[B.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${T&&M==="editor"&&!ee?"pb-1":""}`,style:{paddingBottom:ee?`${m+60}px`:void 0},children:[B.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:tt.background},children:p&&v?B.jsx("div",{ref:n,className:"flex-1 w-full",children:B.jsx(An,{ref:h,deviceId:t,paneId:v,theme:x,inputMode:M,deviceConnected:p,isSelectionInvalid:Ts,onResize:On,onSync:Nn},`${t}:${v}`)}):B.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:B.jsx("div",{className:"max-w-sm space-y-4",children:p?i?B.jsxs(B.Fragment,{children:[B.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:B.jsx(bi,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),B.jsx("h3",{className:"text-lg font-medium",children:e("terminal.connecting")})]}):B.jsxs(B.Fragment,{children:[B.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:B.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),B.jsx("h3",{className:"text-lg font-medium",children:e("window.noWindowSelected")}),B.jsx("p",{className:"text-sm text-muted-foreground",children:e("window.selectWindowToStart")})]}):B.jsxs(B.Fragment,{children:[B.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:B.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),B.jsx("h3",{className:"text-lg font-medium",children:e("device.disconnected")}),B.jsx("p",{className:"text-sm text-muted-foreground",children:e("device.connectToStart")})]})})})}),Kn&&B.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:B.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm",children:[B.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),B.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:e("terminal.connecting")})]})})]}),M==="direct"&&B.jsx("div",{className:"",children:B.jsx(Or,{onSend:As,disabled:!Ne,isMobile:T,inputMode:M})}),M==="editor"&&B.jsxs("div",{ref:o,className:`editor-mode-input bg-card/85 backdrop-blur-sm ${ee?"fixed left-0 right-0 z-50":""}`,style:ee?{bottom:`${F}px`}:void 0,children:[T&&B.jsx(Or,{onSend:As,onFocusEditor:$n,disabled:!Ne,isMobile:T,inputMode:M}),B.jsx("textarea",{ref:l,"data-testid":"editor-input",className:"min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring",value:O,onChange:g=>{const P=g.target.value;if(W(P),!!A){if(P){Ee(A,P);return}J(A)}},placeholder:e("terminal.inputPlaceholder"),onFocus:Fn,onBlur:Wn,onCompositionStart:()=>{I.current=!0},onCompositionEnd:()=>{I.current=!1}}),B.jsx("div",{className:"actions mt-2",children:B.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[B.jsxs("div",{className:"send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground","data-testid":"editor-send-with-enter-toggle",children:[B.jsx(no,{size:"sm",checked:j,onCheckedChange:g=>G(!!g)}),B.jsx("span",{children:e("terminal.editorSendWithEnter")})]}),B.jsxs(_t,{variant:"outline",size:"sm","data-testid":"editor-clear",onPointerDown:g=>g.preventDefault(),onClick:()=>{var g;W(""),A&&J(A),T&&M==="editor"&&((g=l.current)==null||g.focus({preventScroll:!0}))},title:e("terminal.clear"),children:[B.jsx(Gn,{className:"h-4 w-4"}),e("terminal.clear")]}),B.jsxs(_t,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onPointerDown:g=>g.preventDefault(),onClick:()=>{var g;zn(),T&&M==="editor"&&((g=l.current)==null||g.focus({preventScroll:!0}))},disabled:!Ne||E,children:[E?B.jsx(bi,{className:"h-4 w-4 animate-spin"}):B.jsx(Ns,{className:"h-4 w-4"}),e("terminal.editorSendLineByLine")]}),B.jsxs(_t,{variant:"default",size:"sm","data-testid":"editor-send",onPointerDown:g=>g.preventDefault(),onClick:()=>{var g;Hn(),T&&M==="editor"&&((g=l.current)==null||g.focus({preventScroll:!0}))},disabled:!Ne||E,children:[E?B.jsx(bi,{className:"h-4 w-4 animate-spin"}):B.jsx(Ns,{className:"h-4 w-4"}),e("common.send")]})]})})]})]})}function jh(){const{deviceId:e,windowId:t,paneId:i}=ws(),s=i?bs(i):void 0,r=Ae(d=>d.snapshots),n=Ss(d=>{var c;return((c=d.settings)==null?void 0:c.siteName)??"tmex"}),o=e?r[e]:void 0,l=w.useMemo(()=>{var d;if(!(!t||!((d=o==null?void 0:o.session)!=null&&d.windows)))return o.session.windows.find(c=>c.id===t)},[t,o]),h=w.useMemo(()=>{if(!(!s||!l))return l.panes.find(d=>d.id===s)},[s,l]),a=w.useMemo(()=>l&&h?In({paneIdx:h.index,windowIdx:l.index,paneTitle:h.title,windowName:l.name,deviceName:n}):e??"",[l,h,n,e]);return B.jsx(B.Fragment,{children:a})}function Vh(){const{t:e}=Fr(),{deviceId:t,paneId:i}=ws(),s=i?bs(i):void 0,r=Ve(f=>f.inputMode),n=Ve(f=>f.setInputMode),o=Ae(f=>{var p;return t?((p=f.deviceConnected)==null?void 0:p[t])??!1:!1}),[l,h]=w.useState(!1),a=!!(s&&o),d=()=>{n(r==="direct"?"editor":"direct")},c=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},_=()=>{h(!0)},u=()=>{window.location.reload()};return B.jsxs(B.Fragment,{children:[B.jsx(_t,{variant:"ghost",size:"icon-sm",onClick:_,"aria-label":e("nav.refreshPage"),title:e("nav.refreshPage"),children:B.jsx(uo,{className:"h-4 w-4"})}),B.jsx(_t,{variant:"ghost",size:"icon-sm",onClick:d,disabled:!a,"data-testid":"terminal-input-mode-toggle","aria-label":e(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:e(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:r==="direct"?B.jsx(ho,{className:"h-4 w-4"}):B.jsx(fo,{className:"h-4 w-4"})}),B.jsx(_t,{variant:"ghost",size:"icon-sm",onClick:c,disabled:!a,"aria-label":e("nav.jumpToLatest"),title:e("nav.jumpToLatest"),children:B.jsx(ao,{className:"h-4 w-4"})}),B.jsx(Jn,{open:l,onOpenChange:h,children:B.jsxs(Zn,{children:[B.jsxs(Qn,{children:[B.jsx(eo,{children:e("nav.refreshPage")}),B.jsx(to,{children:e("nav.refreshPageConfirm")})]}),B.jsxs(io,{children:[B.jsx(so,{onClick:()=>h(!1),children:e("common.cancel")}),B.jsx(ro,{onClick:u,children:e("common.confirm")})]})]})})]})}export{Vh as PageActions,jh as PageTitle,qh as default};
267
- //# sourceMappingURL=DevicePage-DDl0kHG5.js.map
265
+ `;function s({options:n,addons:o,listeners:l}={}){const h=i.useRef(null),a=i.useRef(l),[d,c]=i.useState(null);return i.useEffect(()=>{a.current=l},[l]),i.useEffect(()=>{const _=new t.Terminal({fontFamily:"operator mono,SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace",fontSize:14,theme:{background:"#101420"},cursorStyle:"underline",cursorBlink:!1,...n});o==null||o.forEach(f=>_.loadAddon(f));const u=a.current;return u!=null&&u.onBinary&&_.onBinary(u.onBinary),u!=null&&u.onCursorMove&&_.onCursorMove(u.onCursorMove),u!=null&&u.onLineFeed&&_.onLineFeed(u.onLineFeed),u!=null&&u.onScroll&&_.onScroll(u.onScroll),u!=null&&u.onSelectionChange&&_.onSelectionChange(u.onSelectionChange),u!=null&&u.onRender&&_.onRender(u.onRender),u!=null&&u.onResize&&_.onResize(u.onResize),u!=null&&u.onTitleChange&&_.onTitleChange(u.onTitleChange),u!=null&&u.onKey&&_.onKey(u.onKey),u!=null&&u.onData&&_.onData(u.onData),u!=null&&u.customKeyEventHandler&&_.attachCustomKeyEventHandler(u.customKeyEventHandler),h.current&&(_.open(h.current),_.focus()),c(_),()=>{_.dispose(),c(null)}},[n,o]),{ref:h,instance:d}}function r({className:n="",options:o,addons:l,listeners:h,...a}){const{ref:d}=s({options:o,addons:l,listeners:h});return e.jsx("div",{className:n,ref:d,...a})}return Jt.XTerm=r,Jt.useXTerm=s,Jt}var Dh=Bh();const An={background:"#e1e1e1",foreground:"#616161",cursor:"#616161",selectionBackground:"rgba(97, 97, 97, 0.25)",black:"#171717",red:"#bf2172",green:"#009799",yellow:"#9a7200",blue:"#007299",magenta:"#9b1d72",cyan:"#007173",white:"#d9d9d9",brightBlack:"#4e4e4e",brightRed:"#e12672",brightGreen:"#00bddf",brightYellow:"#ffdd00",brightBlue:"#7299bc",brightMagenta:"#e17899",brightCyan:"#6fbcbd",brightWhite:"#f1f1f1"},In={background:"#262626",foreground:"#d0d0d0",cursor:"#c5c5c5",selectionBackground:"rgba(197, 197, 197, 0.25)",black:"#000000",red:"#ba3c3c",green:"#5d876d",yellow:"#d5a54e",blue:"#887c8d",magenta:"#cd6d6d",cyan:"#618484",white:"#cfcdc3",brightBlack:"#000000",brightRed:"#ea7171",brightGreen:"#7aab7a",brightYellow:"#d1d194",brightBlue:"#afa3b5",brightMagenta:"#e29f9f",brightCyan:"#a0aea3",brightWhite:"#d0d0d0"},Mh='"JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", "Source Han Mono SC", "Sarasa Mono SC", "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", monospace';var zi={exports:{}},Ir;function Lh(){return Ir||(Ir=1,(function(e,t){(function(i,s){e.exports=s()})(self,(()=>(()=>{var i={};return(()=>{var s=i;Object.defineProperty(s,"__esModule",{value:!0}),s.FitAddon=void 0,s.FitAddon=class{activate(r){this._terminal=r}dispose(){}fit(){const r=this.proposeDimensions();if(!r||!this._terminal||isNaN(r.cols)||isNaN(r.rows))return;const n=this._terminal._core;this._terminal.rows===r.rows&&this._terminal.cols===r.cols||(n._renderService.clear(),this._terminal.resize(r.cols,r.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const r=this._terminal._core,n=r._renderService.dimensions;if(n.css.cell.width===0||n.css.cell.height===0)return;const o=this._terminal.options.scrollback===0?0:r.viewport.scrollBarWidth,l=window.getComputedStyle(this._terminal.element.parentElement),h=parseInt(l.getPropertyValue("height")),a=Math.max(0,parseInt(l.getPropertyValue("width"))),d=window.getComputedStyle(this._terminal.element),c=h-(parseInt(d.getPropertyValue("padding-top"))+parseInt(d.getPropertyValue("padding-bottom"))),_=a-(parseInt(d.getPropertyValue("padding-right"))+parseInt(d.getPropertyValue("padding-left")))-o;return{cols:Math.max(2,Math.floor(_/n.css.cell.width)),rows:Math.max(1,Math.floor(c/n.css.cell.height))}}}})(),i})()))})(zi)),zi.exports}var Th=Lh();function Ph({deviceId:e,paneId:t,deviceConnected:i,isSelectionInvalid:s,onResize:r,onSync:n,getContainerRect:o}){const l=C.useRef(null),h=C.useRef(null),a=C.useRef(null),d=C.useRef(null),c=C.useRef(0),_=C.useRef([]),u=C.useRef(null),f=C.useRef(null),p=C.useRef(r),b=C.useRef(n);C.useEffect(()=>{p.current=r},[r]),C.useEffect(()=>{b.current=n},[n]);const g=C.useCallback((N,$=!1)=>{var E,x,H,Y,te,Re,G,ie;if(!e||!t||!i||s&&N!=="sync"||!$&&Date.now()<c.current)return!1;const V=f.current,ne=u.current;if(!V||!ne||!V.element)return!1;let W,B;try{ne.fit(),W=Math.max(2,V.cols)}catch{const J=V._core,Q=((Y=(H=(x=(E=J==null?void 0:J._renderService)==null?void 0:E.dimensions)==null?void 0:x.css)==null?void 0:H.cell)==null?void 0:Y.width)??9,j=o==null?void 0:o();if(!j||j.width===0)return!1;W=Math.max(2,Math.floor(j.width/Q))}const y=o==null?void 0:o();if(!y||y.height===0)return!1;const v=V._core,S=((ie=(G=(Re=(te=v==null?void 0:v._renderService)==null?void 0:te.dimensions)==null?void 0:Re.css)==null?void 0:G.cell)==null?void 0:ie.height)??17;B=Math.max(2,Math.floor(y.height/S));const k=a.current;return!$&&k&&k.cols===W&&k.rows===B||(N==="sync"?b.current(W,B):p.current(W,B),a.current={cols:W,rows:B},d.current={cols:W,rows:B,at:Date.now()}),!0},[e,t,i,s]),T=C.useCallback((N="resize",$={})=>{const{immediate:V=!1,force:ne=!1}=$;h.current!==null&&(window.clearTimeout(h.current),h.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);const W=()=>{l.current=requestAnimationFrame(()=>{l.current=null,g(N,ne)})};if(V){W();return}h.current=window.setTimeout(()=>{h.current=null,W()},150)},[g]),D=C.useCallback(()=>{_.current.forEach(N=>window.clearTimeout(N)),_.current=[]},[]),P=C.useCallback(()=>{var $;D(),T("sync",{immediate:!0,force:!0});const N=window.setTimeout(()=>{T("sync",{immediate:!0,force:!0})},60);_.current.push(N),typeof document<"u"&&"fonts"in document&&(($=document.fonts)!=null&&$.ready)&&document.fonts.ready.then(()=>{T("sync",{immediate:!0,force:!0})}).catch(()=>{})},[D,T]);C.useEffect(()=>{let N=null;const $=()=>{N!==null&&cancelAnimationFrame(N),N=requestAnimationFrame(()=>{N=null,T("resize")})};return window.addEventListener("resize",$),()=>{window.removeEventListener("resize",$),N!==null&&cancelAnimationFrame(N)}},[T]),C.useEffect(()=>{const N=()=>{document.visibilityState==="visible"&&T("sync",{force:!0})},$=()=>{T("sync",{force:!0})};return document.addEventListener("visibilitychange",N),window.addEventListener("focus",$),()=>{document.removeEventListener("visibilitychange",N),window.removeEventListener("focus",$)}},[T]),C.useEffect(()=>()=>{D(),h.current!==null&&window.clearTimeout(h.current),l.current!==null&&cancelAnimationFrame(l.current)},[D]);const A=C.useCallback(N=>{u.current=N},[]),I=C.useCallback(N=>{f.current=N},[]);return{scheduleResize:T,runPostSelectResize:P,clearPostSelectResizeTimers:D,setFitAddon:A,setTerminal:I,lastReportedSize:a,pendingLocalSize:d,suppressLocalResizeUntil:c}}const Ah=1.3,Ih=36;function Oh(e,t){const i=C.useRef(!1);return C.useEffect(()=>{const s=e.current;if(!s||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;i.current=!0;let n=0,o=null,l=!1,h=0;const a=b=>b?!!(b.closest(".scrollbar")||b.closest(".slider")||b.closest(".xterm-scroll-area")):!1,d=(b,g,T)=>{const D=T instanceof Element?T:null;if(a(D))return!0;const P=document.elementFromPoint(b,g);if(a(P))return!0;const A=s.querySelector(".xterm");if(!(A instanceof HTMLElement))return!1;const I=A.getBoundingClientRect(),N=b>=I.left&&b<=I.right,$=g>=I.top&&g<=I.bottom;return!N||!$?!1:b>=I.right-Ih},c=()=>[s.querySelector(".xterm-viewport"),s.querySelector(".xterm-scrollable-element")].filter(g=>g instanceof HTMLElement),_=b=>{if(o===null)return null;for(let g=0;g<b.length;g+=1){const T=b.item(g);if(T&&T.identifier===o)return T}return null},u=b=>{if(b.touches.length!==1)return;const g=b.touches.item(0);g&&(o=g.identifier,n=g.clientY,h=0,l=d(g.clientX,g.clientY,b.target))},f=b=>{var N,$,V,ne,W,B,y,v;const g=_(b.touches)??b.touches.item(0);if(!g||(l||(l=d(g.clientX,g.clientY,b.target),l&&(h=0)),l))return;const T=g.clientY,D=n-T;if(n=T,D===0)return;let P=!1,A=!1;const I=(t==null?void 0:t())??null;if(I){const S=I==null?void 0:I._core,k=((ne=(V=($=(N=S==null?void 0:S._renderService)==null?void 0:N.dimensions)==null?void 0:$.css)==null?void 0:V.cell)==null?void 0:ne.height)??18;h+=D*Ah;const E=h>0?Math.floor(h/k):Math.ceil(h/k);if(E!==0){const x=((B=(W=I.buffer)==null?void 0:W.active)==null?void 0:B.viewportY)??0;I.scrollLines(E);const H=((v=(y=I.buffer)==null?void 0:y.active)==null?void 0:v.viewportY)??0;P=x!==H,A=E<0&&x<=0&&H<=0,h-=E*k}}else{const S=c();if(S.length===0)return;for(const k of S){const E=k.scrollTop;k.scrollTop+=D;const x=k.scrollTop;Math.abs(x-E)>0&&(P=!0),D<0&&x<=0&&(A=!0)}if(!P){const k=s.querySelector(".xterm");if(k instanceof HTMLElement){const E=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:D}),x=k.dispatchEvent(E);P=E.defaultPrevented||!x}}}b.cancelable&&(P||A)&&b.preventDefault()},p=b=>{o===null||!_(b.changedTouches)||(o=null,h=0,l=!1)};return s.addEventListener("touchstart",u,{passive:!0}),s.addEventListener("touchmove",f,{passive:!1}),s.addEventListener("touchend",p,{passive:!0}),s.addEventListener("touchcancel",p,{passive:!0}),()=>{i.current=!1,s.removeEventListener("touchstart",u),s.removeEventListener("touchmove",f),s.removeEventListener("touchend",p),s.removeEventListener("touchcancel",p)}},[e,t]),i}function Nh(e){return e&&e.replace(/\r?\n/g,`\r
266
+ `)}function Or(e,t){let i=t,s=0;for(const l of e)l===10&&!i&&(s+=1),i=l===13;const r=i;if(s===0)return{normalized:e,endedWithCR:r};const n=new Uint8Array(e.length+s);let o=0;i=t;for(const l of e)l===10&&!i&&(n[o]=13,o+=1),n[o]=l,o+=1,i=l===13;return{normalized:n,endedWithCR:r}}const Hh={fontFamily:Mh,fontSize:13,convertEol:!0,scrollSensitivity:2,smoothScrollDuration:120,letterSpacing:0,cursorBlink:!0,allowProposedApi:!0,scrollback:1e4},On=C.forwardRef(({deviceId:e,paneId:t,theme:i,inputMode:s,deviceConnected:r,isSelectionInvalid:n,onResize:o,onSync:l},h)=>{const{instance:a,ref:d}=Dh.useXTerm({options:Hh}),c=C.useMemo(()=>{switch(i){case"light":return An;case"dark":default:return In}},[i]),_=Ie(v=>v.sendInput),u=C.useRef(null),f=C.useCallback(()=>a??null,[a]);Oh(u,f);const p=C.useRef(e),b=C.useRef(t),g=C.useRef(r&&!n),T=C.useRef(!1),D=C.useRef(""),P=C.useRef(null),A=C.useRef(!1),I=C.useRef(null),N=C.useRef(null);C.useEffect(()=>{p.current=e,b.current=t,T.current=!1,D.current="",P.current=null},[e,t]),C.useEffect(()=>{g.current=r&&!n},[r,n]);const $=C.useCallback(v=>{if(!v||s!=="direct"||!g.current)return;const S=p.current,k=b.current;if(!S||!k)return;const E=Date.now(),x=P.current;x&&x.data===v&&E-x.at<40||(P.current={data:v,at:E},_(S,k,v,!1))},[s,_]),{scheduleResize:V,runPostSelectResize:ne,setFitAddon:W,setTerminal:B}=Ph({deviceId:e,paneId:t,deviceConnected:r,isSelectionInvalid:n,onResize:o,onSync:l,getContainerRect:()=>{const v=u.current;if(!v)return null;const S=v.getBoundingClientRect();return{width:S.width,height:S.height}}});C.useEffect(()=>{a&&(a.options.theme=c)},[a,c]),C.useEffect(()=>{a&&(a.options.disableStdin=s==="editor")},[a,s]),C.useEffect(()=>{if(!a){T.current=!1,D.current="";return}const v=a.textarea;if(!v){T.current=!1,D.current="";return}const S=()=>{T.current=!0,D.current=""},k=H=>{typeof H.data=="string"&&H.data&&(D.current=H.data)},E=H=>{T.current=!1;const te=(typeof H.data=="string"?H.data:"")||D.current;D.current="",te&&$(te)},x=H=>{const Y=typeof H.data=="string"?H.data:"";if(Y){if(H.isComposing||T.current){D.current=Y;return}$(Y)}};return v.addEventListener("compositionstart",S),v.addEventListener("compositionupdate",k),v.addEventListener("compositionend",E),v.addEventListener("beforeinput",x),()=>{v.removeEventListener("compositionstart",S),v.removeEventListener("compositionupdate",k),v.removeEventListener("compositionend",E),v.removeEventListener("beforeinput",x),T.current=!1,D.current=""}},[a,$]);const y=C.useMemo(()=>a?{onResetTerminal:v=>{p.current===v&&(a.reset(),A.current=!1,ne())},onApplyHistory:(v,S)=>{p.current===v&&a.write(Nh(S))},onFlushBuffer:(v,S)=>{if(p.current===v)for(const k of S){const E=Or(k,A.current);A.current=E.endedWithCR,a.write(E.normalized)}},onOutput:(v,S,k)=>{if(p.current!==v||b.current!==S||!g.current)return;const E=Or(k,A.current);A.current=E.endedWithCR,a.write(E.normalized)}}:{},[a,ne]);return C.useEffect(()=>{a?I.current!==a&&(A.current=!1,a.reset(),I.current=a):I.current=null},[a]),C.useEffect(()=>{},[a]),C.useEffect(()=>{Hs(y)},[y]),C.useEffect(()=>()=>{Hs({})},[]),C.useEffect(()=>{if(!a){N.current=null,W(null),B(null);return}const v=new Th.FitAddon;return a.loadAddon(v),N.current=v,W(v),B(a),V("sync",{immediate:!0,force:!0}),()=>{try{v.dispose()}finally{N.current=null,W(null),B(null)}}},[a,V,W,B]),C.useEffect(()=>{const v=u.current;if(!v)return;let S=null;const k=new ResizeObserver(()=>{S!==null&&cancelAnimationFrame(S),S=requestAnimationFrame(()=>{S=null,V("resize")})});return k.observe(v),()=>{k.disconnect(),S!==null&&cancelAnimationFrame(S)}},[V]),C.useEffect(()=>{if(!a||!e||!t)return;const v=a.onData(S=>{!r||n||T.current||$(S)});return a.attachCustomKeyEventHandler(S=>!r||n||S.type!=="keydown"||T.current||s!=="direct"?!0:S.shiftKey&&S.key==="Enter"?(S.preventDefault(),$("\x1B[13;2u"),!1):!0),()=>{v.dispose(),a.attachCustomKeyEventHandler(()=>!0)}},[a,r,n,s,$]),C.useImperativeHandle(h,()=>({write:v=>a==null?void 0:a.write(v),reset:()=>{a==null||a.reset(),A.current=!1},scrollToBottom:()=>a==null?void 0:a.scrollToBottom(),resize:(v,S)=>a==null?void 0:a.resize(v,S),getTerminal:()=>a??null,getSize:()=>a?{cols:Math.max(2,a.cols),rows:Math.max(2,a.rows)}:null,runPostSelectResize:()=>ne(),scheduleResize:(v,S)=>V(v,S),calculateSizeFromContainer:()=>{var Re,G,ie,J,Q,j,tt,ve,Pe,Se,he,q,lt,bi,yi,kt;const v=u.current,S=a,k=N.current;if(!v||!S)return null;const E=v.getBoundingClientRect();if(E.width===0||E.height===0)return null;const x=S._core;let H;if(k)try{const _e=k.proposeDimensions();if(_e)H=Math.max(2,_e.cols);else{const Gt=((J=(ie=(G=(Re=x==null?void 0:x._renderService)==null?void 0:Re.dimensions)==null?void 0:G.css)==null?void 0:ie.cell)==null?void 0:J.width)??9;H=Math.max(2,Math.floor(E.width/Gt))}}catch{const _e=((ve=(tt=(j=(Q=x==null?void 0:x._renderService)==null?void 0:Q.dimensions)==null?void 0:j.css)==null?void 0:tt.cell)==null?void 0:ve.width)??9;H=Math.max(2,Math.floor(E.width/_e))}else{const _e=((q=(he=(Se=(Pe=x==null?void 0:x._renderService)==null?void 0:Pe.dimensions)==null?void 0:Se.css)==null?void 0:he.cell)==null?void 0:q.width)??9;H=Math.max(2,Math.floor(E.width/_e))}const Y=((kt=(yi=(bi=(lt=x==null?void 0:x._renderService)==null?void 0:lt.dimensions)==null?void 0:bi.css)==null?void 0:yi.cell)==null?void 0:kt.height)??17,te=Math.max(2,Math.floor(E.height/Y));return{cols:H,rows:te}}}),[a,ne,V]),M.jsx("div",{ref:u,className:"h-full w-full relative",style:{backgroundColor:c.background},children:M.jsx("div",{ref:d,className:"absolute inset-0"})})});On.displayName="Terminal";function zh(){const e=Cs.getState().settings;return(e==null?void 0:e.siteName)||"tmex"}function Nr(e){const t=e==null?void 0:e.trim();return t&&t.length>0?t:"?"}function Nn({paneIdx:e,windowIdx:t,paneTitle:i,windowName:s,deviceName:r}){const n=t??"?",o=e??"?",l=Nr(i??s),h=Nr(r);return`${n}/${o}: ${l}@${h}`}function Fh(e){const t=zh();return e!=null&&e.trim()?`[${t}]${e}`:t}function Wh(){if(typeof navigator>"u")return!1;const e=navigator.userAgent,t=/iPad|iPhone|iPod/.test(e),i=navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;return t||i}const $h=[{key:"enter",label:"ENTER",payload:"\r"},{key:"ctrl-c",label:"CTRL-C",payload:""},{key:"ctrl-d",label:"CTRL-D",payload:""},{key:"up",label:"↑",payload:"\x1B[A"},{key:"down",label:"↓",payload:"\x1B[B"},{key:"left",label:"←",payload:"\x1B[D"},{key:"right",label:"→",payload:"\x1B[C"},{key:"shift-enter",label:"SHIFT+ENTER",payload:"\x1B[13;2u"},{key:"tab",label:"TAB",payload:" "},{key:"backspace",label:"BACKSPACE",payload:"\b"},{key:"esc",label:"ESC",payload:"\x1B"},{key:"delete",label:"DELETE",payload:""},{key:":",label:":",payload:":"},{key:"/",label:"/",payload:"/"},{key:"'",label:"'",payload:"'"},{key:'"',label:'"',payload:'"'},{key:"`",label:"`",payload:"`"}],Hr=C.memo(function({onSend:t,onFocusEditor:i,disabled:s,isMobile:r,inputMode:n}){return M.jsx("div",{className:"terminal-shortcuts-strip my-2 bg-muted rounded-xl","data-testid":"terminal-shortcuts-strip",children:M.jsx("div",{className:"shortcut-row flex items-center gap-1.5 p-2 overflow-x-auto scrollbar-thin","data-testid":"editor-shortcuts-row",children:$h.map(o=>M.jsx(ft,{variant:"secondary",size:"sm",className:"h-7 min-w-9 px-2.5 rounded-full text-[11px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3",title:o.label,"aria-label":o.label,"data-testid":`editor-shortcut-${o.key}`,onPointerDown:l=>l.preventDefault(),onClick:()=>{t(o.payload),r&&n==="editor"&&(i==null||i())},disabled:s,children:o.label},o.key))})})});function Yh(){var Ns;const{t:e}=$r(),{deviceId:t,windowId:i,paneId:s}=xs(),r=Gn(),n=C.useRef(null),o=C.useRef(null),l=C.useRef(null),h=C.useRef(null),a=C.useRef(!1),d=C.useRef(!1),c=C.useRef(null),_=Ie(m=>m.selectPane),u=Ie(m=>t?m.snapshots[t]:void 0),f=Ie(m=>{var O;return t?(O=m.deviceErrors)==null?void 0:O[t]:void 0}),p=Ie(m=>{var O;return t?((O=m.deviceConnected)==null?void 0:O[t])??!1:!1}),b=Cs(m=>{var O;return((O=m.settings)==null?void 0:O.siteName)??"tmex"}),g=C.useMemo(()=>ks(s),[s]),T=C.useMemo(()=>t&&g?`${t}:${g}`:null,[t,g]),[D,P]=C.useState(!1),[A,I]=C.useState(""),[N,$]=C.useState(!1),V=C.useRef(!1),ne=!p||!g,[W,B]=C.useState(0),[y,v]=C.useState(0),[S,k]=C.useState(!1),E=Ve(m=>m.inputMode),x=Ve(m=>m.theme),H=Ve(m=>m.editorSendWithEnter),Y=Ve(m=>m.setEditorSendWithEnter),te=Ve(m=>m.addEditorHistory),Re=Ve(m=>m.setEditorDraft),G=Ve(m=>m.removeEditorDraft),ie=Ve(m=>T?m.editorDrafts[T]??"":""),J=C.useMemo(()=>Wh(),[]),Q=D&&E==="editor"&&J&&N,j=(Ns=u==null?void 0:u.session)==null?void 0:Ns.windows,tt=x==="light"?An:In,{data:ve}=Jn({queryKey:["devices"],queryFn:async()=>{const m=await fetch("/api/devices");if(!m.ok)throw new Error("Failed to fetch devices");return m.json()},throwOnError:!1}),Pe=C.useMemo(()=>{if(t)return ve==null?void 0:ve.devices.find(m=>m.id===t)},[t,ve==null?void 0:ve.devices]),Se=C.useMemo(()=>{if(!(!i||!j))return j.find(m=>m.id===i)},[i,j]),he=C.useMemo(()=>{if(!(!g||!Se))return Se.panes.find(m=>m.id===g)},[g,Se]),q=!!j,kt=!!(q&&!!i&&!Se||q&&!!i&&!!g&&!!Se&&!he?e("wsError.checkGateway"):null),_e=!!(p&&g&&!kt),Gt=C.useMemo(()=>{if(!Se||!he)return null;const m=(Pe==null?void 0:Pe.name)??t;return Nn({paneIdx:he.index,windowIdx:Se.index,paneTitle:he.title,windowName:Se.name,deviceName:m})},[Pe==null?void 0:Pe.name,t,he,Se]),Hn=C.useCallback((m,O)=>{!t||!g||Ie.getState().resizePane(t,g,m,O)},[t,g]),zn=C.useCallback((m,O)=>{!t||!g||Ie.getState().syncPaneSize(t,g,m,O)},[t,g]);C.useEffect(()=>{const m=()=>{P(window.innerWidth<768||"ontouchstart"in window)};return m(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]),C.useEffect(()=>{if(!D||!J||d.current)return;d.current=!0;const m=()=>{window.scrollTo(0,1)},O=window.requestAnimationFrame(m),z=window.setTimeout(m,120),fe=window.setTimeout(m,420);return()=>{window.cancelAnimationFrame(O),window.clearTimeout(z),window.clearTimeout(fe)}},[J,D]),C.useEffect(()=>{E!=="editor"&&$(!1)},[E]),C.useEffect(()=>{var fe,oe;if(!(D&&J&&E==="editor"&&N)){B(0);return}let m=null;const O=()=>{const $e=window.visualViewport,ht=($e==null?void 0:$e.height)??window.innerHeight,Dt=($e==null?void 0:$e.offsetTop)??0,jn=Math.max(0,Math.round(window.innerHeight-ht-Dt));B(jn)},z=()=>{m===null&&(m=window.requestAnimationFrame(()=>{m=null,O()}))};return O(),(fe=window.visualViewport)==null||fe.addEventListener("resize",z),(oe=window.visualViewport)==null||oe.addEventListener("scroll",z),window.addEventListener("resize",z),()=>{var $e,ht;($e=window.visualViewport)==null||$e.removeEventListener("resize",z),(ht=window.visualViewport)==null||ht.removeEventListener("scroll",z),window.removeEventListener("resize",z),m!==null&&window.cancelAnimationFrame(m)}},[E,N,J,D]),C.useEffect(()=>{if(!Q){v(0);return}const m=o.current;if(!m)return;const O=()=>{v(Math.ceil(m.getBoundingClientRect().height))};O();const z=new ResizeObserver(O);return z.observe(m),()=>z.disconnect()},[Q]),C.useEffect(()=>{t&&(a.current=!1,Rt.current=null,Bt.current=null,c.current=null,Et.current=[])},[t]),C.useEffect(()=>{p||(a.current=!1)},[p]),C.useEffect(()=>{if(!t||!p||!i||!j)return;if(j.length===0){r("/devices",{replace:!0});return}const m=j.find(z=>z.id===i);if(!m)return;if(!g){const z=m.panes.find(fe=>fe.active)??m.panes[0];z&&r(`/devices/${t}/windows/${i}/panes/${Mt(z.id)}`,{replace:!0});return}if(!m.panes.find(z=>z.id===g)){const z=m.panes.find(fe=>fe.active)??m.panes[0];z&&r(`/devices/${t}/windows/${i}/panes/${Mt(z.id)}`,{replace:!0});return}},[t,p,j,i,g,r]),C.useEffect(()=>{if(!t||!p||!j||j.length===0||i&&g||a.current)return;const m=j.find(z=>z.active)??j[0],O=m.panes.find(z=>z.active)??m.panes[0];O&&(a.current=!0,r(`/devices/${t}/windows/${m.id}/panes/${Mt(O.id)}`,{replace:!0}))},[p,t,r,g,i,j]),C.useEffect(()=>{var z;if(!t||!i||!g||ne||!p)return;const m=Ie.getState().selectedPanes[t];if(m&&m.windowId===i&&m.paneId===g)return;const O=((z=h.current)==null?void 0:z.calculateSizeFromContainer())??void 0;Ci(i,g),_(t,i,g,O)},[p,t,ne,g,_,i]);const Et=C.useRef([]),Ci=C.useCallback((m,O)=>{const z=Date.now(),fe=[...Et.current.filter(oe=>z-oe.at<2e3),{windowId:m,paneId:O,at:z}];Et.current=fe.slice(-8)},[]),De=Ie(m=>t?m.activePaneFromEvent[t]:void 0),Rt=C.useRef(null);C.useEffect(()=>{var O;if(!t||!p||!i||!g||!De)return;{const z=Date.now();if(Et.current.some(oe=>oe.windowId===De.windowId&&oe.paneId===De.paneId&&z-oe.at<1200))return}if(De.windowId===i&&De.paneId===g||Rt.current&&Rt.current.windowId===De.windowId&&Rt.current.paneId===De.paneId)return;Rt.current={...De};const m=((O=h.current)==null?void 0:O.calculateSizeFromContainer())??void 0;Ci(De.windowId,De.paneId),_(t,De.windowId,De.paneId,m),r(`/devices/${t}/windows/${De.windowId}/panes/${Mt(De.paneId)}`,{replace:!0})},[t,p,i,g,De,_,r]);const Bt=C.useRef(null);C.useEffect(()=>{var ht;if(!t||!p||!j||j.length===0||c.current)return;const m=Et.current,O=m.length>0?m[m.length-1]:null;if(O&&Date.now()-O.at<1200)return;const z=j.find(Dt=>Dt.active);if(!z)return;const fe=z.panes.find(Dt=>Dt.active);if(!fe)return;const oe={windowId:z.id,paneId:fe.id};if(Bt.current&&Bt.current.windowId===oe.windowId&&Bt.current.paneId===oe.paneId||(Bt.current={...oe},i===oe.windowId&&g===oe.paneId))return;const $e=((ht=h.current)==null?void 0:ht.calculateSizeFromContainer())??void 0;Ci(oe.windowId,oe.paneId),_(t,oe.windowId,oe.paneId,$e),r(`/devices/${t}/windows/${oe.windowId}/panes/${Mt(oe.paneId)}`,{replace:!0})},[t,p,j,i,g,_,r]),C.useEffect(()=>{var fe;if(!_e||!he||ne)return;const m=(fe=h.current)==null?void 0:fe.getTerminal();if(!m)return;const O=Math.max(2,Math.floor(he.width||0)),z=Math.max(2,Math.floor(he.height||0));!O||!z||m.cols===O&&m.rows===z||m.resize(O,z)},[_e,ne,he]),C.useEffect(()=>{const m=window.requestAnimationFrame(()=>{var z;(z=h.current)==null||z.scrollToBottom()}),O=window.setTimeout(()=>{var z;(z=h.current)==null||z.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(m),window.clearTimeout(O)}},[E]),C.useEffect(()=>{f!=null&&f.message&&xi.error(f.message)},[f==null?void 0:f.message]),C.useEffect(()=>(document.title=Fh(Gt),()=>{document.title=b}),[b,Gt]),C.useEffect(()=>{const m=()=>{var O;(O=h.current)==null||O.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",m),()=>{window.removeEventListener("tmex:jump-to-latest",m)}},[]),C.useEffect(()=>{const m=O=>{const{deviceId:z,windowId:fe,paneId:oe}=O.detail;z===t&&(c.current={windowId:fe,paneId:oe})};return window.addEventListener("tmex:user-initiated-selection",m),()=>{window.removeEventListener("tmex:user-initiated-selection",m)}},[t]),C.useEffect(()=>{I(ie)},[ie]);const Os=C.useCallback(m=>{if(!t||!g||!_e)return;Ie.getState().sendInput(t,g,m,!1)},[_e,t,g]),Fn=C.useCallback(()=>{if(!_e){xi.error(e("wsError.checkGateway"));return}if(!t||!g||!A.trim())return;k(!0),window.setTimeout(()=>k(!1),150);const m=H?`${A}\r`:A;Ie.getState().sendInput(t,g,m,!1),te(A),T&&G(T),I("")},[te,_e,t,T,H,A,G,g,e]),Wn=C.useCallback(()=>{if(!_e){xi.error(e("wsError.checkGateway"));return}if(!t||!g||!A.trim())return;k(!0),window.setTimeout(()=>k(!1),150);const m=A.split(/\r?\n/),O=Ie.getState();for(const z of m)z.trim()&&O.sendInput(t,g,`${z}\r`,!1);te(A),T&&G(T),I("")},[te,_e,t,T,A,G,g,e]),$n=C.useCallback(m=>{if($(!0),!(D&&J))return;const O=m.currentTarget;window.requestAnimationFrame(()=>{O.scrollIntoView({block:"nearest",inline:"nearest"})}),window.setTimeout(()=>{window.scrollTo(0,1)},60)},[J,D]),Kn=C.useCallback(()=>{$(!1)},[]),Un=C.useCallback(()=>{var m;(m=l.current)==null||m.focus({preventScroll:!0})},[]);if(!t)return M.jsx("div",{className:"flex h-full items-center justify-center p-4",children:M.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:e("device.noDevices")})});const qn=!p&&!f;return M.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[M.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${D&&E==="editor"&&!Q?"pb-1":""}`,style:{paddingBottom:Q?`${y+60}px`:void 0},children:[M.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:tt.background},children:p&&g?M.jsx("div",{ref:n,className:"flex-1 w-full",children:M.jsx(On,{ref:h,deviceId:t,paneId:g,theme:x,inputMode:E,deviceConnected:p,isSelectionInvalid:kt,onResize:Hn,onSync:zn},`${t}:${g}`)}):M.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:M.jsx("div",{className:"max-w-sm space-y-4",children:p?i?M.jsxs(M.Fragment,{children:[M.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:M.jsx(ki,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),M.jsx("h3",{className:"text-lg font-medium",children:e("terminal.connecting")})]}):M.jsxs(M.Fragment,{children:[M.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:M.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),M.jsx("h3",{className:"text-lg font-medium",children:e("window.noWindowSelected")}),M.jsx("p",{className:"text-sm text-muted-foreground",children:e("window.selectWindowToStart")})]}):M.jsxs(M.Fragment,{children:[M.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:M.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),M.jsx("h3",{className:"text-lg font-medium",children:e("device.disconnected")}),M.jsx("p",{className:"text-sm text-muted-foreground",children:e("device.connectToStart")})]})})})}),qn&&M.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:M.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm",children:[M.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),M.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:e("terminal.connecting")})]})})]}),E==="direct"&&M.jsx("div",{className:"",children:M.jsx(Hr,{onSend:Os,disabled:!_e,isMobile:D,inputMode:E})}),E==="editor"&&M.jsxs("div",{ref:o,className:`editor-mode-input bg-card/85 backdrop-blur-sm ${Q?"fixed left-0 right-0 z-50":""}`,style:Q?{bottom:`${W}px`}:void 0,children:[D&&M.jsx(Hr,{onSend:Os,onFocusEditor:Un,disabled:!_e,isMobile:D,inputMode:E}),M.jsx("textarea",{ref:l,"data-testid":"editor-input",className:"min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring",value:A,onChange:m=>{const O=m.target.value;if(I(O),!!T){if(O){Re(T,O);return}G(T)}},placeholder:e("terminal.inputPlaceholder"),onFocus:$n,onBlur:Kn,onCompositionStart:()=>{V.current=!0},onCompositionEnd:()=>{V.current=!1}}),M.jsx("div",{className:"actions mt-2",children:M.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[M.jsxs("div",{className:"send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground","data-testid":"editor-send-with-enter-toggle",children:[M.jsx(ao,{size:"sm",checked:H,onCheckedChange:m=>Y(!!m)}),M.jsx("span",{children:e("terminal.editorSendWithEnter")})]}),M.jsxs(ft,{variant:"outline",size:"sm","data-testid":"editor-clear",onPointerDown:m=>m.preventDefault(),onClick:()=>{var m;I(""),T&&G(T),D&&E==="editor"&&((m=l.current)==null||m.focus({preventScroll:!0}))},title:e("terminal.clear"),children:[M.jsx(Zn,{className:"h-4 w-4"}),e("terminal.clear")]}),M.jsxs(ft,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onPointerDown:m=>m.preventDefault(),onClick:()=>{var m;Wn(),D&&E==="editor"&&((m=l.current)==null||m.focus({preventScroll:!0}))},disabled:!_e||S,children:[S?M.jsx(ki,{className:"h-4 w-4 animate-spin"}):M.jsx(zs,{className:"h-4 w-4"}),e("terminal.editorSendLineByLine")]}),M.jsxs(ft,{variant:"default",size:"sm","data-testid":"editor-send",onPointerDown:m=>m.preventDefault(),onClick:()=>{var m;Fn(),D&&E==="editor"&&((m=l.current)==null||m.focus({preventScroll:!0}))},disabled:!_e||S,children:[S?M.jsx(ki,{className:"h-4 w-4 animate-spin"}):M.jsx(zs,{className:"h-4 w-4"}),e("common.send")]})]})})]})]})}function Xh(){const{deviceId:e,windowId:t,paneId:i}=xs(),s=i?ks(i):void 0,r=Ie(d=>d.snapshots),n=Cs(d=>{var c;return((c=d.settings)==null?void 0:c.siteName)??"tmex"}),o=e?r[e]:void 0,l=C.useMemo(()=>{var d;if(!(!t||!((d=o==null?void 0:o.session)!=null&&d.windows)))return o.session.windows.find(c=>c.id===t)},[t,o]),h=C.useMemo(()=>{if(!(!s||!l))return l.panes.find(d=>d.id===s)},[s,l]),a=C.useMemo(()=>l&&h?Nn({paneIdx:h.index,windowIdx:l.index,paneTitle:h.title,windowName:l.name,deviceName:n}):e??"",[l,h,n,e]);return M.jsx(M.Fragment,{children:a})}function Gh(){const{t:e}=$r(),{deviceId:t,paneId:i}=xs(),s=i?ks(i):void 0,r=Ve(f=>f.inputMode),n=Ve(f=>f.setInputMode),o=Ie(f=>{var p;return t?((p=f.deviceConnected)==null?void 0:p[t])??!1:!1}),[l,h]=C.useState(!1),a=!!(s&&o),d=()=>{n(r==="direct"?"editor":"direct")},c=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},_=()=>{h(!0)},u=()=>{window.location.reload()};return M.jsxs(M.Fragment,{children:[M.jsx(ft,{variant:"ghost",size:"icon-sm",onClick:_,"aria-label":e("nav.refreshPage"),title:e("nav.refreshPage"),children:M.jsx(fo,{className:"h-4 w-4"})}),M.jsx(ft,{variant:"ghost",size:"icon-sm",onClick:d,disabled:!a,"data-testid":"terminal-input-mode-toggle","aria-label":e(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:e(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:r==="direct"?M.jsx(uo,{className:"h-4 w-4"}):M.jsx(go,{className:"h-4 w-4"})}),M.jsx(ft,{variant:"ghost",size:"icon-sm",onClick:c,disabled:!a,"aria-label":e("nav.jumpToLatest"),title:e("nav.jumpToLatest"),children:M.jsx(ho,{className:"h-4 w-4"})}),M.jsx(Qn,{open:l,onOpenChange:h,children:M.jsxs(eo,{children:[M.jsxs(to,{children:[M.jsx(io,{children:e("nav.refreshPage")}),M.jsx(so,{children:e("nav.refreshPageConfirm")})]}),M.jsxs(ro,{children:[M.jsx(no,{onClick:()=>h(!1),children:e("common.cancel")}),M.jsx(oo,{onClick:u,children:e("common.confirm")})]})]})})]})}export{Gh as PageActions,Xh as PageTitle,Yh as default};
267
+ //# sourceMappingURL=DevicePage-TP91rSIc.js.map