@xterm/headless 6.1.0-beta.183 → 6.1.0-beta.185
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.
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
15
15
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
16
16
|
*--------------------------------------------------------------------------------------------*/
|
|
17
|
-
var Jt=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var R=(n,r,e,t)=>{for(var i=t>1?void 0:t?Qt(r,e):r,s=n.length-1,a;s>=0;s--)(a=n[s])&&(i=(t?a(r,e,i):a(i))||i);return t&&i&&Jt(r,e,i),i},T=(n,r)=>(e,t)=>r(e,t,n);function w(n){return n>65535?(n-=65536,String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)}function F(n,r=0,e=n.length){let t="";for(let i=r;i<e;++i){let s=n[i];s>65535?(s-=65536,t+=String.fromCharCode((s>>10)+55296)+String.fromCharCode(s%1024+56320)):t+=String.fromCharCode(s)}return t}var ve=class{constructor(){this._interim=0}clear(){this._interim=0}decode(r,e){let t=r.length;if(!t)return 0;let i=0,s=0;if(this._interim){let a=r.charCodeAt(s++);56320<=a&&a<=57343?e[i++]=(this._interim-55296)*1024+a-56320+65536:(e[i++]=this._interim,e[i++]=a),this._interim=0}for(let a=s;a<t;++a){let l=r.charCodeAt(a);if(55296<=l&&l<=56319){if(++a>=t)return this._interim=l,i;let c=r.charCodeAt(a);56320<=c&&c<=57343?e[i++]=(l-55296)*1024+c-56320+65536:(e[i++]=l,e[i++]=c);continue}l!==65279&&(e[i++]=l)}return i}},ge=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(r,e){let t=r.length;if(!t)return 0;let i=0,s,a,l,c,u=0,_=0;if(this.interim[0]){let m=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let f=0,h;for(;(h=this.interim[++f]&63)&&f<4;)p<<=6,p|=h;let S=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=S-f;for(;_<E;){if(_>=t)return 0;if(h=r[_++],(h&192)!==128){_--,m=!0;break}else this.interim[f++]=h,p<<=6,p|=h&63}m||(S===2?p<128?_--:e[i++]=p:S===3?p<2048||p>=55296&&p<=57343||p===65279||(e[i++]=p):p<65536||p>1114111||(e[i++]=p)),this.interim.fill(0)}let o=t-4,d=_;for(;d<t;){for(;d<o&&!((s=r[d])&128)&&!((a=r[d+1])&128)&&!((l=r[d+2])&128)&&!((c=r[d+3])&128);)e[i++]=s,e[i++]=a,e[i++]=l,e[i++]=c,d+=4;if(s=r[d++],s<128)e[i++]=s;else if((s&224)===192){if(d>=t)return this.interim[0]=s,i;if(a=r[d++],(a&192)!==128){d--;continue}if(u=(s&31)<<6|a&63,u<128){d--;continue}e[i++]=u}else if((s&240)===224){if(d>=t)return this.interim[0]=s,i;if(a=r[d++],(a&192)!==128){d--;continue}if(d>=t)return this.interim[0]=s,this.interim[1]=a,i;if(l=r[d++],(l&192)!==128){d--;continue}if(u=(s&15)<<12|(a&63)<<6|l&63,u<2048||u>=55296&&u<=57343||u===65279)continue;e[i++]=u}else if((s&248)===240){if(d>=t)return this.interim[0]=s,i;if(a=r[d++],(a&192)!==128){d--;continue}if(d>=t)return this.interim[0]=s,this.interim[1]=a,i;if(l=r[d++],(l&192)!==128){d--;continue}if(d>=t)return this.interim[0]=s,this.interim[1]=a,this.interim[2]=l,i;if(c=r[d++],(c&192)!==128){d--;continue}if(u=(s&7)<<18|(a&63)<<12|(l&63)<<6|c&63,u<65536||u>1114111)continue;e[i++]=u}}return i}};var q=class n{constructor(){this.fg=0;this.bg=0;this.extended=new V}static toColorRGB(r){return[r>>>16&255,r>>>8&255,r&255]}static fromColorRGB(r){return(r[0]&255)<<16|(r[1]&255)<<8|r[2]&255}clone(){let r=new n;return r.fg=this.fg,r.bg=this.bg,r.extended=this.extended.clone(),r}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}},V=class n{constructor(r=0,e=0){this._ext=0;this._urlId=0;this._ext=r,this._urlId=e}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(r){this._ext=r}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(r){this._ext&=-469762049,this._ext|=r<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(r){this._ext&=-67108864,this._ext|=r&67108863}get urlId(){return this._urlId}set urlId(r){this._urlId=r}get underlineVariantOffset(){let r=(this._ext&3758096384)>>29;return r<0?r^4294967288:r}set underlineVariantOffset(r){this._ext&=536870911,this._ext|=r<<29&3758096384}clone(){return new n(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}};var A=class n extends q{constructor(){super(...arguments);this.content=0;this.fg=0;this.bg=0;this.extended=new V;this.combinedData=""}static fromCharData(e){let t=new n;return t.setFromCharData(e),t}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?w(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(i-55296)*1024+s-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}attributesEquals(e){if(this.getFgColorMode()!==e.getFgColorMode()||this.getFgColor()!==e.getFgColor()||this.getBgColorMode()!==e.getBgColorMode()||this.getBgColor()!==e.getBgColor()||this.isInverse()!==e.isInverse()||this.isBold()!==e.isBold()||this.isUnderline()!==e.isUnderline())return!1;if(this.isUnderline()){if(this.getUnderlineStyle()!==e.getUnderlineStyle())return!1;let t=this.isUnderlineColorDefault(),i=e.isUnderlineColorDefault();if(!(t&&i)&&(t!==i||this.getUnderlineColor()!==e.getUnderlineColor()||this.getUnderlineColorMode()!==e.getUnderlineColorMode()))return!1}return!(this.isOverline()!==e.isOverline()||this.isBlink()!==e.isBlink()||this.isInvisible()!==e.isInvisible()||this.isItalic()!==e.isItalic()||this.isDim()!==e.isDim()||this.isStrikethrough()!==e.isStrikethrough())}};var Ie=class{constructor(r){this._line=r}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(r,e){if(!(r<0||r>=this._line.length))return e?(this._line.loadCell(r,e),e):this._line.loadCell(r,new A)}translateToString(r,e,t){return this._line.translateToString(r,e,t)}};var ae=class{constructor(r,e){this._buffer=r;this.type=e}init(r){return this._buffer=r,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(r){let e=this._buffer.lines.get(r);if(e)return new Ie(e)}getNullCell(){return new A}};function W(n){return{dispose:n}}function vt(n){if(!n)return n;if(Array.isArray(n)){for(let r of n)r.dispose();return[]}return n.dispose(),n}var oe=class{constructor(){this._disposables=new Set;this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(r){return this._isDisposed?r.dispose():this._disposables.add(r),r}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let r of this._disposables)r.dispose();this._disposables.clear()}}clear(){for(let r of this._disposables)r.dispose();this._disposables.clear()}},g=class{constructor(){this._store=new oe}dispose(){this._store.dispose()}_register(r){return this._store.add(r)}};g.None=Object.freeze({dispose(){}});var Se=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(r){this._isDisposed||r===this._value||(this._value?.dispose(),this._value=r)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}};var b=class{constructor(){this._listeners=[];this._disposed=!1}get event(){return this._event?this._event:(this._event=(r,e,t)=>{if(this._disposed)return W(()=>{});let i={fn:r,thisArgs:e};this._listeners.push(i);let s=W(()=>{let a=this._listeners.indexOf(i);a!==-1&&this._listeners.splice(a,1)});return t&&(Array.isArray(t)?t.push(s):t.add(s)),s},this._event)}fire(r){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:e,thisArgs:t}=this._listeners[0];e.call(t,r);return}default:{let e=this._listeners.slice();for(let{fn:t,thisArgs:i}of e)t.call(i,r)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},B;(i=>{function n(s,a){return s(l=>a.fire(l))}i.forward=n;function r(s,a){return(l,c,u)=>s(_=>l.call(c,a(_)),void 0,u)}i.map=r;function e(...s){return(a,l,c)=>{let u=new oe;for(let _ of s)u.add(_(o=>a.call(l,o)));return c&&(Array.isArray(c)?c.push(u):c.add(u)),u}}i.any=e;function t(s,a,l){return a(l),s(c=>a(c))}i.runAndSubscribe=t})(B||={});var xe=class extends g{constructor(e){super();this._core=e;this._onBufferChange=this._register(new b);this.onBufferChange=this._onBufferChange.event;this._normal=new ae(this._core.buffers.normal,"normal"),this._alternate=new ae(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)}};var Ce=class{constructor(r){this._core=r}registerCsiHandler(r,e){return this._core.registerCsiHandler(r,t=>e(t.toArray()))}addCsiHandler(r,e){return this.registerCsiHandler(r,e)}registerDcsHandler(r,e){return this._core.registerDcsHandler(r,(t,i)=>e(t,i.toArray()))}addDcsHandler(r,e){return this.registerDcsHandler(r,e)}registerEscHandler(r,e){return this._core.registerEscHandler(r,e)}addEscHandler(r,e){return this.registerEscHandler(r,e)}registerOscHandler(r,e){return this._core.registerOscHandler(r,e)}addOscHandler(r,e){return this.registerOscHandler(r,e)}registerApcHandler(r,e){return this._core.registerApcHandler(r,e)}};var Ee=class{constructor(r){this._core=r}register(r){this._core.unicodeService.register(r)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(r){this._core.unicodeService.activeVersion=r}};var v=3;var x=Object.freeze(new q),ye=0,gt=new A,Je=2,G=class n{constructor(r,e,t=!1){this.isWrapped=t;this._combined={};this._extendedAttrs={};this._data=new Uint32Array(r*v);let i=e??A.fromCharData([0,"",1,0]);for(let s=0;s<r;++s)this.setCell(s,i);this.length=r}get(r){let e=this._data[r*v+0],t=e&2097151;return[this._data[r*v+1],e&2097152?this._combined[r]:t?w(t):"",e>>22,e&2097152?this._combined[r].charCodeAt(this._combined[r].length-1):t]}set(r,e){this._data[r*v+1]=e[0],e[1].length>1?(this._combined[r]=e[1],this._data[r*v+0]=r|2097152|e[2]<<22):this._data[r*v+0]=e[1].charCodeAt(0)|e[2]<<22}getWidth(r){return this._data[r*v+0]>>22}hasWidth(r){return this._data[r*v+0]&12582912}getFg(r){return this._data[r*v+1]}getBg(r){return this._data[r*v+2]}hasContent(r){return this._data[r*v+0]&4194303}getCodePoint(r){let e=this._data[r*v+0];return e&2097152?this._combined[r].charCodeAt(this._combined[r].length-1):e&2097151}isCombined(r){return this._data[r*v+0]&2097152}getString(r){let e=this._data[r*v+0];return e&2097152?this._combined[r]:e&2097151?w(e&2097151):""}isProtected(r){return this._data[r*v+2]&536870912}loadCell(r,e){return ye=r*v,e.content=this._data[ye+0],e.fg=this._data[ye+1],e.bg=this._data[ye+2],e.content&2097152&&(e.combinedData=this._combined[r]),e.bg&268435456&&(e.extended=this._extendedAttrs[r]),e}setCell(r,e){e.content&2097152&&(this._combined[r]=e.combinedData),e.bg&268435456&&(this._extendedAttrs[r]=e.extended),this._data[r*v+0]=e.content,this._data[r*v+1]=e.fg,this._data[r*v+2]=e.bg}setCellFromCodepoint(r,e,t,i){i.bg&268435456&&(this._extendedAttrs[r]=i.extended),this._data[r*v+0]=e|t<<22,this._data[r*v+1]=i.fg,this._data[r*v+2]=i.bg}addCodepointToCell(r,e,t){let i=this._data[r*v+0];i&2097152?this._combined[r]+=w(e):i&2097151?(this._combined[r]=w(i&2097151)+w(e),i&=-2097152,i|=2097152):i=e|1<<22,t&&(i&=-12582913,i|=t<<22),this._data[r*v+0]=i}insertCells(r,e,t){if(r%=this.length,r&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r-1,0,1,t),e<this.length-r){for(let i=this.length-r-e-1;i>=0;--i)this.setCell(r+e+i,this.loadCell(r+i,gt));for(let i=0;i<e;++i)this.setCell(r+i,t)}else for(let i=r;i<this.length;++i)this.setCell(i,t);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,t)}deleteCells(r,e,t){if(r%=this.length,e<this.length-r){for(let i=0;i<this.length-r-e;++i)this.setCell(r+i,this.loadCell(r+e+i,gt));for(let i=this.length-e;i<this.length;++i)this.setCell(i,t)}else for(let i=r;i<this.length;++i)this.setCell(i,t);r&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r-1,0,1,t),this.getWidth(r)===0&&!this.hasContent(r)&&this.setCellFromCodepoint(r,0,1,t)}replaceCells(r,e,t,i=!1){if(i){for(r&&this.getWidth(r-1)===2&&!this.isProtected(r-1)&&this.setCellFromCodepoint(r-1,0,1,t),e<this.length&&this.getWidth(e-1)===2&&!this.isProtected(e)&&this.setCellFromCodepoint(e,0,1,t);r<e&&r<this.length;)this.isProtected(r)||this.setCell(r,t),r++;return}for(r&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r-1,0,1,t),e<this.length&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e,0,1,t);r<e&&r<this.length;)this.setCell(r++,t)}resize(r,e){if(r===this.length)return this._data.length*4*Je<this._data.buffer.byteLength;let t=r*v;if(r>this.length){if(this._data.buffer.byteLength>=t*4)this._data=new Uint32Array(this._data.buffer,0,t);else{let i=new Uint32Array(t);i.set(this._data),this._data=i}for(let i=this.length;i<r;++i)this.setCell(i,e)}else{this._data=this._data.subarray(0,t);let i=Object.keys(this._combined);for(let a=0;a<i.length;a++){let l=parseInt(i[a],10);l>=r&&delete this._combined[l]}let s=Object.keys(this._extendedAttrs);for(let a=0;a<s.length;a++){let l=parseInt(s[a],10);l>=r&&delete this._extendedAttrs[l]}}return this.length=r,t*4*Je<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Je<this._data.buffer.byteLength){let r=new Uint32Array(this._data.length);return r.set(this._data),this._data=r,1}return 0}fill(r,e=!1){if(e){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,r);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,r)}copyFrom(r){this.length!==r.length?this._data=new Uint32Array(r._data):this._data.set(r._data),this.length=r.length,this._combined={};for(let e in r._combined)this._combined[e]=r._combined[e];this._extendedAttrs={};for(let e in r._extendedAttrs)this._extendedAttrs[e]=r._extendedAttrs[e];this.isWrapped=r.isWrapped}clone(){let r=new n(0);r._data=new Uint32Array(this._data),r.length=this.length;for(let e in this._combined)r._combined[e]=this._combined[e];for(let e in this._extendedAttrs)r._extendedAttrs[e]=this._extendedAttrs[e];return r.isWrapped=this.isWrapped,r}getTrimmedLength(){for(let r=this.length-1;r>=0;--r)if(this._data[r*v+0]&4194303)return r+(this._data[r*v+0]>>22);return 0}getNoBgTrimmedLength(){for(let r=this.length-1;r>=0;--r)if(this._data[r*v+0]&4194303||this._data[r*v+2]&50331648)return r+(this._data[r*v+0]>>22);return 0}copyCellsFrom(r,e,t,i,s){let a=r._data;if(s)for(let c=i-1;c>=0;c--){for(let u=0;u<v;u++)this._data[(t+c)*v+u]=a[(e+c)*v+u];a[(e+c)*v+2]&268435456&&(this._extendedAttrs[t+c]=r._extendedAttrs[e+c])}else for(let c=0;c<i;c++){for(let u=0;u<v;u++)this._data[(t+c)*v+u]=a[(e+c)*v+u];a[(e+c)*v+2]&268435456&&(this._extendedAttrs[t+c]=r._extendedAttrs[e+c])}let l=Object.keys(r._combined);for(let c=0;c<l.length;c++){let u=parseInt(l[c],10);u>=e&&(this._combined[u-e+t]=r._combined[u])}}translateToString(r,e,t,i){e=e??0,t=t??this.length,r&&(t=Math.min(t,this.getTrimmedLength())),i&&(i.length=0);let s="";for(;e<t;){let a=this._data[e*v+0],l=a&2097151,c=a&2097152?this._combined[e]:l?w(l):" ";if(s+=c,i)for(let u=0;u<c.length;++u)i.push(e);e+=a>>22||1}return i&&i.push(e),s}};var It="di$target",tt="di$dependencies",et=new Map;function St(n){return n[tt]||[]}function L(n){if(et.has(n))return et.get(n);let r=function(e,t,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");tr(r,e,i)};return r._id=n,et.set(n,r),r}function tr(n,r,e){r[It]===r?r[tt].push({id:n,index:e}):(r[tt]=[{id:n,index:e}],r[It]=r)}var H=L("BufferService"),xt=L("CoreMouseService"),Te=L("CoreService"),Ct=L("CharsetService"),Et=L("InstantiationService");var j=L("LogService"),N=L("OptionsService"),yt=L("OscLinkService"),Tt=L("UnicodeService"),jr=L("DecorationService");var rt=class{constructor(...r){this._entries=new Map;for(let[e,t]of r)this.set(e,t)}set(r,e){let t=this._entries.get(r);return this._entries.set(r,e),t}forEach(r){for(let[e,t]of this._entries.entries())r(e,t)}has(r){return this._entries.has(r)}get(r){return this._entries.get(r)}},De=class{constructor(){this._services=new rt;this._services.set(Et,this)}setService(r,e){this._services.set(r,e)}getService(r){return this._services.get(r)}createInstance(r,...e){let t=St(r).sort((a,l)=>a.index-l.index),i=[];for(let a of t){let l=this._services.get(a.id);if(!l)throw new Error(`[createInstance] ${r.name} depends on UNKNOWN service ${a.id._id}.`);i.push(l)}let s=t.length>0?t[0].index:e.length;if(e.length!==s)throw new Error(`[createInstance] First service dependency of ${r.name} at position ${s+1} conflicts with ${e.length} static arguments`);return new r(...e,...i)}};var rr={trace:0,debug:1,info:2,warn:3,error:4,off:5},ir="xterm.js: ",z=class extends g{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=rr[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?"":ir)+t,...i)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};z=R([T(0,N)],z);var ce=class extends g{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 a=t-1;a>=0;a--)this.set(e+a+i,this.get(e+a));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}};var Ae=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),ue=Ae?"node":navigator.userAgent,it=Ae?"node":navigator.platform,ci=ue.includes("Firefox"),ui=ue.includes("Chrome"),hi=ue.includes("Edge"),di=/^((?!chrome|android).)*safari/i.test(ue);var At=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(it),fi=["Windows","Win16","Win32","WinCE"].includes(it),pi=it.indexOf("Linux")>=0,_i=/\bCrOS\b/.test(ue);var Be=class{constructor(r){this._tasks=[];this._i=0;this._logService=r}enqueue(r){this._tasks.push(r),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(r){this._idleCallback=void 0;let e=0,t=0,i=r.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),t=Math.max(e,t),s=r.timeRemaining(),t*1.5>s){i-e<-20&&this._logService.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=s}this.clear()}},st=class extends Be{_requestCallback(r){return setTimeout(()=>r(this._createDeadline(16)))}_cancelCallback(r){clearTimeout(r)}_createDeadline(r){let e=performance.now()+r;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},nt=class extends Be{_requestCallback(r){return requestIdleCallback(r)}_cancelCallback(r){cancelIdleCallback(r)}},Bt=!Ae&&"requestIdleCallback"in window?nt:st;function Pt(n,r,e,t,i,s){let a=[];for(let l=0;l<n.length-1;l++){let c=l,u=n.get(++c);if(!u.isWrapped)continue;let _=[n.get(l)];for(;c<n.length&&u.isWrapped;)_.push(u),u=n.get(++c);if(!s&&t>=l&&t<c){l+=_.length-1;continue}let o=0,d=J(_,o,r),m=1,p=0;for(;m<_.length;){let h=J(_,m,r),S=h-p,E=e-d,O=Math.min(S,E);_[o].copyCellsFrom(_[m],p,d,O,!1),d+=O,d===e&&(o++,d=0),p+=O,p===h&&(m++,p=0),d===0&&o!==0&&_[o-1].getWidth(e-1)===2&&(_[o].copyCellsFrom(_[o-1],e-1,d++,1,!1),_[o-1].setCell(e-1,i))}_[o].replaceCells(d,e,i);let f=0;for(let h=_.length-1;h>0&&(h>o||_[h].getTrimmedLength()===0);h--)f++;f>0&&(a.push(l+_.length-f),a.push(f)),l+=_.length-1}return a}function Ot(n,r){let e=[],t=0,i=r[t],s=0;for(let a=0;a<n.length;a++)if(i===a){let l=r[++t];n.onDeleteEmitter.fire({index:a-s,amount:l}),a+=l-1,s+=l,i=r[++t]}else e.push(a);return{layout:e,countRemoved:s}}function Rt(n,r){let e=[];for(let t=0;t<r.length;t++)e.push(n.get(r[t]));for(let t=0;t<e.length;t++)n.set(t,e[t]);n.length=r.length}function kt(n,r,e){let t=[],i=n.map((c,u)=>J(n,u,r)).reduce((c,u)=>c+u),s=0,a=0,l=0;for(;l<i;){if(i-l<e){t.push(i-l);break}s+=e;let c=J(n,a,r);s>c&&(s-=c,a++);let u=n[a].getWidth(s-1)===2;u&&s--;let _=u?e-1:e;t.push(_),l+=_}return t}function J(n,r,e){if(r===n.length-1)return n[r].getTrimmedLength();let t=!n[r].hasContent(e-1)&&n[r].getWidth(e-1)===1,i=n[r+1].getWidth(0)===2;return t&&i?e-1:e}var Oe=class Oe{constructor(r){this.line=r;this.isDisposed=!1;this._disposables=[];this._id=Oe._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(),vt(this._disposables),this._disposables.length=0)}register(r){return this._disposables.push(r),r}};Oe._nextId=1;var Pe=Oe;var C={},K=C.B;C[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"};C.A={"#":"\xA3"};C.B=void 0;C[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};C.C=C[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};C.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};C.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};C.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};C.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};C.E=C[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};C.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};C.H=C[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};C["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};var wt=4294967295,he=class{constructor(r,e,t,i){this._hasScrollback=r;this._optionsService=e;this._bufferService=t;this._logService=i;this.ydisp=0;this.ybase=0;this.y=0;this.x=0;this.tabs={};this.savedY=0;this.savedX=0;this.savedCurAttrData=x.clone();this.savedCharset=K;this.savedCharsets=[];this.savedGlevel=0;this.savedOriginMode=!1;this.savedWraparoundMode=!0;this.markers=[];this._nullCell=A.fromCharData([0,"",1,0]);this._whitespaceCell=A.fromCharData([0," ",1,32]);this._isClearing=!1;this._memoryCleanupPosition=0;this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ce(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops(),this._memoryCleanupQueue=new Bt(this._logService)}getNullCell(r){return r?(this._nullCell.fg=r.fg,this._nullCell.bg=r.bg,this._nullCell.extended=r.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new V),this._nullCell}getWhitespaceCell(r){return r?(this._whitespaceCell.fg=r.fg,this._whitespaceCell.bg=r.bg,this._whitespaceCell.extended=r.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new V),this._whitespaceCell}getBlankLine(r,e){return new G(this._bufferService.cols,this.getNullCell(r),e)}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(r){if(!this._hasScrollback)return r;let e=r+this._optionsService.rawOptions.scrollback;return e>wt?wt:e}fillViewportRows(r){if(this.lines.length===0){r??=x;let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(r))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new ce(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(r,e){let t=this.getNullCell(x),i=0,s=this._getCorrectBufferLength(e);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<r)for(let l=0;l<this.lines.length;l++)i+=+this.lines.get(l).resize(r,t);let a=0;if(this._rows<e)for(let l=this._rows;l<e;l++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new G(r,t)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new G(r,t)));else for(let l=this._rows;l>e;l--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let l=this.lines.length-s;l>0&&(this.lines.trimStart(l),this.ybase=Math.max(this.ybase-l,0),this.ydisp=Math.max(this.ydisp-l,0),this.savedY=Math.max(this.savedY-l,0)),this.lines.maxLength=s}this.x=Math.min(this.x,r-1),this.y=Math.min(this.y,e-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,r-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(r,e),this._cols>r))for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(r,t);if(this._cols=r,this._rows=e,this.lines.length>0){let a=Math.max(0,this.lines.length-this.ybase-1);this.y=Math.min(this.y,a)}this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let r=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,r=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return r}get _isReflowEnabled(){let r=this._optionsService.rawOptions.windowsPty;return r&&r.buildNumber?this._hasScrollback&&r.backend==="conpty"&&r.buildNumber>=21376:this._hasScrollback}_reflow(r,e){this._cols!==r&&(r>this._cols?this._reflowLarger(r,e):this._reflowSmaller(r,e))}_reflowLarger(r,e){let t=this._optionsService.rawOptions.reflowCursorLine,i=Pt(this.lines,this._cols,r,this.ybase+this.y,this.getNullCell(x),t);if(i.length>0){let s=Ot(this.lines,i);Rt(this.lines,s.layout),this._reflowLargerAdjustViewport(r,e,s.countRemoved)}}_reflowLargerAdjustViewport(r,e,t){let i=this.getNullCell(x),s=t;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new G(r,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-t,0)}_reflowSmaller(r,e){let t=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(x),s=[],a=0;for(let l=this.lines.length-1;l>=0;l--){let c=this.lines.get(l);if(!c||!c.isWrapped&&c.getTrimmedLength()<=r)continue;let u=[c];for(;c.isWrapped&&l>0;)c=this.lines.get(--l),u.unshift(c);if(!t){let I=this.ybase+this.y;if(I>=l&&I<l+u.length)continue}let _=u[u.length-1].getTrimmedLength(),o=kt(u,this._cols,r),d=o.length-u.length,m;this.ybase===0&&this.y!==this.lines.length-1?m=Math.max(0,this.y-this.lines.maxLength+d):m=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let I=0;I<d;I++){let je=this.getBlankLine(x,!0);p.push(je)}p.length>0&&(s.push({start:l+u.length+a,newLines:p}),a+=p.length),u.push(...p);let f=o.length-1,h=o[f];h===0&&(f--,h=o[f]);let S=u.length-d-1,E=_;for(;S>=0;){let I=Math.min(E,h);if(u[f]===void 0)break;if(u[f].copyCellsFrom(u[S],E-I,h-I,I,!0),h-=I,h===0&&(f--,h=o[f]),E-=I,E===0){S--;let je=Math.max(S,0);E=J(u,je,this._cols)}}for(let I=0;I<u.length;I++)o[I]<r&&u[I].setCell(o[I],i);let O=d-m;for(;O-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+e-1)}if(s.length>0){let l=[],c=[];for(let h=0;h<this.lines.length;h++)c.push(this.lines.get(h));let u=this.lines.length,_=u-1,o=0,d=s[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let m=0;for(let h=Math.min(this.lines.maxLength-1,u+a-1);h>=0;h--)if(d&&d.start>_+m){for(let S=d.newLines.length-1;S>=0;S--)this.lines.set(h--,d.newLines[S]);h++,l.push({index:_+1,amount:d.newLines.length}),m+=d.newLines.length,d=s[++o]}else this.lines.set(h,c[_--]);let p=0;for(let h=l.length-1;h>=0;h--)l[h].index+=p,this.lines.onInsertEmitter.fire(l[h]),p+=l[h].amount;let f=Math.max(0,u+a-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(r,e,t=0,i){let s=this.lines.get(r);return s?s.translateToString(e,t,i):""}getWrappedRangeForLine(r){let e=r,t=r;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;t+1<this.lines.length&&this.lines.get(t+1).isWrapped;)t++;return{first:e,last:t}}setupTabStops(r){for(r!=null?this.tabs[r]||(r=this.prevStop(r)):(this.tabs={},r=0);r<this._cols;r+=this._optionsService.rawOptions.tabStopWidth)this.tabs[r]=!0}prevStop(r){for(r??=this.x;!this.tabs[--r]&&r>0;);return r>=this._cols?this._cols-1:r<0?0:r}nextStop(r){for(r??=this.x;!this.tabs[++r]&&r<this._cols;);return r>=this._cols?this._cols-1:r<0?0:r}clearMarkers(r){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===r&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let r=0;r<this.markers.length;r++)this.markers[r].dispose();this.markers.length=0,this._isClearing=!1}addMarker(r){let e=new Pe(r);return this.markers.push(e),e.register(this.lines.onTrim(t=>{e.line-=t,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(t=>{e.line>=t.index&&(e.line+=t.amount)})),e.register(this.lines.onDelete(t=>{e.line>=t.index&&e.line<t.index+t.amount&&e.dispose(),e.line>t.index&&(e.line-=t.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(r){this._isClearing||this.markers.splice(this.markers.indexOf(r),1)}};var Re=class extends g{constructor(e,t,i){super();this._optionsService=e;this._bufferService=t;this._logService=i;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 he(!0,this._optionsService,this._bufferService,this._logService),this._normal.fillViewportRows(),this._alt=new he(!1,this._optionsService,this._bufferService,this._logService),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)}};var ot=2,lt=1,Q=class extends g{constructor(e,t){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,ot),this.rows=Math.max(e.rawOptions.rows||0,lt),this.buffers=this._register(new Re(e,this,t)),this._register(this.buffers.onBufferActivate(i=>{this._onScroll.fire(i.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 a=i.ybase+i.scrollTop,l=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;l===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(l+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=l-a+1;i.lines.shiftElements(a+1,c-1,-1),i.lines.set(l,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))}};Q=R([T(0,N),T(1,j)],Q);var Z={cols:80,rows:24,showCursorImmediately:!1,cursorBlink:!1,blinkIntervalDuration:0,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollbar:{showScrollbar:!0},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:At,windowOptions:{},windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",quirks:{},vtExtensions:{}},nr=["normal","bold","100","200","300","400","500","600","700","800","900"],ke=class extends g{constructor(e){super();this._onOptionChange=this._register(new b);this.onOptionChange=this._onOptionChange.event;let t={...Z};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(W(()=>{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 Z))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Z))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=Z[e]),!ar(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Z[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=nr.includes(t)?t:Z[e];break;case"blinkIntervalDuration":if(t=Math.floor(t),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);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 ar(n){return n==="block"||n==="underline"||n==="bar"}function ee(n,r=5){if(typeof n!="object")return n;let e=Array.isArray(n)?[]:{};for(let t in n)e[t]=r<=1?n[t]:n[t]&&ee(n[t],r-1);return e}var Lt=Object.freeze({insertMode:!1}),Mt=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,colorSchemeUpdates:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,win32InputMode:!1,wraparound:!0}),Ht=()=>({flags:0,mainFlags:0,altFlags:0,mainStack:[],altStack:[]}),te=class extends g{constructor(e,t,i){super();this._bufferService=e;this._logService=t;this._optionsService=i;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.isCursorInitialized=i.rawOptions.showCursorImmediately??!1,this.modes=ee(Lt),this.decPrivateModes=ee(Mt),this.kittyKeyboard=Ht()}reset(){this.modes=ee(Lt),this.decPrivateModes=ee(Mt),this.kittyKeyboard=Ht()}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))}};te=R([T(0,H),T(1,j),T(2,N)],te);var Nt={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:n=>n.button===4||n.action!==1?!1:(n.ctrl=!1,n.alt=!1,n.shift=!1,!0)},VT200:{events:19,restrict:n=>n.action!==32},DRAG:{events:23,restrict:n=>!(n.action===32&&n.button===3)},ANY:{events:31,restrict:n=>!0}};function ct(n,r){let e=(n.ctrl?16:0)|(n.shift?4:0)|(n.alt?8:0);return n.button===4?(e|=64,e|=n.action):(e|=n.button&3,n.button&4&&(e|=64),n.button&8&&(e|=128),n.action===32?e|=32:n.action===0&&!r&&(e|=3)),e}var ut=String.fromCharCode,Ft={DEFAULT:n=>{let r=[ct(n,!1)+32,n.col+32,n.row+32];return r[0]>255||r[1]>255||r[2]>255?"":`\x1B[M${ut(r[0])}${ut(r[1])}${ut(r[2])}`},SGR:n=>{let r=n.action===0&&n.button!==4?"m":"M";return`\x1B[<${ct(n,!0)};${n.col};${n.row}${r}`},SGR_PIXELS:n=>{let r=n.action===0&&n.button!==4?"m":"M";return`\x1B[<${ct(n,!0)};${n.x};${n.y}${r}`}},re=class extends g{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(Nt))this.addProtocol(s,Nt[s]);for(let s of Object.keys(Ft))this.addEncoding(s,Ft[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,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_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)}};re=R([T(0,H),T(1,Te),T(2,N)],re);var ht=[[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]],or=[[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]],y;function lr(n,r){let e=0,t=r.length-1,i;if(n<r[0][0]||n>r[t][1])return!1;for(;t>=e;)if(i=e+t>>1,n>r[i][1])e=i+1;else if(n<r[i][0])t=i-1;else return!0;return!1}var we=class{constructor(){this.version="6";if(!y){y=new Uint8Array(65536),y.fill(1),y[0]=0,y.fill(0,1,32),y.fill(0,127,160),y.fill(2,4352,4448),y[9001]=2,y[9002]=2,y.fill(2,11904,42192),y[12351]=1,y.fill(2,44032,55204),y.fill(2,63744,64256),y.fill(2,65040,65050),y.fill(2,65072,65136),y.fill(2,65280,65377),y.fill(2,65504,65511);for(let r=0;r<ht.length;++r)y.fill(0,ht[r][0],ht[r][1]+1)}}wcwidth(r){return r<32?0:r<127?1:r<65536?y[r]:lr(r,or)?0:r>=131072&&r<=196605||r>=196608&&r<=262141?2:1}charProperties(r,e){let t=this.wcwidth(r),i=t===0&&e!==0;if(i){let s=k.extractWidth(e);s===0?i=!1:s>t&&(t=s)}return k.createPropertyValue(0,t,i)}};var k=class n{constructor(){this._providers=Object.create(null);this._active="";this._onChange=new b;this.onChange=this._onChange.event;let r=new we;this.register(r),this._active=r.version,this._activeProvider=r}static extractShouldJoin(r){return(r&1)!==0}static extractWidth(r){return r>>1&3}static extractCharKind(r){return r>>3}static createPropertyValue(r,e,t=!1){return(r&16777215)<<3|(e&3)<<1|(t?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(r){if(!this._providers[r])throw new Error(`unknown Unicode version "${r}"`);this._active=r,this._activeProvider=this._providers[r],this._onChange.fire(r)}register(r){this._providers[r.version]=r}wcwidth(r){return this._activeProvider.wcwidth(r)}getStringCellWidth(r){let e=0,t=0,i=r.length;for(let s=0;s<i;++s){let a=r.charCodeAt(s);if(55296<=a&&a<=56319){if(++s>=i)return e+this.wcwidth(a);let u=r.charCodeAt(s);56320<=u&&u<=57343?a=(a-55296)*1024+u-56320+65536:e+=this.wcwidth(u)}let l=this.charProperties(a,t),c=n.extractWidth(l);n.extractShouldJoin(l)&&(c-=n.extractWidth(t)),e+=c,t=l}return e}charProperties(r,e){return this._activeProvider.charProperties(r,e)}};var Le=class{constructor(){this.glevel=0;this._charsets=[]}get charsets(){return this._charsets}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(r){this.glevel=r,this.charset=this._charsets[r]}setgCharset(r,e){this._charsets[r]=e,this.glevel===r&&(this.charset=e)}};function dt(n){let e=n.buffer.lines.get(n.buffer.ybase+n.buffer.y-1)?.get(n.cols-1),t=n.buffer.lines.get(n.buffer.ybase+n.buffer.y);t&&e&&(t.isWrapped=e[3]!==0&&e[3]!==32)}var de=2147483647,cr=256,ie=class n{constructor(r=32,e=32){this.maxLength=r;this.maxSubParamsLength=e;if(e>cr)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(r),this.length=0,this._subParams=new Int32Array(e),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(r),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(r){let e=new n;if(!r.length)return e;for(let t=Array.isArray(r[0])?1:0;t<r.length;++t){let i=r[t];if(Array.isArray(i))for(let s=0;s<i.length;++s)e.addSubParam(i[s]);else e.addParam(i)}return e}clone(){let r=new n(this.maxLength,this.maxSubParamsLength);return r.params.set(this.params),r.length=this.length,r._subParams.set(this._subParams),r._subParamsLength=this._subParamsLength,r._subParamsIdx.set(this._subParamsIdx),r._rejectDigits=this._rejectDigits,r._rejectSubDigits=this._rejectSubDigits,r._digitIsSub=this._digitIsSub,r}toArray(){let r=[];for(let e=0;e<this.length;++e){r.push(this.params[e]);let t=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;i-t>0&&r.push(Array.prototype.slice.call(this._subParams,t,i))}return r}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(r){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(r<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=r>de?de:r}addSubParam(r){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(r<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=r>de?de:r,this._subParamsIdx[this.length-1]++}}hasSubParams(r){return(this._subParamsIdx[r]&255)-(this._subParamsIdx[r]>>8)>0}getSubParams(r){let e=this._subParamsIdx[r]>>8,t=this._subParamsIdx[r]&255;return t-e>0?this._subParams.subarray(e,t):null}getSubParamsAll(){let r={};for(let e=0;e<this.length;++e){let t=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;i-t>0&&(r[e]=this._subParams.slice(t,i))}return r}addDigit(r){let e;if(this._rejectDigits||!(e=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let t=this._digitIsSub?this._subParams:this.params,i=t[e-1];t[e-1]=~i?Math.min(i*10+r,de):r}};var fe=[],Me=class{constructor(){this._state=0;this._active=fe;this._id=-1;this._handlers=Object.create(null);this._handlerFb=()=>{};this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(r,e){this._handlers[r]??=[];let t=this._handlers[r];return t.push(e),{dispose:()=>{let i=t.indexOf(e);i!==-1&&t.splice(i,1)}}}clearHandler(r){this._handlers[r]&&delete this._handlers[r]}setHandlerFallback(r){this._handlerFb=r}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=fe}reset(){if(this._state===2)for(let r=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;r>=0;--r)this._active[r].end(!1);this._stack.paused=!1,this._active=fe,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||fe,!this._active.length)this._handlerFb(this._id,"START");else for(let r=this._active.length-1;r>=0;r--)this._active[r].start()}_put(r,e,t){if(!this._active.length)this._handlerFb(this._id,"PUT",F(r,e,t));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(r,e,t)}start(){this.reset(),this._state=1}put(r,e,t){if(this._state!==3){if(this._state===1)for(;e<t;){let i=r[e++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&t-e>0&&this._put(r,e,t)}}end(r,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",r);else{let t=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,t=e,s=this._stack.fallThrough,this._stack.paused=!1),!s&&t===!1){for(;i>=0&&(t=this._active[i].end(r),t!==!0);i--)if(t instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,t;i--}for(;i>=0;i--)if(t=this._active[i].end(!1),t instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,t}this._active=fe,this._id=-1,this._state=0}}},He=class He{constructor(r){this._handler=r;this._data="";this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(r,e,t){this._hitLimit||(this._data+=F(r,e,t),this._data.length>He._payloadLimit&&(this._data="",this._hitLimit=!0))}end(r){let e=!1;if(this._hitLimit)e=!1;else if(r&&(e=this._handler(this._data),e instanceof Promise))return e.then(t=>(this._data="",this._hitLimit=!1,t));return this._data="",this._hitLimit=!1,e}};He._payloadLimit=1e7;var D=He;var pe=[],Ne=class{constructor(){this._handlers=Object.create(null);this._active=pe;this._ident=0;this._handlerFb=()=>{};this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=pe}registerHandler(r,e){this._handlers[r]??=[];let t=this._handlers[r];return t.push(e),{dispose:()=>{let i=t.indexOf(e);i!==-1&&t.splice(i,1)}}}clearHandler(r){this._handlers[r]&&delete this._handlers[r]}setHandlerFallback(r){this._handlerFb=r}reset(){if(this._active.length)for(let r=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;r>=0;--r)this._active[r].unhook(!1);this._stack.paused=!1,this._active=pe,this._ident=0}hook(r,e){if(this.reset(),this._ident=r,this._active=this._handlers[r]||pe,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let t=this._active.length-1;t>=0;t--)this._active[t].hook(e)}put(r,e,t){if(!this._active.length)this._handlerFb(this._ident,"PUT",F(r,e,t));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(r,e,t)}unhook(r,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",r);else{let t=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,t=e,s=this._stack.fallThrough,this._stack.paused=!1),!s&&t===!1){for(;i>=0&&(t=this._active[i].unhook(r),t!==!0);i--)if(t instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,t;i--}for(;i>=0;i--)if(t=this._active[i].unhook(!1),t instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,t}this._active=pe,this._ident=0}},_e=new ie;_e.addParam(0);var Fe=class Fe{constructor(r){this._handler=r;this._data="";this._params=_e;this._hitLimit=!1}hook(r){this._params=r.length>1||r.params[0]?r.clone():_e,this._data="",this._hitLimit=!1}put(r,e,t){this._hitLimit||(this._data+=F(r,e,t),this._data.length>Fe._payloadLimit&&(this._data="",this._hitLimit=!0))}unhook(r){let e=!1;if(this._hitLimit)e=!1;else if(r&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(t=>(this._params=_e,this._data="",this._hitLimit=!1,t));return this._params=_e,this._data="",this._hitLimit=!1,e}};Fe._payloadLimit=1e7;var be=Fe;var se=[],Ue=class{constructor(){this._state=0;this._active=se;this._id=-1;this._handlers=Object.create(null);this._handlerFb=()=>{};this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(r,e){this._handlers[r]??=[];let t=this._handlers[r];return t.push(e),{dispose:()=>{let i=t.indexOf(e);i!==-1&&t.splice(i,1)}}}clearHandler(r){this._handlers[r]&&delete this._handlers[r]}setHandlerFallback(r){this._handlerFb=r}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=se}reset(){if(this._state===2)for(let r=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;r>=0;--r)this._active[r].end(!1);this._stack.paused=!1,this._active=se,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||se,!this._active.length)this._handlerFb(this._id,"START");else for(let r=this._active.length-1;r>=0;r--)this._active[r].start()}_put(r,e,t){if(!this._active.length)this._handlerFb(this._id,"PUT",F(r,e,t));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(r,e,t)}start(){this.reset(),this._state=1}put(r,e,t){this._state!==3&&(this._state===1&&e<t&&(this._id=r[e++],this._state=2,this._start()),this._state===2&&t-e>0&&this._put(r,e,t))}end(r,e=!0){if(this._state!==0){if(this._state!==3){if(this._state===1){this._active=se,this._id=-1,this._state=0;return}if(!this._active.length)this._handlerFb(this._id,"END",r);else{let t=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,t=e,s=this._stack.fallThrough,this._stack.paused=!1),!s&&t===!1){for(;i>=0&&(t=this._active[i].end(r),t!==!0);i--)if(t instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,t;i--}for(;i>=0;i--)if(t=this._active[i].end(!1),t instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,t}}this._active=se,this._id=-1,this._state=0}}},Ge=class Ge{constructor(r){this._handler=r;this._data="";this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(r,e,t){this._hitLimit||(this._data+=F(r,e,t),this._data.length>Ge._payloadLimit&&(this._data="",this._hitLimit=!0))}end(r){let e=!1;if(this._hitLimit)e=!1;else if(r&&(e=this._handler(this._data),e instanceof Promise))return e.then(t=>(this._data="",this._hitLimit=!1,t));return this._data="",this._hitLimit=!1,e}};Ge._payloadLimit=1e7;var We=Ge;var ft=class{constructor(r){this.table=new Uint16Array(r)}setDefault(r,e){this.table.fill(r<<8|e)}add(r,e,t,i){this.table[e<<8|r]=t<<8|i}addMany(r,e,t,i){for(let s=0;s<r.length;s++)this.table[e<<8|r[s]]=t<<8|i}},P=160,ur=(function(){let n=new ft(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),t=(l,c)=>e.slice(l,c),i=t(32,127),s=t(0,24);s.push(25),s.push.apply(s,t(28,32));let a=t(0,15);n.setDefault(1,0),n.addMany(i,0,2,0);for(let l of a)n.addMany([24,26,153,154],l,3,0),n.addMany(t(128,144),l,3,0),n.addMany(t(144,152),l,3,0),n.add(156,l,0,0),n.add(27,l,11,1),n.add(157,l,4,8),n.addMany([152,158],l,0,7),n.add(159,l,15,14),n.add(155,l,11,3),n.add(144,l,11,9);return n.addMany(s,0,3,0),n.addMany(s,1,3,1),n.add(127,1,0,1),n.addMany(s,8,0,8),n.addMany(s,3,3,3),n.add(127,3,0,3),n.addMany(s,4,3,4),n.add(127,4,0,4),n.addMany(s,6,3,6),n.addMany(s,5,3,5),n.add(127,5,0,5),n.addMany(s,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(i,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(t(28,32),8,0,8),n.addMany([88,94],1,0,7),n.addMany(i,7,0,7),n.addMany(s,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(95,1,15,14),n.addMany(i,14,16,14),n.addMany(s,14,0,14),n.add(127,14,0,14),n.addMany([27,156,24,26],14,17,0),n.add(91,1,11,3),n.addMany(t(64,127),3,7,0),n.addMany(t(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(t(48,60),4,8,4),n.addMany(t(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(t(32,64),6,0,6),n.add(127,6,0,6),n.addMany(t(64,127),6,0,0),n.addMany(t(32,48),3,9,5),n.addMany(t(32,48),5,9,5),n.addMany(t(48,64),5,0,6),n.addMany(t(64,127),5,7,0),n.addMany(t(32,48),4,9,5),n.addMany(t(32,48),1,9,2),n.addMany(t(32,48),2,9,2),n.addMany(t(48,127),2,10,0),n.addMany(t(48,80),1,10,0),n.addMany(t(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(t(96,127),1,10,0),n.add(80,1,11,9),n.addMany(s,9,0,9),n.add(127,9,0,9),n.addMany(t(28,32),9,0,9),n.addMany(t(32,48),9,9,12),n.addMany(t(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(s,11,0,11),n.addMany(t(32,128),11,0,11),n.addMany(t(28,32),11,0,11),n.addMany(s,10,0,10),n.add(127,10,0,10),n.addMany(t(28,32),10,0,10),n.addMany(t(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(t(32,48),10,9,12),n.addMany(s,12,0,12),n.add(127,12,0,12),n.addMany(t(28,32),12,0,12),n.addMany(t(32,48),12,9,12),n.addMany(t(48,64),12,0,11),n.addMany(t(64,127),12,12,13),n.addMany(t(64,127),10,12,13),n.addMany(t(64,127),9,12,13),n.addMany(s,13,13,13),n.addMany(i,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(P,0,2,0),n.add(P,8,5,8),n.add(P,6,0,6),n.add(P,11,0,11),n.add(P,13,13,13),n.add(P,14,16,14),n})(),Ke=class extends g{constructor(e=ur){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 ie,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(W(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Me),this._dcsParser=this._register(new Ne),this._apcParser=this._register(new Ue),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 a=0;a<e.intermediates.length;++a){let l=e.intermediates.charCodeAt(a);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=l}}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]??=[];let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,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]??=[];let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,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)}registerApcHandler(e,t){return this._apcParser.registerHandler(e,t)}clearApcHandler(e){this._apcParser.clearHandler(e)}setApcHandlerFallback(e){this._apcParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._apcParser.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,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,i){let s=0,a=0,l=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=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 u=this._parseStack.handlers,_=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&_>-1){for(;_>=0&&(c=u[_](this._params),c!==!0);_--)if(c instanceof Promise)return this._parseStack.handlerPos=_,c}this._parseStack.handlers=[];break;case 4:if(i===!1&&_>-1){for(;_>=0&&(c=u[_](),c!==!0);_--)if(c instanceof Promise)return this._parseStack.handlerPos=_,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,i),c)return c;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],c=this._oscParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 7:if(s=e[this._parseStack.chunkPos],c=this._apcParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&255}for(let u=l;u<t;++u){switch(s=e[u],a=this._transitions.table[this.currentState<<8|(s<160?s:P)],a>>8){case 2:for(let f=u+1;;++f){if(f>=t||(s=e[f])<32||s>126&&s<P){this._printHandler(e,u,f),u=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<P){this._printHandler(e,u,f),u=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<P){this._printHandler(e,u,f),u=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<P){this._printHandler(e,u,f),u=f-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:u,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|s],d=o?o.length-1:-1;for(;d>=0&&(c=o[d](this._params),c!==!0);d--)if(c instanceof Promise)return this._preserveStack(3,o,d,a,u),c;d<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(++u<t&&(s=e[u])>47&&s<60);u--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let m=this._escHandlers[this._collect<<8|s],p=m?m.length-1:-1;for(;p>=0&&(c=m[p](),c!==!0);p--)if(c instanceof Promise)return this._preserveStack(4,m,p,a,u),c;p<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 f=u+1;;++f)if(f>=t||(s=e[f])===24||s===26||s===27||s>127&&s<P){this._dcsParser.put(e,u,f),u=f-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,a,u),c;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=u+1;;f++)if(f>=t||(s=e[f])<32||s>127&&s<P){this._oscParser.put(e,u,f),u=f-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,a,u),c;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 15:this._apcParser.start();break;case 16:for(let f=u+1;;++f)if(f>=t||(s=e[f])===24||s===26||s===27||s===156||s>127&&s<P){this._apcParser.put(e,u,f),u=f-1;break}break;case 17:if(c=this._apcParser.end(s!==24&&s!==26),c)return this._preserveStack(7,[],0,a,u),c;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&255}}};var hr=/^([\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})$/,dr=/^[\da-f]+$/;function pt(n){if(!n)return;let r=n.toLowerCase();if(r.startsWith("rgb:")){r=r.slice(4);let e=hr.exec(r);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(r.startsWith("#")&&(r=r.slice(1),dr.exec(r)&&[3,6,9,12].includes(r.length))){let e=r.length/3,t=[0,0,0];for(let i=0;i<3;++i){let s=parseInt(r.slice(e*i,e*i+e),16);t[i]=e===1?s<<4:e===2?s:e===3?s>>4:s>>8}return t}}var Gt="6.0.0";var fr={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Y=131072,Kt=10;function qt(n,r){if(n>24)return r.setWinLines||!1;switch(n){case 1:return!!r.restoreWin;case 2:return!!r.minimizeWin;case 3:return!!r.setWinPosition;case 4:return!!r.setWinSizePixels;case 5:return!!r.raiseWin;case 6:return!!r.lowerWin;case 7:return!!r.refreshWin;case 8:return!!r.setWinSizeChars;case 9:return!!r.maximizeWin;case 10:return!!r.fullscreenWin;case 11:return!!r.getWinState;case 13:return!!r.getWinPosition;case 14:return!!r.getWinSizePixels;case 15:return!!r.getScreenSizePixels;case 16:return!!r.getCellSizePixels;case 18:return!!r.getWinSizeChars;case 19:return!!r.getScreenSizeChars;case 20:return!!r.getIconTitle;case 21:return!!r.getWinTitle;case 22:return!!r.pushTitle;case 23:return!!r.popTitle;case 24:return!!r.setWinLines}return!1}var Vt=5e3,Yt=0,qe=class extends g{constructor(e,t,i,s,a,l,c,u,_=new Ke){super();this._bufferService=e;this._charsetService=t;this._coreService=i;this._logService=s;this._optionsService=a;this._oscLinkService=l;this._coreMouseService=c;this._unicodeService=u;this._parser=_;this._parseBuffer=new Uint32Array(4096);this._stringDecoder=new ve;this._utf8Decoder=new ge;this._windowTitle="";this._iconName="";this._windowTitleStack=[];this._iconNameStack=[];this._curAttrData=x.clone();this._eraseAttrDataInternal=x.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._onRequestColorSchemeQuery=this._register(new b);this.onRequestColorSchemeQuery=this._onRequestColorSchemeQuery.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 me(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(o=>this._activeBuffer=o.activeBuffer)),this._parser.setCsiHandlerFallback((o,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(o),params:d.toArray()})}),this._parser.setEscHandlerFallback(o=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(o)})}),this._parser.setExecuteHandlerFallback(o=>{this._logService.debug("Unknown EXECUTE code: ",{code:o})}),this._parser.setOscHandlerFallback((o,d,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:o,action:d,data:m})}),this._parser.setDcsHandlerFallback((o,d,m)=>{d==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(o),action:d,payload:m})}),this._parser.setPrintHandler((o,d,m)=>this.print(o,d,m)),this._parser.registerCsiHandler({final:"@"},o=>this.insertChars(o)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},o=>this.scrollLeft(o)),this._parser.registerCsiHandler({final:"A"},o=>this.cursorUp(o)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},o=>this.scrollRight(o)),this._parser.registerCsiHandler({final:"B"},o=>this.cursorDown(o)),this._parser.registerCsiHandler({final:"C"},o=>this.cursorForward(o)),this._parser.registerCsiHandler({final:"D"},o=>this.cursorBackward(o)),this._parser.registerCsiHandler({final:"E"},o=>this.cursorNextLine(o)),this._parser.registerCsiHandler({final:"F"},o=>this.cursorPrecedingLine(o)),this._parser.registerCsiHandler({final:"G"},o=>this.cursorCharAbsolute(o)),this._parser.registerCsiHandler({final:"H"},o=>this.cursorPosition(o)),this._parser.registerCsiHandler({final:"I"},o=>this.cursorForwardTab(o)),this._parser.registerCsiHandler({final:"J"},o=>this.eraseInDisplay(o,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},o=>this.eraseInDisplay(o,!0)),this._parser.registerCsiHandler({final:"K"},o=>this.eraseInLine(o,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},o=>this.eraseInLine(o,!0)),this._parser.registerCsiHandler({final:"L"},o=>this.insertLines(o)),this._parser.registerCsiHandler({final:"M"},o=>this.deleteLines(o)),this._parser.registerCsiHandler({final:"P"},o=>this.deleteChars(o)),this._parser.registerCsiHandler({final:"S"},o=>this.scrollUp(o)),this._parser.registerCsiHandler({final:"T"},o=>this.scrollDown(o)),this._parser.registerCsiHandler({final:"X"},o=>this.eraseChars(o)),this._parser.registerCsiHandler({final:"Z"},o=>this.cursorBackwardTab(o)),this._parser.registerCsiHandler({final:"^"},o=>this.scrollDown(o)),this._parser.registerCsiHandler({final:"`"},o=>this.charPosAbsolute(o)),this._parser.registerCsiHandler({final:"a"},o=>this.hPositionRelative(o)),this._parser.registerCsiHandler({final:"b"},o=>this.repeatPrecedingCharacter(o)),this._parser.registerCsiHandler({final:"c"},o=>this.sendDeviceAttributesPrimary(o)),this._parser.registerCsiHandler({prefix:">",final:"c"},o=>this.sendDeviceAttributesSecondary(o)),this._parser.registerCsiHandler({final:"d"},o=>this.linePosAbsolute(o)),this._parser.registerCsiHandler({final:"e"},o=>this.vPositionRelative(o)),this._parser.registerCsiHandler({final:"f"},o=>this.hVPosition(o)),this._parser.registerCsiHandler({final:"g"},o=>this.tabClear(o)),this._parser.registerCsiHandler({final:"h"},o=>this.setMode(o)),this._parser.registerCsiHandler({prefix:"?",final:"h"},o=>this.setModePrivate(o)),this._parser.registerCsiHandler({final:"l"},o=>this.resetMode(o)),this._parser.registerCsiHandler({prefix:"?",final:"l"},o=>this.resetModePrivate(o)),this._parser.registerCsiHandler({final:"m"},o=>this.charAttributes(o)),this._parser.registerCsiHandler({final:"n"},o=>this.deviceStatus(o)),this._parser.registerCsiHandler({prefix:"?",final:"n"},o=>this.deviceStatusPrivate(o)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},o=>this.softReset(o)),this._parser.registerCsiHandler({prefix:">",final:"q"},o=>this.sendXtVersion(o)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},o=>this.setCursorStyle(o)),this._parser.registerCsiHandler({final:"r"},o=>this.setScrollRegion(o)),this._parser.registerCsiHandler({final:"s"},o=>this.saveCursor(o)),this._parser.registerCsiHandler({final:"t"},o=>this.windowOptions(o)),this._parser.registerCsiHandler({final:"u"},o=>this.restoreCursor(o)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},o=>this.insertColumns(o)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},o=>this.deleteColumns(o)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},o=>this.selectProtected(o)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},o=>this.requestMode(o,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},o=>this.requestMode(o,!1)),this._parser.registerCsiHandler({prefix:"=",final:"u"},o=>this.kittyKeyboardSet(o)),this._parser.registerCsiHandler({prefix:"?",final:"u"},o=>this.kittyKeyboardQuery(o)),this._parser.registerCsiHandler({prefix:">",final:"u"},o=>this.kittyKeyboardPush(o)),this._parser.registerCsiHandler({prefix:"<",final:"u"},o=>this.kittyKeyboardPop(o)),this._parser.setExecuteHandler("\x07",()=>this.bell()),this._parser.setExecuteHandler(`
|
|
18
|
-
`,()=>this.lineFeed()),this._parser.setExecuteHandler("\v",()=>this.lineFeed()),this._parser.setExecuteHandler("\f",()=>this.lineFeed()),this._parser.setExecuteHandler("\r",()=>this.carriageReturn()),this._parser.setExecuteHandler("\b",()=>this.backspace()),this._parser.setExecuteHandler(" ",()=>this.tab()),this._parser.setExecuteHandler("",()=>this.shiftOut()),this._parser.setExecuteHandler("",()=>this.shiftIn()),this._parser.setExecuteHandler("\x84",()=>this.index()),this._parser.setExecuteHandler("\x85",()=>this.nextLine()),this._parser.setExecuteHandler("\x88",()=>this.tabSet()),this._parser.registerOscHandler(0,new D(o=>(this.setTitle(o),this.setIconName(o),!0))),this._parser.registerOscHandler(1,new D(o=>this.setIconName(o))),this._parser.registerOscHandler(2,new D(o=>this.setTitle(o))),this._parser.registerOscHandler(4,new D(o=>this.setOrReportIndexedColor(o))),this._parser.registerOscHandler(8,new D(o=>this.setHyperlink(o))),this._parser.registerOscHandler(10,new D(o=>this.setOrReportFgColor(o))),this._parser.registerOscHandler(11,new D(o=>this.setOrReportBgColor(o))),this._parser.registerOscHandler(12,new D(o=>this.setOrReportCursorColor(o))),this._parser.registerOscHandler(104,new D(o=>this.restoreIndexedColor(o))),this._parser.registerOscHandler(110,new D(o=>this.restoreFgColor(o))),this._parser.registerOscHandler(111,new D(o=>this.restoreBgColor(o))),this._parser.registerOscHandler(112,new D(o=>this.restoreCursorColor(o))),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 o in C)this._parser.registerEscHandler({intermediates:"(",final:o},()=>this.selectCharset("("+o)),this._parser.registerEscHandler({intermediates:")",final:o},()=>this.selectCharset(")"+o)),this._parser.registerEscHandler({intermediates:"*",final:o},()=>this.selectCharset("*"+o)),this._parser.registerEscHandler({intermediates:"+",final:o},()=>this.selectCharset("+"+o)),this._parser.registerEscHandler({intermediates:"-",final:o},()=>this.selectCharset("-"+o)),this._parser.registerEscHandler({intermediates:".",final:o},()=>this.selectCharset("."+o)),this._parser.registerEscHandler({intermediates:"/",final:o},()=>this.selectCharset("/"+o));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(o=>(this._logService.error("Parsing error: ",o),o)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new be((o,d)=>this.requestStatusString(o,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){if(this._logService.logLevel<=3){let t,i=new Promise((s,a)=>{t=setTimeout(()=>a("#SLOW_TIMEOUT"),Vt)});Promise.race([e,i]).then(()=>{t!==void 0&&clearTimeout(t)},s=>{if(t!==void 0&&clearTimeout(t),s!=="#SLOW_TIMEOUT")throw s;console.warn(`async parser handler taking longer than ${Vt} ms`)})}}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,a=this._activeBuffer.y,l=0,c=this._parseStack.paused;if(c){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Y&&(l=this._parseStack.position+Y)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,o=>String.fromCharCode(o)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(o=>o.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Y&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Y))),c||this._dirtyRowTracker.clearRange(),e.length>Y)for(let o=l;o<e.length;o+=Y){let d=o+Y<e.length?o+Y:e.length,m=typeof e=="string"?this._stringDecoder.decode(e.substring(o,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(o,d),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,a,m,o),this._logSlowResolvingAsync(i),i}else if(!c){let o=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,o))return this._preserveStack(s,a,o,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==a)&&this._onCursorMove.fire();let u=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),_=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);_<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(_,this._bufferService.rows-1),end:Math.min(u,this._bufferService.rows-1)})}print(e,t,i){let s,a,l=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,u=this._bufferService.cols,_=this._coreService.decPrivateModes.wraparound,o=this._coreService.modes.insertMode,d=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);if(!m)return;this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let p=this._parser.precedingJoinState;for(let f=t;f<i;++f){if(s=e[f],s===173)continue;if(s<127&&l){let O=l[String.fromCharCode(s)];O&&(s=O.charCodeAt(0))}let h=this._unicodeService.charProperties(s,p);a=k.extractWidth(h);let S=k.extractShouldJoin(h),E=S?k.extractWidth(p):0;if(p=h,c&&this._onA11yChar.fire(w(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-E>u){if(_){let O=m,I=this._activeBuffer.x-E;if(this._activeBuffer.x=E,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),!m)return;for(E>0&&m instanceof G&&m.copyCellsFrom(O,I,0,E,!1);I<u;)O.setCellFromCodepoint(I++,0,1,d)}else if(this._activeBuffer.x=u-1,a===2)continue}if(S&&this._activeBuffer.x){let O=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-O,s,a);for(let I=a-E;--I>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(o&&(m.insertCells(this._activeBuffer.x,a-E,this._activeBuffer.getNullCell(d)),m.getWidth(u-1)===2&&m.setCellFromCodepoint(u-1,0,1,d)),m.setCellFromCodepoint(this._activeBuffer.x++,s,a,d),a>0)for(;--a;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=p,this._activeBuffer.x<u&&i-t>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.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=>qt(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new be(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new D(t))}registerApcHandler(e,t){return this._parser.registerApcHandler(e,new We(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(){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&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.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,a=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l&&(l.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(l.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){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:if(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){let a=this._activeBuffer.lines.get(i+1);a&&(a.isWrapped=!1)}for(;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--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.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 s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,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,a=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(a-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(x));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=k.extractWidth(t),a=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(a),u=new Uint32Array(c.length*i),_=0;for(let d=0;d<c.length;){let m=c.codePointAt(d)||0;u[_++]=m,d+=m>65535?2:1}let o=_;for(let d=1;d<i;++d)u.copyWithin(o,0,_),o+=_;return this.print(u,0,o),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent("\x1B[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent("\x1B[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent("\x1B[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent("\x1B[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent("\x1B[>83;40003;0c")),!0}sendXtVersion(e){return e.params[0]>0||this._coreService.triggerDataEvent(`\x1BP>|xterm.js(${Gt})\x1B\\`),!0}_is(e){return(this._optionsService.rawOptions.termName+"").startsWith(e)}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,K),this._charsetService.setgCharset(1,K),this._charsetService.setgCharset(2,K),this._charsetService.setgCharset(3,K);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.rawOptions.quirks?.allowSetCursorBlink&&(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:if(this._optionsService.rawOptions.vtExtensions?.kittyKeyboard){let i=this._coreService.kittyKeyboard;i.mainFlags=i.flags,i.flags=i.altFlags}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;case 2031:(this._optionsService.rawOptions.vtExtensions?.colorSchemeQuery??!0)&&(this._coreService.decPrivateModes.colorSchemeUpdates=!0);break;case 9001:this._optionsService.rawOptions.vtExtensions?.win32InputMode&&(this._coreService.decPrivateModes.win32InputMode=!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.rawOptions.quirks?.allowSetCursorBlink&&(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:if(this._optionsService.rawOptions.vtExtensions?.kittyKeyboard){let i=this._coreService.kittyKeyboard;i.altFlags=i.flags,i.flags=i.mainFlags}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;case 2031:(this._optionsService.rawOptions.vtExtensions?.colorSchemeQuery??!0)&&(this._coreService.decPrivateModes.colorSchemeUpdates=!1);break;case 9001:this._optionsService.rawOptions.vtExtensions?.win32InputMode&&(this._coreService.decPrivateModes.win32InputMode=!1);break}return!0}requestMode(e,t){let i;(M=>(M[M.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",M[M.SET=1]="SET",M[M.RESET=2]="RESET",M[M.PERMANENTLY_SET=3]="PERMANENTLY_SET",M[M.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(i||={});let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:l}=this._coreMouseService,c=this._coreService,{buffers:u,cols:_}=this._bufferService,{active:o,alt:d}=u,m=this._optionsService.rawOptions,p=(S,E)=>(c.triggerDataEvent(`\x1B[${t?"":"?"}${S};${E}$y`),!0),f=S=>S?1:2,h=e.params[0];return t?h===2?p(h,4):h===4?p(h,f(c.modes.insertMode)):h===12?p(h,3):h===20?p(h,f(m.convertEol)):p(h,0):h===1?p(h,f(s.applicationCursorKeys)):h===3?p(h,m.windowOptions.setWinLines?_===80?2:_===132?1:0:0):h===6?p(h,f(s.origin)):h===7?p(h,f(s.wraparound)):h===8?p(h,3):h===9?p(h,f(a==="X10")):h===12?p(h,f(m.cursorBlink)):h===25?p(h,f(!c.isCursorHidden)):h===45?p(h,f(s.reverseWraparound)):h===66?p(h,f(s.applicationKeypad)):h===67?p(h,4):h===1e3?p(h,f(a==="VT200")):h===1002?p(h,f(a==="DRAG")):h===1003?p(h,f(a==="ANY")):h===1004?p(h,f(s.sendFocus)):h===1005?p(h,4):h===1006?p(h,f(l==="SGR")):h===1015?p(h,4):h===1016?p(h,f(l==="SGR_PIXELS")):h===1048?p(h,1):h===47||h===1047||h===1049?p(h,f(o===d)):h===2004?p(h,f(s.bracketedPasteMode)):h===2026?p(h,f(s.synchronizedOutput)):h===9001&&this._optionsService.rawOptions.vtExtensions?.win32InputMode?p(h,f(s.win32InputMode)):p(h,0)}_updateAttrColor(e,t,i,s,a){return t===2?(e|=50331648,e&=-16777216,e|=q.fromColorRGB([i,s,a])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],a=0,l=0;do{if(s[l+a]=e.params[t+l],e.hasSubParams(t+l)){let c=e.getSubParams(t+l),u=0;do s[1]===5&&(a=1),s[l+u+1+a]=c[u];while(++u<c.length&&u+l+1+a<s.length);break}if(s[1]===5&&l+a>=2||s[1]===2&&l+a>=5)break;s[1]&&(a=1)}while(++l+t<e.length&&l+a<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=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 l}_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=x.fg,e.bg=x.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 a=0;a<t;a++)i=e.params[a],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(a)?e.getSubParams(a)[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|=x.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=x.bg&16777215):i===38||i===48||i===58?a+=this._extractColor(e,a,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===221&&(this._optionsService.rawOptions.vtExtensions?.kittySgrBoldFaintControl??!0)?s.fg&=-134217729:i===222&&(this._optionsService.rawOptions.vtExtensions?.kittySgrBoldFaintControl??!0)?s.bg&=-134217729:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent("\x1B[0n");break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`\x1B[${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(`\x1B[?${t};${i}R`);break;case 15:break;case 25:break;case 26:break;case 53:break;case 996:(this._optionsService.rawOptions.vtExtensions?.colorSchemeQuery??!0)&&this._onRequestColorSchemeQuery.fire();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=x.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(!qt(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(`\x1B[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Kt&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Kt&&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,this._activeBuffer.savedCharsets=this._charsetService.charsets.slice(),this._activeBuffer.savedGlevel=this._charsetService.glevel,this._activeBuffer.savedOriginMode=this._coreService.decPrivateModes.origin,this._activeBuffer.savedWraparoundMode=this._coreService.decPrivateModes.wraparound,!0}restoreCursor(e){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;for(let t=0;t<this._activeBuffer.savedCharsets.length;t++)this._charsetService.setgCharset(t,this._activeBuffer.savedCharsets[t]);return this._charsetService.setgLevel(this._activeBuffer.savedGlevel),this._coreService.decPrivateModes.origin=this._activeBuffer.savedOriginMode,this._coreService.decPrivateModes.wraparound=this._activeBuffer.savedWraparoundMode,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(),a=i.shift();if(/^\d+$/.exec(s)){let l=parseInt(s);if($t(l))if(a==="?")t.push({type:0,index:l});else{let c=pt(a);c&&t.push({type:1,index:l,color:c})}}}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,a=i.findIndex(l=>l.startsWith("id="));return a!==-1&&(s=i[a].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 a=pt(i[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}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 a=parseInt(i[s]);$t(a)&&t.push({type:2,index:a})}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,K),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(fr[e[0]],C[e[1]]??K),!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=x.clone(),this._eraseAttrDataInternal=x.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 A;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=c=>(this._coreService.triggerDataEvent(`\x1B${c}\x1B\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions,l={block:2,underline:4,bar:6};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${l[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}kittyKeyboardSet(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return!0;let t=e.params[0]||0,i=e.length>1&&e.params[1]||1,s=this._coreService.kittyKeyboard;switch(i){case 1:s.flags=t;break;case 2:s.flags|=t;break;case 3:s.flags&=~t;break}return!0}kittyKeyboardQuery(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return!0;let t=this._coreService.kittyKeyboard.flags;return this._coreService.triggerDataEvent(`\x1B[?${t}u`),!0}kittyKeyboardPush(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return!0;let t=e.params[0]||0,i=this._coreService.kittyKeyboard,a=this._bufferService.buffer===this._bufferService.buffers.alt?i.altStack:i.mainStack;return a.length>=16&&a.shift(),a.push(i.flags),i.flags=t,!0}kittyKeyboardPop(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return!0;let t=Math.max(1,e.params[0]||1),i=this._coreService.kittyKeyboard,a=this._bufferService.buffer===this._bufferService.buffers.alt?i.altStack:i.mainStack;for(let l=0;l<t&&a.length>0;l++)i.flags=a.pop();return a.length===0&&t>0&&(i.flags=0),!0}},me=class{constructor(r){this._bufferService=r;this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(r){r<this.start?this.start=r:r>this.end&&(this.end=r)}markRangeDirty(r,e){r>e&&(Yt=r,r=e,e=Yt),r<this.start&&(this.start=r),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};me=R([T(0,H)],me);function $t(n){return 0<=n&&n<256}var pr=5e7,Xt=12,_r=50,Ve=class extends g{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}flushSync(){if(this._isSyncWriting)return;this._isSyncWriting=!0;let e;for(;e=this._writeBuffer.shift();){this._action(e);let t=this._callbacks.shift();t&&t()}this._pendingData=0,this._bufferOffset=2147483647,this._writeBuffer.length=0,this._callbacks.length=0,this._isSyncWriting=!1}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>pr)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],a=this._action(s,t);if(a){let c=u=>performance.now()-i>=Xt?setTimeout(()=>this._innerWrite(0,u)):this._innerWrite(i,u);a.catch(u=>(queueMicrotask(()=>{throw u}),Promise.resolve(!1))).then(c);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Xt)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>_r&&(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()}};var ne=class{constructor(r){this._bufferService=r;this._nextId=1;this._entriesWithId=new Map;this._dataByLinkId=new Map}registerLink(r){let e=this._bufferService.buffer;if(r.id===void 0){let c=e.addMarker(e.ybase+e.y),u={data:r,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._dataByLinkId.set(u.id,u),u.id}let t=r,i=this._getEntryIdKey(t),s=this._entriesWithId.get(i);if(s)return this.addLineToLink(s.id,e.ybase+e.y),s.id;let a=e.addMarker(e.ybase+e.y),l={id:this._nextId++,key:this._getEntryIdKey(t),data:t,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(l,a)),this._entriesWithId.set(l.key,l),this._dataByLinkId.set(l.id,l),l.id}addLineToLink(r,e){let t=this._dataByLinkId.get(r);if(t&&t.lines.every(i=>i.line!==e)){let i=this._bufferService.buffer.addMarker(e);t.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(t,i))}}getLinkData(r){return this._dataByLinkId.get(r)?.data}_getEntryIdKey(r){return`${r.id};;${r.uri}`}_removeMarkerFromLink(r,e){let t=r.lines.indexOf(e);t!==-1&&(r.lines.splice(t,1),r.lines.length===0&&(r.data.id!==void 0&&this._entriesWithId.delete(r.key),this._dataByLinkId.delete(r.id)))}};ne=R([T(0,H)],ne);var jt=!1,Ye=class extends g{constructor(e){super();this._windowsWrappingHeuristics=this._register(new Se);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._onRender=this._register(new b);this.onRender=this._onRender.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 De,this.optionsService=this._register(new ke(e)),this._instantiationService.setService(N,this.optionsService),this._logService=this._register(this._instantiationService.createInstance(z)),this._instantiationService.setService(j,this._logService),this._bufferService=this._register(this._instantiationService.createInstance(Q)),this._instantiationService.setService(H,this._bufferService),this.coreService=this._register(this._instantiationService.createInstance(te)),this._instantiationService.setService(Te,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(re)),this._instantiationService.setService(xt,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(k)),this._instantiationService.setService(Tt,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Le),this._instantiationService.setService(Ct,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ne),this._instantiationService.setService(yt,this._oscLinkService),this._inputHandler=this._register(new qe(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(B.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(B.forward(this._bufferService.onResize,this._onResize)),this._register(B.forward(this.coreService.onData,this._onData)),this._register(B.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(["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 Ve((t,i)=>this._inputHandler.parse(t,i))),this._register(B.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new b),this._onScroll.event(e=>{this._onScrollApi?.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&&!jt&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jt=!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,ot),t=Math.max(t,lt),this._writeBuffer.flushSync(),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)}registerApcHandler(e,t){return this._inputHandler.registerApcHandler(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),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(dt.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(dt(this._bufferService),!1))),this._windowsWrappingHeuristics.value=W(()=>{for(let t of e)t.dispose()})}}};var $e=class extends Ye{constructor(e={}){super(e);this._onBell=this._register(new b);this.onBell=this._onBell.event;this._onCursorMove=this._register(new b);this.onCursorMove=this._onCursorMove.event;this._onTitleChange=this._register(new b);this.onTitleChange=this._onTitleChange.event;this._onA11yCharEmitter=this._register(new b);this.onA11yChar=this._onA11yCharEmitter.event;this._onA11yTabEmitter=this._register(new b);this.onA11yTab=this._onA11yTabEmitter.event;this._setup(),this._register(this._inputHandler.onRequestBell(()=>this.bell())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(B.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(B.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(B.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(B.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(B.forward(B.map(this._inputHandler.onRequestRefreshRows,t=>({start:t?.start??0,end:t?.end??this.rows-1})),this._onRender))}get buffer(){return this.buffers.active}get markers(){return this.buffer.markers}addMarker(e){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}bell(){this._onBell.fire()}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){e===this.cols&&t===this.rows||super.resize(e,t)}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){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(x));this._onScroll.fire({position:this.buffer.ydisp})}}reset(){this.options.rows=this.rows,this.options.cols=this.cols,this._setup(),super.reset()}};var Xe=class{constructor(){this._addons=[]}dispose(){for(let r=this._addons.length-1;r>=0;r--)this._addons[r].instance.dispose()}loadAddon(r,e){let t={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(t),e.dispose=()=>this._wrappedAddonDispose(t),e.activate(r)}_wrappedAddonDispose(r){if(r.isDisposed)return;let e=-1;for(let t=0;t<this._addons.length;t++)if(this._addons[t]===r){e=t;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");r.isDisposed=!0,r.dispose.apply(r.instance),this._addons.splice(e,1)}};var br=["cols","rows"],zt=class extends g{constructor(r){super(),this._core=this._register(new $e(r)),this._addonManager=this._register(new Xe),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],t=(i,s)=>{this._checkReadonlyOptions(i),this._core.options[i]=s};for(let i in this._core.options){Object.defineProperty(this._publicOptions,i,{get:()=>this._core.options[i],set:a=>{this._checkReadonlyOptions(i),this._core.options[i]=a}});let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this._publicOptions,i,s)}}_checkReadonlyOptions(r){if(br.includes(r))throw new Error(`Option "${r}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.options.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 onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get parser(){return this._parser??=new Ce(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Ee(this._core)}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer??=this._register(new xe(this._core)),this._buffer}get markers(){return this._core.markers}get modes(){let r=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:r.applicationCursorKeys,applicationKeypadMode:r.applicationKeypad,bracketedPasteMode:r.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:r.origin,reverseWraparoundMode:r.reverseWraparound,sendFocusMode:r.sendFocus,showCursor:!this._core.coreService.isCursorHidden,synchronizedOutputMode:r.synchronizedOutput,win32InputMode:r.win32InputMode,wraparoundMode:r.wraparound}}get options(){return this._publicOptions}set options(r){for(let e in r)this._publicOptions[e]=r[e]}input(r,e=!0){this._core.input(r,e)}resize(r,e){this._verifyIntegers(r,e),this._core.resize(r,e)}registerMarker(r=0){return this._verifyIntegers(r),this._core.addMarker(r)}addMarker(r){return this.registerMarker(r)}dispose(){super.dispose()}scrollLines(r){this._verifyIntegers(r),this._core.scrollLines(r)}scrollPages(r){this._verifyIntegers(r),this._core.scrollPages(r)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(r){this._verifyIntegers(r),this._core.scrollToLine(r)}clear(){this._core.clear()}write(r,e){this._core.write(r,e)}writeln(r,e){this._core.write(r),this._core.write(`\r
|
|
19
|
-
`,e)}reset(){this._core.reset()}loadAddon(
|
|
17
|
+
var Jt=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var H=(n,t,e,r)=>{for(var i=r>1?void 0:r?Qt(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(t,e,i):o(i))||i);return r&&i&&Jt(t,e,i),i},R=(n,t)=>(e,r)=>t(e,r,n);function k(n){return n>65535?(n-=65536,String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)}function M(n,t=0,e=n.length){let r="";for(let i=t;i<e;++i){let s=n[i];s>65535?(s-=65536,r+=String.fromCharCode((s>>10)+55296)+String.fromCharCode(s%1024+56320)):r+=String.fromCharCode(s)}return r}var me=class{constructor(){this._interim=0}clear(){this._interim=0}decode(t,e){let r=t.length;if(!r)return 0;let i=0,s=0;if(this._interim){let o=t.charCodeAt(s++);56320<=o&&o<=57343?e[i++]=(this._interim-55296)*1024+o-56320+65536:(e[i++]=this._interim,e[i++]=o),this._interim=0}for(let o=s;o<r;++o){let l=t.charCodeAt(o);if(55296<=l&&l<=56319){if(++o>=r)return this._interim=l,i;let c=t.charCodeAt(o);56320<=c&&c<=57343?e[i++]=(l-55296)*1024+c-56320+65536:(e[i++]=l,e[i++]=c);continue}l!==65279&&(e[i++]=l)}return i}},ve=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(t,e){let r=t.length;if(!r)return 0;let i=0,s,o,l,c,u=0,_=0;if(this.interim[0]){let m=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let f=0,h;for(;(h=this.interim[++f]&63)&&f<4;)p<<=6,p|=h;let S=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=S-f;for(;_<E;){if(_>=r)return 0;if(h=t[_++],(h&192)!==128){_--,m=!0;break}else this.interim[f++]=h,p<<=6,p|=h&63}m||(S===2?p<128?_--:e[i++]=p:S===3?p<2048||p>=55296&&p<=57343||p===65279||(e[i++]=p):p<65536||p>1114111||(e[i++]=p)),this.interim.fill(0)}let a=r-4,d=_;for(;d<r;){for(;d<a&&!((s=t[d])&128)&&!((o=t[d+1])&128)&&!((l=t[d+2])&128)&&!((c=t[d+3])&128);)e[i++]=s,e[i++]=o,e[i++]=l,e[i++]=c,d+=4;if(s=t[d++],s<128)e[i++]=s;else if((s&224)===192){if(d>=r)return this.interim[0]=s,i;if(o=t[d++],(o&192)!==128){d--;continue}if(u=(s&31)<<6|o&63,u<128){d--;continue}e[i++]=u}else if((s&240)===224){if(d>=r)return this.interim[0]=s,i;if(o=t[d++],(o&192)!==128){d--;continue}if(d>=r)return this.interim[0]=s,this.interim[1]=o,i;if(l=t[d++],(l&192)!==128){d--;continue}if(u=(s&15)<<12|(o&63)<<6|l&63,u<2048||u>=55296&&u<=57343||u===65279)continue;e[i++]=u}else if((s&248)===240){if(d>=r)return this.interim[0]=s,i;if(o=t[d++],(o&192)!==128){d--;continue}if(d>=r)return this.interim[0]=s,this.interim[1]=o,i;if(l=t[d++],(l&192)!==128){d--;continue}if(d>=r)return this.interim[0]=s,this.interim[1]=o,this.interim[2]=l,i;if(c=t[d++],(c&192)!==128){d--;continue}if(u=(s&7)<<18|(o&63)<<12|(l&63)<<6|c&63,u<65536||u>1114111)continue;e[i++]=u}}return i}};var G=class n{constructor(){this.fg=0;this.bg=0;this.extended=new K}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 n;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}},K=class n{constructor(t=0,e=0){this._ext=0;this._urlId=0;this._ext=t,this._urlId=e}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 n(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}};var D=class n extends G{constructor(){super(...arguments);this.content=0;this.fg=0;this.bg=0;this.extended=new K;this.combinedData=""}static fromCharData(e){let r=new n;return r.setFromCharData(e),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?k(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let r=!1;if(e[1].length>2)r=!0;else if(e[1].length===2){let i=e[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=e[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(i-55296)*1024+s-56320+65536|e[2]<<22:r=!0}else r=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;r&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}attributesEquals(e){if(this.getFgColorMode()!==e.getFgColorMode()||this.getFgColor()!==e.getFgColor()||this.getBgColorMode()!==e.getBgColorMode()||this.getBgColor()!==e.getBgColor()||this.isInverse()!==e.isInverse()||this.isBold()!==e.isBold()||this.isUnderline()!==e.isUnderline())return!1;if(this.isUnderline()){if(this.getUnderlineStyle()!==e.getUnderlineStyle())return!1;let r=this.isUnderlineColorDefault(),i=e.isUnderlineColorDefault();if(!(r&&i)&&(r!==i||this.getUnderlineColor()!==e.getUnderlineColor()||this.getUnderlineColorMode()!==e.getUnderlineColorMode()))return!1}return!(this.isOverline()!==e.isOverline()||this.isBlink()!==e.isBlink()||this.isInvisible()!==e.isInvisible()||this.isItalic()!==e.isItalic()||this.isDim()!==e.isDim()||this.isStrikethrough()!==e.isStrikethrough())}};var ge=class{constructor(t){this._line=t}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(t,e){if(!(t<0||t>=this._line.length))return e?(this._line.loadCell(t,e),e):this._line.loadCell(t,new D)}translateToString(t,e,r){return this._line.translateToString(t,e,r)}};var ne=class{constructor(t,e){this._buffer=t;this.type=e}init(t){return this._buffer=t,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(t){let e=this._buffer.lines.get(t);if(e)return new ge(e)}getNullCell(){return new D}};function F(n){return{dispose:n}}function mt(n){if(!n)return n;if(Array.isArray(n)){for(let t of n)t.dispose();return[]}return n.dispose(),n}var ae=class{constructor(){this._disposables=new Set;this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(t){return this._isDisposed?t.dispose():this._disposables.add(t),t}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let t of this._disposables)t.dispose();this._disposables.clear()}}clear(){for(let t of this._disposables)t.dispose();this._disposables.clear()}},g=class{constructor(){this._store=new ae}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};g.None=Object.freeze({dispose(){}});var Ie=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}};var b=class{constructor(){this._listeners=[];this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,e,r)=>{if(this._disposed)return F(()=>{});let i={fn:t,thisArgs:e};this._listeners.push(i);let s=F(()=>{let o=this._listeners.indexOf(i);o!==-1&&this._listeners.splice(o,1)});return r&&(Array.isArray(r)?r.push(s):r.add(s)),s},this._event)}fire(t){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:e,thisArgs:r}=this._listeners[0];e.call(r,t);return}default:{let e=this._listeners.slice();for(let{fn:r,thisArgs:i}of e)r.call(i,t)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},A;(i=>{function n(s,o){return s(l=>o.fire(l))}i.forward=n;function t(s,o){return(l,c,u)=>s(_=>l.call(c,o(_)),void 0,u)}i.map=t;function e(...s){return(o,l,c)=>{let u=new ae;for(let _ of s)u.add(_(a=>o.call(l,a)));return c&&(Array.isArray(c)?c.push(u):c.add(u)),u}}i.any=e;function r(s,o,l){return o(l),s(c=>o(c))}i.runAndSubscribe=r})(A||={});var Se=class extends g{constructor(e){super();this._core=e;this._onBufferChange=this._register(new b);this.onBufferChange=this._onBufferChange.event;this._normal=new ne(this._core.buffers.normal,"normal"),this._alternate=new ne(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)}};var xe=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,r=>e(r.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(r,i)=>e(r,i.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}registerApcHandler(t,e){return this._core.registerApcHandler(t,e)}};var Ce=class{constructor(t){this._core=t}register(t){this._core.unicodeService.register(t)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(t){this._core.unicodeService.activeVersion=t}};var v=3;var x=Object.freeze(new G),Ee=0,vt=new D,ze=2,U=class n{constructor(t,e,r=!1){this.isWrapped=r;this._combined={};this._extendedAttrs={};this._data=new Uint32Array(t*v);let i=e??D.fromCharData([0,"",1,0]);for(let s=0;s<t;++s)this.setCell(s,i);this.length=t}get(t){let e=this._data[t*v+0],r=e&2097151;return[this._data[t*v+1],e&2097152?this._combined[t]:r?k(r):"",e>>22,e&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,e){this._data[t*v+1]=e[0],e[1].length>1?(this._combined[t]=e[1],this._data[t*v+0]=t|2097152|e[2]<<22):this._data[t*v+0]=e[1].charCodeAt(0)|e[2]<<22}getWidth(t){return this._data[t*v+0]>>22}hasWidth(t){return this._data[t*v+0]&12582912}getFg(t){return this._data[t*v+1]}getBg(t){return this._data[t*v+2]}hasContent(t){return this._data[t*v+0]&4194303}getCodePoint(t){let e=this._data[t*v+0];return e&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):e&2097151}isCombined(t){return this._data[t*v+0]&2097152}getString(t){let e=this._data[t*v+0];return e&2097152?this._combined[t]:e&2097151?k(e&2097151):""}isProtected(t){return this._data[t*v+2]&536870912}loadCell(t,e){return Ee=t*v,e.content=this._data[Ee+0],e.fg=this._data[Ee+1],e.bg=this._data[Ee+2],e.content&2097152&&(e.combinedData=this._combined[t]),e.bg&268435456&&(e.extended=this._extendedAttrs[t]),e}setCell(t,e){e.content&2097152&&(this._combined[t]=e.combinedData),e.bg&268435456&&(this._extendedAttrs[t]=e.extended),this._data[t*v+0]=e.content,this._data[t*v+1]=e.fg,this._data[t*v+2]=e.bg}setCellFromCodepoint(t,e,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*v+0]=e|r<<22,this._data[t*v+1]=i.fg,this._data[t*v+2]=i.bg}addCodepointToCell(t,e,r){let i=this._data[t*v+0];i&2097152?this._combined[t]+=k(e):i&2097151?(this._combined[t]=k(i&2097151)+k(e),i&=-2097152,i|=2097152):i=e|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*v+0]=i}insertCells(t,e,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),e<this.length-t){for(let i=this.length-t-e-1;i>=0;--i)this.setCell(t+e+i,this.loadCell(t+i,vt));for(let i=0;i<e;++i)this.setCell(t+i,r)}else for(let i=t;i<this.length;++i)this.setCell(i,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,e,r){if(t%=this.length,e<this.length-t){for(let i=0;i<this.length-t-e;++i)this.setCell(t+i,this.loadCell(t+e+i,vt));for(let i=this.length-e;i<this.length;++i)this.setCell(i,r)}else for(let i=t;i<this.length;++i)this.setCell(i,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,e,r,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),e<this.length&&this.getWidth(e-1)===2&&!this.isProtected(e)&&this.setCellFromCodepoint(e,0,1,r);t<e&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),e<this.length&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e,0,1,r);t<e&&t<this.length;)this.setCell(t++,r)}resize(t,e){if(t===this.length)return this._data.length*4*ze<this._data.buffer.byteLength;let r=t*v;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,e)}else{this._data=this._data.subarray(0,r);let i=Object.keys(this._combined);for(let o=0;o<i.length;o++){let l=parseInt(i[o],10);l>=t&&delete this._combined[l]}let s=Object.keys(this._extendedAttrs);for(let o=0;o<s.length;o++){let l=parseInt(s[o],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,r*4*ze<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ze<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,e=!1){if(e){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,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 e in t._combined)this._combined[e]=t._combined[e];this._extendedAttrs={};for(let e in t._extendedAttrs)this._extendedAttrs[e]=t._extendedAttrs[e];this.isWrapped=t.isWrapped}clone(){let t=new n(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*v+0]&4194303)return t+(this._data[t*v+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*v+0]&4194303||this._data[t*v+2]&50331648)return t+(this._data[t*v+0]>>22);return 0}copyCellsFrom(t,e,r,i,s){let o=t._data;if(s)for(let c=i-1;c>=0;c--){for(let u=0;u<v;u++)this._data[(r+c)*v+u]=o[(e+c)*v+u];o[(e+c)*v+2]&268435456&&(this._extendedAttrs[r+c]=t._extendedAttrs[e+c])}else for(let c=0;c<i;c++){for(let u=0;u<v;u++)this._data[(r+c)*v+u]=o[(e+c)*v+u];o[(e+c)*v+2]&268435456&&(this._extendedAttrs[r+c]=t._extendedAttrs[e+c])}let l=Object.keys(t._combined);for(let c=0;c<l.length;c++){let u=parseInt(l[c],10);u>=e&&(this._combined[u-e+r]=t._combined[u])}}translateToString(t,e,r,i){e=e??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let s="";for(;e<r;){let o=this._data[e*v+0],l=o&2097151,c=o&2097152?this._combined[e]:l?k(l):" ";if(s+=c,i)for(let u=0;u<c.length;++u)i.push(e);e+=o>>22||1}return i&&i.push(e),s}};var gt="di$target",et="di$dependencies",Ze=new Map;function It(n){return n[et]||[]}function w(n){if(Ze.has(n))return Ze.get(n);let t=function(e,r,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");tr(t,e,i)};return t._id=n,Ze.set(n,t),t}function tr(n,t,e){t[gt]===t?t[et].push({id:n,index:e}):(t[et]=[{id:n,index:e}],t[gt]=t)}var q=w("BufferService"),St=w("MouseStateService"),xt=w("CoreService"),Ct=w("CharsetService"),Et=w("InstantiationService");var j=w("LogService"),$=w("OptionsService"),yt=w("OscLinkService"),Tt=w("UnicodeService"),jr=w("DecorationService");var tt=class{constructor(...t){this._entries=new Map;for(let[e,r]of t)this.set(e,r)}set(t,e){let r=this._entries.get(t);return this._entries.set(t,e),r}forEach(t){for(let[e,r]of this._entries.entries())t(e,r)}has(t){return this._entries.has(t)}get(t){return this._entries.get(t)}},ye=class{constructor(){this._services=new tt;this._services.set(Et,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let r=It(t).sort((o,l)=>o.index-l.index),i=[];for(let o of r){let l=this._services.get(o.id);if(!l)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${o.id._id}.`);i.push(l)}let s=r.length>0?r[0].index:e.length;if(e.length!==s)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${s+1} conflicts with ${e.length} static arguments`);return new t(...e,...i)}};var rr={trace:0,debug:1,info:2,warn:3,error:4,off:5},ir="xterm.js: ",z=class extends g{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=rr[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let r=0;r<e.length;r++)typeof e[r]=="function"&&(e[r]=e[r]())}_log(e,r,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":ir)+r,...i)}trace(e,...r){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,r)}debug(e,...r){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,r)}info(e,...r){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,r)}warn(e,...r){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,r)}error(e,...r){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,r)}};z=H([R(0,$)],z);var le=class extends g{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 r=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)r[i]=this._array[this._getCyclicIndex(i)];this._array=r,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let r=this._length;r<e;r++)this._array[r]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,r){this._array[this._getCyclicIndex(e)]=r}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,r,...i){if(r){for(let s=e;s<this._length-r;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+r)];this._length-=r,this.onDeleteEmitter.fire({index:e,amount:r})}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,r,i){if(!(r<=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 o=r-1;o>=0;o--)this.set(e+o+i,this.get(e+o));let s=e+r+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<r;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}};var Te=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),ce=Te?"node":navigator.userAgent,rt=Te?"node":navigator.platform,ci=ce.includes("Firefox"),ui=ce.includes("Chrome"),hi=ce.includes("Edge"),di=/^((?!chrome|android).)*safari/i.test(ce);var At=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(rt),fi=["Windows","Win16","Win32","WinCE"].includes(rt),pi=rt.indexOf("Linux")>=0,_i=/\bCrOS\b/.test(ce);var De=class{constructor(t){this._tasks=[];this._i=0;this._logService=t}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,r=0,i=t.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),r=Math.max(e,r),s=t.timeRemaining(),r*1.5>s){i-e<-20&&this._logService.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-e))}ms`),this._start();return}i=s}this.clear()}},it=class extends De{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},st=class extends De{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Bt=!Te&&"requestIdleCallback"in window?st:it;function Pt(n,t,e,r,i,s){let o=[];for(let l=0;l<n.length-1;l++){let c=l,u=n.get(++c);if(!u.isWrapped)continue;let _=[n.get(l)];for(;c<n.length&&u.isWrapped;)_.push(u),u=n.get(++c);if(!s&&r>=l&&r<c){l+=_.length-1;continue}let a=0,d=J(_,a,t),m=1,p=0;for(;m<_.length;){let h=J(_,m,t),S=h-p,E=e-d,P=Math.min(S,E);_[a].copyCellsFrom(_[m],p,d,P,!1),d+=P,d===e&&(a++,d=0),p+=P,p===h&&(m++,p=0),d===0&&a!==0&&_[a-1].getWidth(e-1)===2&&(_[a].copyCellsFrom(_[a-1],e-1,d++,1,!1),_[a-1].setCell(e-1,i))}_[a].replaceCells(d,e,i);let f=0;for(let h=_.length-1;h>0&&(h>a||_[h].getTrimmedLength()===0);h--)f++;f>0&&(o.push(l+_.length-f),o.push(f)),l+=_.length-1}return o}function Rt(n,t){let e=[],r=0,i=t[r],s=0;for(let o=0;o<n.length;o++)if(i===o){let l=t[++r];n.onDeleteEmitter.fire({index:o-s,amount:l}),o+=l-1,s+=l,i=t[++r]}else e.push(o);return{layout:e,countRemoved:s}}function Ot(n,t){let e=[];for(let r=0;r<t.length;r++)e.push(n.get(t[r]));for(let r=0;r<e.length;r++)n.set(r,e[r]);n.length=t.length}function kt(n,t,e){let r=[],i=n.map((c,u)=>J(n,u,t)).reduce((c,u)=>c+u),s=0,o=0,l=0;for(;l<i;){if(i-l<e){r.push(i-l);break}s+=e;let c=J(n,o,t);s>c&&(s-=c,o++);let u=n[o].getWidth(s-1)===2;u&&s--;let _=u?e-1:e;r.push(_),l+=_}return r}function J(n,t,e){if(t===n.length-1)return n[t].getTrimmedLength();let r=!n[t].hasContent(e-1)&&n[t].getWidth(e-1)===1,i=n[t+1].getWidth(0)===2;return r&&i?e-1:e}var Be=class Be{constructor(t){this.line=t;this.isDisposed=!1;this._disposables=[];this._id=Be._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(),mt(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};Be._nextId=1;var Ae=Be;var C={},W=C.B;C[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"};C.A={"#":"\xA3"};C.B=void 0;C[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};C.C=C[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};C.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};C.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};C.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};C.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};C.E=C[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};C.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};C.H=C[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};C["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};var wt=4294967295,ue=class{constructor(t,e,r,i){this._hasScrollback=t;this._optionsService=e;this._bufferService=r;this._logService=i;this.ydisp=0;this.ybase=0;this.y=0;this.x=0;this.tabs={};this.savedY=0;this.savedX=0;this.savedCurAttrData=x.clone();this.savedCharset=W;this.savedCharsets=[];this.savedGlevel=0;this.savedOriginMode=!1;this.savedWraparoundMode=!0;this.markers=[];this._nullCell=D.fromCharData([0,"",1,0]);this._whitespaceCell=D.fromCharData([0," ",1,32]);this._isClearing=!1;this._memoryCleanupPosition=0;this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new le(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops(),this._memoryCleanupQueue=new Bt(this._logService)}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new K),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new K),this._whitespaceCell}getBlankLine(t,e){return new U(this._bufferService.cols,this.getNullCell(t),e)}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(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>wt?wt:e}fillViewportRows(t){if(this.lines.length===0){t??=x;let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new le(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let r=this.getNullCell(x),i=0,s=this._getCorrectBufferLength(e);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<t)for(let l=0;l<this.lines.length;l++)i+=+this.lines.get(l).resize(t,r);let o=0;if(this._rows<e)for(let l=this._rows;l<e;l++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new U(t,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new U(t,r)));else for(let l=this._rows;l>e;l--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let l=this.lines.length-s;l>0&&(this.lines.trimStart(l),this.ybase=Math.max(this.ybase-l,0),this.ydisp=Math.max(this.ydisp-l,0),this.savedY=Math.max(this.savedY-l,0)),this.lines.maxLength=s}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(t,r);if(this._cols=t,this._rows=e,this.lines.length>0){let o=Math.max(0,this.lines.length-this.ybase-1);this.y=Math.min(this.y,o)}this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let r=this._optionsService.rawOptions.reflowCursorLine,i=Pt(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(x),r);if(i.length>0){let s=Rt(this.lines,i);Ot(this.lines,s.layout),this._reflowLargerAdjustViewport(t,e,s.countRemoved)}}_reflowLargerAdjustViewport(t,e,r){let i=this.getNullCell(x),s=r;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new U(t,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(t,e){let r=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(x),s=[],o=0;for(let l=this.lines.length-1;l>=0;l--){let c=this.lines.get(l);if(!c||!c.isWrapped&&c.getTrimmedLength()<=t)continue;let u=[c];for(;c.isWrapped&&l>0;)c=this.lines.get(--l),u.unshift(c);if(!r){let I=this.ybase+this.y;if(I>=l&&I<l+u.length)continue}let _=u[u.length-1].getTrimmedLength(),a=kt(u,this._cols,t),d=a.length-u.length,m;this.ybase===0&&this.y!==this.lines.length-1?m=Math.max(0,this.y-this.lines.maxLength+d):m=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let I=0;I<d;I++){let Ye=this.getBlankLine(x,!0);p.push(Ye)}p.length>0&&(s.push({start:l+u.length+o,newLines:p}),o+=p.length),u.push(...p);let f=a.length-1,h=a[f];h===0&&(f--,h=a[f]);let S=u.length-d-1,E=_;for(;S>=0;){let I=Math.min(E,h);if(u[f]===void 0)break;if(u[f].copyCellsFrom(u[S],E-I,h-I,I,!0),h-=I,h===0&&(f--,h=a[f]),E-=I,E===0){S--;let Ye=Math.max(S,0);E=J(u,Ye,this._cols)}}for(let I=0;I<u.length;I++)a[I]<t&&u[I].setCell(a[I],i);let P=d-m;for(;P-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+e-1)}if(s.length>0){let l=[],c=[];for(let h=0;h<this.lines.length;h++)c.push(this.lines.get(h));let u=this.lines.length,_=u-1,a=0,d=s[a];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let m=0;for(let h=Math.min(this.lines.maxLength-1,u+o-1);h>=0;h--)if(d&&d.start>_+m){for(let S=d.newLines.length-1;S>=0;S--)this.lines.set(h--,d.newLines[S]);h++,l.push({index:_+1,amount:d.newLines.length}),m+=d.newLines.length,d=s[++a]}else this.lines.set(h,c[_--]);let p=0;for(let h=l.length-1;h>=0;h--)l[h].index+=p,this.lines.onInsertEmitter.fire(l[h]),p+=l[h].amount;let f=Math.max(0,u+o-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(t,e,r=0,i){let s=this.lines.get(t);return s?s.translateToString(e,r,i):""}getWrappedRangeForLine(t){let e=t,r=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:e,last:r}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t??=this.x;!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t??=this.x;!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new Ae(t);return this.markers.push(e),e.register(this.lines.onTrim(r=>{e.line-=r,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(r=>{e.line>=r.index&&(e.line+=r.amount)})),e.register(this.lines.onDelete(r=>{e.line>=r.index&&e.line<r.index+r.amount&&e.dispose(),e.line>r.index&&(e.line-=r.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}};var Pe=class extends g{constructor(e,r,i){super();this._optionsService=e;this._bufferService=r;this._logService=i;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 ue(!0,this._optionsService,this._bufferService,this._logService),this._normal.fillViewportRows(),this._alt=new ue(!1,this._optionsService,this._bufferService,this._logService),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,r){this._normal.resize(e,r),this._alt.resize(e,r),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}};var at=2,ot=1,Q=class extends g{constructor(e,r){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,at),this.rows=Math.max(e.rawOptions.rows||0,ot),this.buffers=this._register(new Pe(e,this,r)),this._register(this.buffers.onBufferActivate(i=>{this._onScroll.fire(i.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,r){let i=this.cols!==e,s=this.rows!==r;this.cols=e,this.rows=r,this.buffers.resize(e,r),this._onResize.fire({cols:e,rows:r,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,r=!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,r),this._cachedBlankLine=s),s.isWrapped=r;let o=i.ybase+i.scrollTop,l=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;l===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(l+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=l-o+1;i.lines.shiftElements(o+1,c-1,-1),i.lines.set(l,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,r){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&&(r||this._onScroll.fire(i.ydisp))}};Q=H([R(0,$),R(1,j)],Q);var Z={cols:80,rows:24,showCursorImmediately:!1,cursorBlink:!1,blinkIntervalDuration:0,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollbar:{showScrollbar:!0},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:At,windowOptions:{},windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",quirks:{},vtExtensions:{}},nr=["normal","bold","100","200","300","400","500","600","700","800","900"],Re=class extends g{constructor(e){super();this._onOptionChange=this._register(new b);this.onOptionChange=this._onOptionChange.event;let r={...Z};for(let i in e)if(i in r)try{let s=e[i];r[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=r,this.options={...r},this._setupOptions(),this._register(F(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,r){return this.onOptionChange(i=>{i===e&&r(this.rawOptions[e])})}onMultipleOptionChange(e,r){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&r()})}_setupOptions(){let e=i=>{if(!(i in Z))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},r=(i,s)=>{if(!(i in Z))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:r.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,r){switch(e){case"cursorStyle":if(r||(r=Z[e]),!ar(r))throw new Error(`"${r}" is not a valid value for ${e}`);break;case"wordSeparator":r||(r=Z[e]);break;case"fontWeight":case"fontWeightBold":if(typeof r=="number"&&1<=r&&r<=1e3)break;r=nr.includes(r)?r:Z[e];break;case"blinkIntervalDuration":if(r=Math.floor(r),r<0)throw new Error(`${e} cannot be less than 0, value: ${r}`);break;case"cursorWidth":r=Math.floor(r);case"lineHeight":case"tabStopWidth":if(r<1)throw new Error(`${e} cannot be less than 1, value: ${r}`);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(r*10)/10));break;case"scrollback":if(r=Math.min(r,4294967295),r<0)throw new Error(`${e} cannot be less than 0, value: ${r}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${r}`);break;case"rows":case"cols":if(!r&&r!==0)throw new Error(`${e} must be numeric, value: ${r}`);break;case"windowsPty":r=r??{};break}return r}};function ar(n){return n==="block"||n==="underline"||n==="bar"}function ee(n,t=5){if(typeof n!="object")return n;let e=Array.isArray(n)?[]:{};for(let r in n)e[r]=t<=1?n[r]:n[r]&&ee(n[r],t-1);return e}var Lt=Object.freeze({insertMode:!1}),Ht=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,colorSchemeUpdates:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,win32InputMode:!1,wraparound:!0}),Mt=()=>({flags:0,mainFlags:0,altFlags:0,mainStack:[],altStack:[]}),te=class extends g{constructor(e,r,i){super();this._bufferService=e;this._logService=r;this._optionsService=i;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.isCursorInitialized=i.rawOptions.showCursorImmediately??!1,this.modes=ee(Lt),this.decPrivateModes=ee(Ht),this.kittyKeyboard=Mt()}reset(){this.modes=ee(Lt),this.decPrivateModes=ee(Ht),this.kittyKeyboard=Mt()}triggerDataEvent(e,r=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;r&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),r&&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(r=>r.charCodeAt(0))),this._onBinary.fire(e))}};te=H([R(0,q),R(1,j),R(2,$)],te);var Nt={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:n=>n.button===4||n.action!==1?!1:(n.ctrl=!1,n.alt=!1,n.shift=!1,!0)},VT200:{events:19,restrict:n=>n.action!==32},DRAG:{events:23,restrict:n=>!(n.action===32&&n.button===3)},ANY:{events:31,restrict:n=>!0}};function lt(n,t){let e=(n.ctrl?16:0)|(n.shift?4:0)|(n.alt?8:0);return n.button===4?(e|=64,e|=n.action):(e|=n.button&3,n.button&4&&(e|=64),n.button&8&&(e|=128),n.action===32?e|=32:n.action===0&&!t&&(e|=3)),e}var ct=String.fromCharCode,Ft={DEFAULT:n=>{let t=[lt(n,!1)+32,n.col+32,n.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${ct(t[0])}${ct(t[1])}${ct(t[2])}`},SGR:n=>{let t=n.action===0&&n.button!==4?"m":"M";return`\x1B[<${lt(n,!0)};${n.col};${n.row}${t}`},SGR_PIXELS:n=>{let t=n.action===0&&n.button!==4?"m":"M";return`\x1B[<${lt(n,!0)};${n.x};${n.y}${t}`}},Oe=class extends g{constructor(){super();this._protocols={};this._encodings={};this._activeProtocol="";this._activeEncoding="";this._onProtocolChange=this._register(new b);this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(Nt))this.addProtocol(e,Nt[e]);for(let e of Object.keys(Ft))this.addEncoding(e,Ft[e]);this.reset()}addProtocol(e,r){this._protocols[e]=r}addEncoding(e,r){this._encodings[e]=r}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"}setCustomWheelEventHandler(e){this._customWheelEventHandler=e}allowCustomWheelEvent(e){return this._customWheelEventHandler?this._customWheelEventHandler(e)!==!1:!0}restrictMouseEvent(e){return this._protocols[this._activeProtocol].restrict(e)}encodeMouseEvent(e){return this._encodings[this._activeEncoding](e)}get isDefaultEncoding(){return this._activeEncoding==="DEFAULT"}get isPixelEncoding(){return this._activeEncoding==="SGR_PIXELS"}};var ut=[[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]],or=[[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]],y;function lr(n,t){let e=0,r=t.length-1,i;if(n<t[0][0]||n>t[r][1])return!1;for(;r>=e;)if(i=e+r>>1,n>t[i][1])e=i+1;else if(n<t[i][0])r=i-1;else return!0;return!1}var ke=class{constructor(){this.version="6";if(!y){y=new Uint8Array(65536),y.fill(1),y[0]=0,y.fill(0,1,32),y.fill(0,127,160),y.fill(2,4352,4448),y[9001]=2,y[9002]=2,y.fill(2,11904,42192),y[12351]=1,y.fill(2,44032,55204),y.fill(2,63744,64256),y.fill(2,65040,65050),y.fill(2,65072,65136),y.fill(2,65280,65377),y.fill(2,65504,65511);for(let t=0;t<ut.length;++t)y.fill(0,ut[t][0],ut[t][1]+1)}}wcwidth(t){return t<32?0:t<127?1:t<65536?y[t]:lr(t,or)?0:t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}charProperties(t,e){let r=this.wcwidth(t),i=r===0&&e!==0;if(i){let s=O.extractWidth(e);s===0?i=!1:s>r&&(r=s)}return O.createPropertyValue(0,r,i)}};var O=class n{constructor(){this._providers=Object.create(null);this._active="";this._onChange=new b;this.onChange=this._onChange.event;let t=new ke;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,e,r=!1){return(t&16777215)<<3|(e&3)<<1|(r?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 e=0,r=0,i=t.length;for(let s=0;s<i;++s){let o=t.charCodeAt(s);if(55296<=o&&o<=56319){if(++s>=i)return e+this.wcwidth(o);let u=t.charCodeAt(s);56320<=u&&u<=57343?o=(o-55296)*1024+u-56320+65536:e+=this.wcwidth(u)}let l=this.charProperties(o,r),c=n.extractWidth(l);n.extractShouldJoin(l)&&(c-=n.extractWidth(r)),e+=c,r=l}return e}charProperties(t,e){return this._activeProvider.charProperties(t,e)}};var we=class{constructor(){this.glevel=0;this._charsets=[]}get charsets(){return this._charsets}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(t){this.glevel=t,this.charset=this._charsets[t]}setgCharset(t,e){this._charsets[t]=e,this.glevel===t&&(this.charset=e)}};function ht(n){let e=n.buffer.lines.get(n.buffer.ybase+n.buffer.y-1)?.get(n.cols-1),r=n.buffer.lines.get(n.buffer.ybase+n.buffer.y);r&&e&&(r.isWrapped=e[3]!==0&&e[3]!==32)}var he=2147483647,cr=256,re=class n{constructor(t=32,e=32){this.maxLength=t;this.maxSubParamsLength=e;if(e>cr)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(e),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let e=new n;if(!t.length)return e;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let i=t[r];if(Array.isArray(i))for(let s=0;s<i.length;++s)e.addSubParam(i[s]);else e.addParam(i)}return e}clone(){let t=new n(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 e=0;e<this.length;++e){t.push(this.params[e]);let r=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}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>he?he: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>he?he:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let e=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-e>0?this._subParams.subarray(e,r):null}getSubParamsAll(){let t={};for(let e=0;e<this.length;++e){let r=this._subParamsIdx[e]>>8,i=this._subParamsIdx[e]&255;i-r>0&&(t[e]=this._subParams.slice(r,i))}return t}addDigit(t){let e;if(this._rejectDigits||!(e=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[e-1];r[e-1]=~i?Math.min(i*10+t,he):t}};var de=[],Le=class{constructor(){this._state=0;this._active=de;this._id=-1;this._handlers=Object.create(null);this._handlerFb=()=>{};this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]??=[];let r=this._handlers[t];return r.push(e),{dispose:()=>{let i=r.indexOf(e);i!==-1&&r.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=de}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=de,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||de,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,r){if(!this._active.length)this._handlerFb(this._id,"PUT",M(t,e,r));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,r)}start(){this.reset(),this._state=1}put(t,e,r){if(this._state!==3){if(this._state===1)for(;e<r;){let i=t[e++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&r-e>0&&this._put(t,e,r)}}end(t,e=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",t);else{let r=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=e,s=this._stack.fallThrough,this._stack.paused=!1),!s&&r===!1){for(;i>=0&&(r=this._active[i].end(t),r!==!0);i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if(r=this._active[i].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}this._active=de,this._id=-1,this._state=0}}},He=class He{constructor(t){this._handler=t;this._data="";this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,r){this._hitLimit||(this._data+=M(t,e,r),this._data.length>He._payloadLimit&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,e}};He._payloadLimit=1e7;var T=He;var fe=[],Me=class{constructor(){this._handlers=Object.create(null);this._active=fe;this._ident=0;this._handlerFb=()=>{};this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=fe}registerHandler(t,e){this._handlers[t]??=[];let r=this._handlers[t];return r.push(e),{dispose:()=>{let i=r.indexOf(e);i!==-1&&r.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}reset(){if(this._active.length)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].unhook(!1);this._stack.paused=!1,this._active=fe,this._ident=0}hook(t,e){if(this.reset(),this._ident=t,this._active=this._handlers[t]||fe,!this._active.length)this._handlerFb(this._ident,"HOOK",e);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(e)}put(t,e,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",M(t,e,r));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,r)}unhook(t,e=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",t);else{let r=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=e,s=this._stack.fallThrough,this._stack.paused=!1),!s&&r===!1){for(;i>=0&&(r=this._active[i].unhook(t),r!==!0);i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if(r=this._active[i].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}this._active=fe,this._ident=0}},pe=new re;pe.addParam(0);var Ne=class Ne{constructor(t){this._handler=t;this._data="";this._params=pe;this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():pe,this._data="",this._hitLimit=!1}put(t,e,r){this._hitLimit||(this._data+=M(t,e,r),this._data.length>Ne._payloadLimit&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(r=>(this._params=pe,this._data="",this._hitLimit=!1,r));return this._params=pe,this._data="",this._hitLimit=!1,e}};Ne._payloadLimit=1e7;var _e=Ne;var ie=[],Fe=class{constructor(){this._state=0;this._active=ie;this._id=-1;this._handlers=Object.create(null);this._handlerFb=()=>{};this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(t,e){this._handlers[t]??=[];let r=this._handlers[t];return r.push(e),{dispose:()=>{let i=r.indexOf(e);i!==-1&&r.splice(i,1)}}}clearHandler(t){this._handlers[t]&&delete this._handlers[t]}setHandlerFallback(t){this._handlerFb=t}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ie}reset(){if(this._state===2)for(let t=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;t>=0;--t)this._active[t].end(!1);this._stack.paused=!1,this._active=ie,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ie,!this._active.length)this._handlerFb(this._id,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start()}_put(t,e,r){if(!this._active.length)this._handlerFb(this._id,"PUT",M(t,e,r));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(t,e,r)}start(){this.reset(),this._state=1}put(t,e,r){this._state!==3&&(this._state===1&&e<r&&(this._id=t[e++],this._state=2,this._start()),this._state===2&&r-e>0&&this._put(t,e,r))}end(t,e=!0){if(this._state!==0){if(this._state!==3){if(this._state===1){this._active=ie,this._id=-1,this._state=0;return}if(!this._active.length)this._handlerFb(this._id,"END",t);else{let r=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=e,s=this._stack.fallThrough,this._stack.paused=!1),!s&&r===!1){for(;i>=0&&(r=this._active[i].end(t),r!==!0);i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if(r=this._active[i].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}}this._active=ie,this._id=-1,this._state=0}}},We=class We{constructor(t){this._handler=t;this._data="";this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(t,e,r){this._hitLimit||(this._data+=M(t,e,r),this._data.length>We._payloadLimit&&(this._data="",this._hitLimit=!0))}end(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data),e instanceof Promise))return e.then(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,e}};We._payloadLimit=1e7;var Ue=We;var dt=class{constructor(t){this.table=new Uint16Array(t)}setDefault(t,e){this.table.fill(t<<8|e)}add(t,e,r,i){this.table[e<<8|t]=r<<8|i}addMany(t,e,r,i){for(let s=0;s<t.length;s++)this.table[e<<8|t[s]]=r<<8|i}},B=160,ur=(function(){let n=new dt(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),r=(l,c)=>e.slice(l,c),i=r(32,127),s=r(0,24);s.push(25),s.push.apply(s,r(28,32));let o=r(0,15);n.setDefault(1,0),n.addMany(i,0,2,0);for(let l of o)n.addMany([24,26,153,154],l,3,0),n.addMany(r(128,144),l,3,0),n.addMany(r(144,152),l,3,0),n.add(156,l,0,0),n.add(27,l,11,1),n.add(157,l,4,8),n.addMany([152,158],l,0,7),n.add(159,l,15,14),n.add(155,l,11,3),n.add(144,l,11,9);return n.addMany(s,0,3,0),n.addMany(s,1,3,1),n.add(127,1,0,1),n.addMany(s,8,0,8),n.addMany(s,3,3,3),n.add(127,3,0,3),n.addMany(s,4,3,4),n.add(127,4,0,4),n.addMany(s,6,3,6),n.addMany(s,5,3,5),n.add(127,5,0,5),n.addMany(s,2,3,2),n.add(127,2,0,2),n.add(93,1,4,8),n.addMany(i,8,5,8),n.add(127,8,5,8),n.addMany([156,27,24,26,7],8,6,0),n.addMany(r(28,32),8,0,8),n.addMany([88,94],1,0,7),n.addMany(i,7,0,7),n.addMany(s,7,0,7),n.add(156,7,0,0),n.add(127,7,0,7),n.add(95,1,15,14),n.addMany(i,14,16,14),n.addMany(s,14,0,14),n.add(127,14,0,14),n.addMany([27,156,24,26],14,17,0),n.add(91,1,11,3),n.addMany(r(64,127),3,7,0),n.addMany(r(48,60),3,8,4),n.addMany([60,61,62,63],3,9,4),n.addMany(r(48,60),4,8,4),n.addMany(r(64,127),4,7,0),n.addMany([60,61,62,63],4,0,6),n.addMany(r(32,64),6,0,6),n.add(127,6,0,6),n.addMany(r(64,127),6,0,0),n.addMany(r(32,48),3,9,5),n.addMany(r(32,48),5,9,5),n.addMany(r(48,64),5,0,6),n.addMany(r(64,127),5,7,0),n.addMany(r(32,48),4,9,5),n.addMany(r(32,48),1,9,2),n.addMany(r(32,48),2,9,2),n.addMany(r(48,127),2,10,0),n.addMany(r(48,80),1,10,0),n.addMany(r(81,88),1,10,0),n.addMany([89,90,92],1,10,0),n.addMany(r(96,127),1,10,0),n.add(80,1,11,9),n.addMany(s,9,0,9),n.add(127,9,0,9),n.addMany(r(28,32),9,0,9),n.addMany(r(32,48),9,9,12),n.addMany(r(48,60),9,8,10),n.addMany([60,61,62,63],9,9,10),n.addMany(s,11,0,11),n.addMany(r(32,128),11,0,11),n.addMany(r(28,32),11,0,11),n.addMany(s,10,0,10),n.add(127,10,0,10),n.addMany(r(28,32),10,0,10),n.addMany(r(48,60),10,8,10),n.addMany([60,61,62,63],10,0,11),n.addMany(r(32,48),10,9,12),n.addMany(s,12,0,12),n.add(127,12,0,12),n.addMany(r(28,32),12,0,12),n.addMany(r(32,48),12,9,12),n.addMany(r(48,64),12,0,11),n.addMany(r(64,127),12,12,13),n.addMany(r(64,127),10,12,13),n.addMany(r(64,127),9,12,13),n.addMany(s,13,13,13),n.addMany(i,13,13,13),n.add(127,13,0,13),n.addMany([27,156,24,26],13,14,0),n.add(B,0,2,0),n.add(B,8,5,8),n.add(B,6,0,6),n.add(B,11,0,11),n.add(B,13,13,13),n.add(B,14,16,14),n})(),Ge=class extends g{constructor(e=ur){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 re,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(r,i,s)=>{},this._executeHandlerFb=r=>{},this._csiHandlerFb=(r,i)=>{},this._escHandlerFb=r=>{},this._errorHandlerFb=r=>r,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(F(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Le),this._dcsParser=this._register(new Me),this._apcParser=this._register(new Fe),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,r=[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 o=0;o<e.intermediates.length;++o){let l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=l}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(r[0]>s||s>r[1])throw new Error(`final must be in range ${r[0]} .. ${r[1]}`);return i<<=8,i|=s,i}identToString(e){let r=[];for(;e;)r.push(String.fromCharCode(e&255)),e>>=8;return r.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,r){let i=this._identifier(e,[48,126]);this._escHandlers[i]??=[];let s=this._escHandlers[i];return s.push(r),{dispose:()=>{let o=s.indexOf(r);o!==-1&&s.splice(o,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,r){this._executeHandlers[e.charCodeAt(0)]=r}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,r){let i=this._identifier(e);this._csiHandlers[i]??=[];let s=this._csiHandlers[i];return s.push(r),{dispose:()=>{let o=s.indexOf(r);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,r){return this._dcsParser.registerHandler(this._identifier(e),r)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,r){return this._oscParser.registerHandler(e,r)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}registerApcHandler(e,r){return this._apcParser.registerHandler(e,r)}clearApcHandler(e){this._apcParser.clearHandler(e)}setApcHandlerFallback(e){this._apcParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._apcParser.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,r,i,s,o){this._parseStack.state=e,this._parseStack.handlers=r,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,r,i){let s=0,o=0,l=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=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 u=this._parseStack.handlers,_=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&_>-1){for(;_>=0&&(c=u[_](this._params),c!==!0);_--)if(c instanceof Promise)return this._parseStack.handlerPos=_,c}this._parseStack.handlers=[];break;case 4:if(i===!1&&_>-1){for(;_>=0&&(c=u[_](),c!==!0);_--)if(c instanceof Promise)return this._parseStack.handlerPos=_,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,i),c)return c;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],c=this._oscParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 7:if(s=e[this._parseStack.chunkPos],c=this._apcParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&255}for(let u=l;u<r;++u){switch(s=e[u],o=this._transitions.table[this.currentState<<8|(s<160?s:B)],o>>8){case 2:for(let f=u+1;;++f){if(f>=r||(s=e[f])<32||s>126&&s<B){this._printHandler(e,u,f),u=f-1;break}if(++f>=r||(s=e[f])<32||s>126&&s<B){this._printHandler(e,u,f),u=f-1;break}if(++f>=r||(s=e[f])<32||s>126&&s<B){this._printHandler(e,u,f),u=f-1;break}if(++f>=r||(s=e[f])<32||s>126&&s<B){this._printHandler(e,u,f),u=f-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:u,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|s],d=a?a.length-1:-1;for(;d>=0&&(c=a[d](this._params),c!==!0);d--)if(c instanceof Promise)return this._preserveStack(3,a,d,o,u),c;d<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(++u<r&&(s=e[u])>47&&s<60);u--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let m=this._escHandlers[this._collect<<8|s],p=m?m.length-1:-1;for(;p>=0&&(c=m[p](),c!==!0);p--)if(c instanceof Promise)return this._preserveStack(4,m,p,o,u),c;p<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 f=u+1;;++f)if(f>=r||(s=e[f])===24||s===26||s===27||s>127&&s<B){this._dcsParser.put(e,u,f),u=f-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,o,u),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let f=u+1;;f++)if(f>=r||(s=e[f])<32||s>127&&s<B){this._oscParser.put(e,u,f),u=f-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,o,u),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 15:this._apcParser.start();break;case 16:for(let f=u+1;;++f)if(f>=r||(s=e[f])===24||s===26||s===27||s===156||s>127&&s<B){this._apcParser.put(e,u,f),u=f-1;break}break;case 17:if(c=this._apcParser.end(s!==24&&s!==26),c)return this._preserveStack(7,[],0,o,u),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&255}}};var hr=/^([\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})$/,dr=/^[\da-f]+$/;function ft(n){if(!n)return;let t=n.toLowerCase();if(t.startsWith("rgb:")){t=t.slice(4);let e=hr.exec(t);if(e){let r=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/r*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/r*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/r*255)]}}else if(t.startsWith("#")&&(t=t.slice(1),dr.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let s=parseInt(t.slice(e*i,e*i+e),16);r[i]=e===1?s<<4:e===2?s:e===3?s>>4:s>>8}return r}}var Gt="6.0.0";var fr={"(":0,")":1,"*":2,"+":3,"-":1,".":2},V=131072,Kt=10;function qt(n,t){if(n>24)return t.setWinLines||!1;switch(n){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 $t=5e3,Vt=0,Ke=class extends g{constructor(e,r,i,s,o,l,c,u,_=new Ge){super();this._bufferService=e;this._charsetService=r;this._coreService=i;this._logService=s;this._optionsService=o;this._oscLinkService=l;this._mouseStateService=c;this._unicodeService=u;this._parser=_;this._parseBuffer=new Uint32Array(4096);this._stringDecoder=new me;this._utf8Decoder=new ve;this._windowTitle="";this._iconName="";this._windowTitleStack=[];this._iconNameStack=[];this._curAttrData=x.clone();this._eraseAttrDataInternal=x.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._onRequestColorSchemeQuery=this._register(new b);this.onRequestColorSchemeQuery=this._onRequestColorSchemeQuery.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 be(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,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:a,action:d,data:m})}),this._parser.setDcsHandlerFallback((a,d,m)=>{d==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(a),action:d,payload:m})}),this._parser.setPrintHandler((a,d,m)=>this.print(a,d,m)),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.scrollDown(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({prefix:">",final:"q"},a=>this.sendXtVersion(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.registerCsiHandler({prefix:"=",final:"u"},a=>this.kittyKeyboardSet(a)),this._parser.registerCsiHandler({prefix:"?",final:"u"},a=>this.kittyKeyboardQuery(a)),this._parser.registerCsiHandler({prefix:">",final:"u"},a=>this.kittyKeyboardPush(a)),this._parser.registerCsiHandler({prefix:"<",final:"u"},a=>this.kittyKeyboardPop(a)),this._parser.setExecuteHandler("\x07",()=>this.bell()),this._parser.setExecuteHandler(`
|
|
18
|
+
`,()=>this.lineFeed()),this._parser.setExecuteHandler("\v",()=>this.lineFeed()),this._parser.setExecuteHandler("\f",()=>this.lineFeed()),this._parser.setExecuteHandler("\r",()=>this.carriageReturn()),this._parser.setExecuteHandler("\b",()=>this.backspace()),this._parser.setExecuteHandler(" ",()=>this.tab()),this._parser.setExecuteHandler("",()=>this.shiftOut()),this._parser.setExecuteHandler("",()=>this.shiftIn()),this._parser.setExecuteHandler("\x84",()=>this.index()),this._parser.setExecuteHandler("\x85",()=>this.nextLine()),this._parser.setExecuteHandler("\x88",()=>this.tabSet()),this._parser.registerOscHandler(0,new T(a=>(this.setTitle(a),this.setIconName(a),!0))),this._parser.registerOscHandler(1,new T(a=>this.setIconName(a))),this._parser.registerOscHandler(2,new T(a=>this.setTitle(a))),this._parser.registerOscHandler(4,new T(a=>this.setOrReportIndexedColor(a))),this._parser.registerOscHandler(8,new T(a=>this.setHyperlink(a))),this._parser.registerOscHandler(10,new T(a=>this.setOrReportFgColor(a))),this._parser.registerOscHandler(11,new T(a=>this.setOrReportBgColor(a))),this._parser.registerOscHandler(12,new T(a=>this.setOrReportCursorColor(a))),this._parser.registerOscHandler(104,new T(a=>this.restoreIndexedColor(a))),this._parser.registerOscHandler(110,new T(a=>this.restoreFgColor(a))),this._parser.registerOscHandler(111,new T(a=>this.restoreBgColor(a))),this._parser.registerOscHandler(112,new T(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 C)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 _e((a,d)=>this.requestStatusString(a,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,r,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=r,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){if(this._logService.logLevel<=3){let r,i=new Promise((s,o)=>{r=setTimeout(()=>o("#SLOW_TIMEOUT"),$t)});Promise.race([e,i]).then(()=>{r!==void 0&&clearTimeout(r)},s=>{if(r!==void 0&&clearTimeout(r),s!=="#SLOW_TIMEOUT")throw s;console.warn(`async parser handler taking longer than ${$t} ms`)})}}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,r){let i,s=this._activeBuffer.x,o=this._activeBuffer.y,l=0,c=this._parseStack.paused;if(c){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,r))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>V&&(l=this._parseStack.position+V)}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<V&&(this._parseBuffer=new Uint32Array(Math.min(e.length,V))),c||this._dirtyRowTracker.clearRange(),e.length>V)for(let a=l;a<e.length;a+=V){let d=a+V<e.length?a+V:e.length,m=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,m))return this._preserveStack(s,o,m,a),this._logSlowResolvingAsync(i),i}else if(!c){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,o,a,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let u=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),_=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);_<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(_,this._bufferService.rows-1),end:Math.min(u,this._bufferService.rows-1)})}print(e,r,i){let s,o,l=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,u=this._bufferService.cols,_=this._coreService.decPrivateModes.wraparound,a=this._coreService.modes.insertMode,d=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);if(!m)return;this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-r>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let p=this._parser.precedingJoinState;for(let f=r;f<i;++f){if(s=e[f],s===173)continue;if(s<127&&l){let P=l[String.fromCharCode(s)];P&&(s=P.charCodeAt(0))}let h=this._unicodeService.charProperties(s,p);o=O.extractWidth(h);let S=O.extractShouldJoin(h),E=S?O.extractWidth(p):0;if(p=h,c&&this._onA11yChar.fire(k(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-E>u){if(_){let P=m,I=this._activeBuffer.x-E;if(this._activeBuffer.x=E,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),!m)return;for(E>0&&m instanceof U&&m.copyCellsFrom(P,I,0,E,!1);I<u;)P.setCellFromCodepoint(I++,0,1,d)}else if(this._activeBuffer.x=u-1,o===2)continue}if(S&&this._activeBuffer.x){let P=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-P,s,o);for(let I=o-E;--I>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(a&&(m.insertCells(this._activeBuffer.x,o-E,this._activeBuffer.getNullCell(d)),m.getWidth(u-1)===2&&m.setCellFromCodepoint(u-1,0,1,d)),m.setCellFromCodepoint(this._activeBuffer.x++,s,o,d),o>0)for(;--o;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=p,this._activeBuffer.x<u&&i-r>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,r){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>qt(i.params[0],this._optionsService.rawOptions.windowOptions)?r(i):!0):this._parser.registerCsiHandler(e,r)}registerDcsHandler(e,r){return this._parser.registerDcsHandler(e,new _e(r))}registerEscHandler(e,r){return this._parser.registerEscHandler(e,r)}registerOscHandler(e,r){return this._parser.registerOscHandler(e,new T(r))}registerApcHandler(e,r){return this._parser.registerApcHandler(e,new Ue(r))}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(){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&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.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,r){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+r):(this._activeBuffer.x=e,this._activeBuffer.y=r),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,r){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+r)}cursorUp(e){let r=this._activeBuffer.y-this._activeBuffer.scrollTop;return r>=0?this._moveCursor(0,-Math.min(r,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let r=this._activeBuffer.scrollBottom-this._activeBuffer.y;return r>=0?this._moveCursor(0,Math.min(r,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 r=e.params[0];return r===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:r===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let r=e.params[0]||1;for(;r--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let r=e.params[0];return r===1&&(this._curAttrData.bg|=536870912),(r===2||r===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,r,i,s=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l&&(l.replaceCells(r,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(l.isWrapped=!1))}_resetBufferLine(e,r=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),r),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,r=!1){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,r);i<this._bufferService.rows;i++)this._resetBufferLine(i,r);this._dirtyRowTracker.markDirty(i);break;case 1:if(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,r),this._activeBuffer.x+1>=this._bufferService.cols){let o=this._activeBuffer.lines.get(i+1);o&&(o.isWrapped=!1)}for(;i--;)this._resetBufferLine(i,r);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+i)?.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,r);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,r=!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,r);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,r);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,r);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let r=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,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;r--;)this._activeBuffer.lines.splice(o-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 r=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;r--;)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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.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 r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let r=e.params[0]||1;for(;r--;)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 r=e.params[0]||1;for(;r--;)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(x));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 r=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,r,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 r=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,r,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 r=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,r,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 r=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,r,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return r&&(r.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 r=this._parser.precedingJoinState;if(!r)return!0;let i=e.params[0]||1,s=O.extractWidth(r),o=this._activeBuffer.x-s,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(c.length*i),_=0;for(let d=0;d<c.length;){let m=c.codePointAt(d)||0;u[_++]=m,d+=m>65535?2:1}let a=_;for(let d=1;d<i;++d)u.copyWithin(a,0,_),a+=_;return this.print(u,0,a),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent("\x1B[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent("\x1B[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent("\x1B[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent("\x1B[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent("\x1B[>83;40003;0c")),!0}sendXtVersion(e){return e.params[0]>0||this._coreService.triggerDataEvent(`\x1BP>|xterm.js(${Gt})\x1B\\`),!0}_is(e){return(this._optionsService.rawOptions.termName+"").startsWith(e)}setMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,W),this._charsetService.setgCharset(1,W),this._charsetService.setgCharset(2,W),this._charsetService.setgCharset(3,W);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.rawOptions.quirks?.allowSetCursorBlink&&(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._mouseStateService.activeProtocol="X10";break;case 1e3:this._mouseStateService.activeProtocol="VT200";break;case 1002:this._mouseStateService.activeProtocol="DRAG";break;case 1003:this._mouseStateService.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._mouseStateService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._mouseStateService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:if(this._optionsService.rawOptions.vtExtensions?.kittyKeyboard){let i=this._coreService.kittyKeyboard;i.mainFlags=i.flags,i.flags=i.altFlags}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;case 2031:(this._optionsService.rawOptions.vtExtensions?.colorSchemeQuery??!0)&&(this._coreService.decPrivateModes.colorSchemeUpdates=!0);break;case 9001:this._optionsService.rawOptions.vtExtensions?.win32InputMode&&(this._coreService.decPrivateModes.win32InputMode=!0);break}return!0}resetMode(e){for(let r=0;r<e.length;r++)switch(e.params[r]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let r=0;r<e.length;r++)switch(e.params[r]){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.rawOptions.quirks?.allowSetCursorBlink&&(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._mouseStateService.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._mouseStateService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._mouseStateService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:if(this._optionsService.rawOptions.vtExtensions?.kittyKeyboard){let i=this._coreService.kittyKeyboard;i.altFlags=i.flags,i.flags=i.mainFlags}this._bufferService.buffers.activateNormalBuffer(),e.params[r]===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;case 2031:(this._optionsService.rawOptions.vtExtensions?.colorSchemeQuery??!0)&&(this._coreService.decPrivateModes.colorSchemeUpdates=!1);break;case 9001:this._optionsService.rawOptions.vtExtensions?.win32InputMode&&(this._coreService.decPrivateModes.win32InputMode=!1);break}return!0}requestMode(e,r){let i;(L=>(L[L.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",L[L.SET=1]="SET",L[L.RESET=2]="RESET",L[L.PERMANENTLY_SET=3]="PERMANENTLY_SET",L[L.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(i||={});let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._mouseStateService,c=this._coreService,{buffers:u,cols:_}=this._bufferService,{active:a,alt:d}=u,m=this._optionsService.rawOptions,p=(S,E)=>(c.triggerDataEvent(`\x1B[${r?"":"?"}${S};${E}$y`),!0),f=S=>S?1:2,h=e.params[0];return r?h===2?p(h,4):h===4?p(h,f(c.modes.insertMode)):h===12?p(h,3):h===20?p(h,f(m.convertEol)):p(h,0):h===1?p(h,f(s.applicationCursorKeys)):h===3?p(h,m.windowOptions.setWinLines?_===80?2:_===132?1:0:0):h===6?p(h,f(s.origin)):h===7?p(h,f(s.wraparound)):h===8?p(h,3):h===9?p(h,f(o==="X10")):h===12?p(h,f(m.cursorBlink)):h===25?p(h,f(!c.isCursorHidden)):h===45?p(h,f(s.reverseWraparound)):h===66?p(h,f(s.applicationKeypad)):h===67?p(h,4):h===1e3?p(h,f(o==="VT200")):h===1002?p(h,f(o==="DRAG")):h===1003?p(h,f(o==="ANY")):h===1004?p(h,f(s.sendFocus)):h===1005?p(h,4):h===1006?p(h,f(l==="SGR")):h===1015?p(h,4):h===1016?p(h,f(l==="SGR_PIXELS")):h===1048?p(h,1):h===47||h===1047||h===1049?p(h,f(a===d)):h===2004?p(h,f(s.bracketedPasteMode)):h===2026?p(h,f(s.synchronizedOutput)):h===9001&&this._optionsService.rawOptions.vtExtensions?.win32InputMode?p(h,f(s.win32InputMode)):p(h,0)}_updateAttrColor(e,r,i,s,o){return r===2?(e|=50331648,e&=-16777216,e|=G.fromColorRGB([i,s,o])):r===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,r,i){let s=[0,0,-1,0,0,0],o=0,l=0;do{if(s[l+o]=e.params[r+l],e.hasSubParams(r+l)){let c=e.getSubParams(r+l),u=0;do s[1]===5&&(o=1),s[l+u+1+o]=c[u];while(++u<c.length&&u+l+1+o<s.length);break}if(s[1]===5&&l+o>=2||s[1]===2&&l+o>=5)break;s[1]&&(o=1)}while(++l+r<e.length&&l+o<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=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 l}_processUnderline(e,r){r.extended=r.extended.clone(),(!~e||e>5)&&(e=1),r.extended.underlineStyle=e,r.fg|=268435456,e===0&&(r.fg&=-268435457),r.updateExtended()}_processSGR0(e){e.fg=x.fg,e.bg=x.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 r=e.length,i,s=this._curAttrData;for(let o=0;o<r;o++)i=e.params[o],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(o)?e.getSubParams(o)[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|=x.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=x.bg&16777215):i===38||i===48||i===58?o+=this._extractColor(e,o,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===221&&(this._optionsService.rawOptions.vtExtensions?.kittySgrBoldFaintControl??!0)?s.fg&=-134217729:i===222&&(this._optionsService.rawOptions.vtExtensions?.kittySgrBoldFaintControl??!0)?s.bg&=-134217729:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent("\x1B[0n");break;case 6:let r=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`\x1B[${r};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let r=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`\x1B[?${r};${i}R`);break;case 15:break;case 25:break;case 26:break;case 53:break;case 996:(this._optionsService.rawOptions.vtExtensions?.colorSchemeQuery??!0)&&this._onRequestColorSchemeQuery.fire();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=x.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 r=e.length===0?1:e.params[0];if(r===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(r){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=r%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let r=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>r&&(this._activeBuffer.scrollTop=r-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!qt(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let r=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:r!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`\x1B[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(r===0||r===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Kt&&this._windowTitleStack.shift()),(r===0||r===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Kt&&this._iconNameStack.shift());break;case 23:(r===0||r===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(r===0||r===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,this._activeBuffer.savedCharsets=this._charsetService.charsets.slice(),this._activeBuffer.savedGlevel=this._charsetService.glevel,this._activeBuffer.savedOriginMode=this._coreService.decPrivateModes.origin,this._activeBuffer.savedWraparoundMode=this._coreService.decPrivateModes.wraparound,!0}restoreCursor(e){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;for(let r=0;r<this._activeBuffer.savedCharsets.length;r++)this._charsetService.setgCharset(r,this._activeBuffer.savedCharsets[r]);return this._charsetService.setgLevel(this._activeBuffer.savedGlevel),this._coreService.decPrivateModes.origin=this._activeBuffer.savedOriginMode,this._coreService.decPrivateModes.wraparound=this._activeBuffer.savedWraparoundMode,this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let r=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),o=i.shift();if(/^\d+$/.exec(s)){let l=parseInt(s);if(Xt(l))if(o==="?")r.push({type:0,index:l});else{let c=ft(o);c&&r.push({type:1,index:l,color:c})}}}return r.length&&this._onColor.fire(r),!0}setHyperlink(e){let r=e.indexOf(";");if(r===-1)return!0;let i=e.slice(0,r).trim(),s=e.slice(r+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,r){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,o=i.findIndex(l=>l.startsWith("id="));return o!==-1&&(s=i[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:r}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,r){let i=e.split(";");for(let s=0;s<i.length&&!(r>=this._specialColors.length);++s,++r)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[r]}]);else{let o=ft(i[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[r],color:o}])}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 r=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let o=parseInt(i[s]);Xt(o)&&r.push({type:2,index:o})}return r.length&&this._onColor.fire(r),!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,W),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(fr[e[0]],C[e[1]]??W),!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=x.clone(),this._eraseAttrDataInternal=x.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 D;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let r=0;r<this._bufferService.rows;++r){let i=this._activeBuffer.ybase+this._activeBuffer.y+r,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,r){let i=c=>(this._coreService.triggerDataEvent(`\x1B${c}\x1B\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions,l={block:2,underline:4,bar:6};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${l[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,r){this._dirtyRowTracker.markRangeDirty(e,r)}kittyKeyboardSet(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return!0;let r=e.params[0]||0,i=e.length>1&&e.params[1]||1,s=this._coreService.kittyKeyboard;switch(i){case 1:s.flags=r;break;case 2:s.flags|=r;break;case 3:s.flags&=~r;break}return!0}kittyKeyboardQuery(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return!0;let r=this._coreService.kittyKeyboard.flags;return this._coreService.triggerDataEvent(`\x1B[?${r}u`),!0}kittyKeyboardPush(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return!0;let r=e.params[0]||0,i=this._coreService.kittyKeyboard,o=this._bufferService.buffer===this._bufferService.buffers.alt?i.altStack:i.mainStack;return o.length>=16&&o.shift(),o.push(i.flags),i.flags=r,!0}kittyKeyboardPop(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return!0;let r=Math.max(1,e.params[0]||1),i=this._coreService.kittyKeyboard,o=this._bufferService.buffer===this._bufferService.buffers.alt?i.altStack:i.mainStack;for(let l=0;l<r&&o.length>0;l++)i.flags=o.pop();return o.length===0&&r>0&&(i.flags=0),!0}},be=class{constructor(t){this._bufferService=t;this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(Vt=t,t=e,e=Vt),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};be=H([R(0,q)],be);function Xt(n){return 0<=n&&n<256}var pr=5e7,Yt=12,_r=50,qe=class extends g{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}flushSync(){if(this._isSyncWriting)return;this._isSyncWriting=!0;let e;for(;e=this._writeBuffer.shift();){this._action(e);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._writeBuffer.length=0,this._callbacks.length=0,this._isSyncWriting=!1}writeSync(e,r){if(r!==void 0&&this._syncCalls>r){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,r){if(this._pendingData>pr)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(r),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(r)}_innerWrite(e=0,r=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,r);if(o){let c=u=>performance.now()-i>=Yt?setTimeout(()=>this._innerWrite(0,u)):this._innerWrite(i,u);o.catch(u=>(queueMicrotask(()=>{throw u}),Promise.resolve(!1))).then(c);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Yt)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>_r&&(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()}};var se=class{constructor(t){this._bufferService=t;this._nextId=1;this._entriesWithId=new Map;this._dataByLinkId=new Map}registerLink(t){let e=this._bufferService.buffer;if(t.id===void 0){let c=e.addMarker(e.ybase+e.y),u={data:t,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._dataByLinkId.set(u.id,u),u.id}let r=t,i=this._getEntryIdKey(r),s=this._entriesWithId.get(i);if(s)return this.addLineToLink(s.id,e.ybase+e.y),s.id;let o=e.addMarker(e.ybase+e.y),l={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(l,o)),this._entriesWithId.set(l.key,l),this._dataByLinkId.set(l.id,l),l.id}addLineToLink(t,e){let r=this._dataByLinkId.get(t);if(r&&r.lines.every(i=>i.line!==e)){let i=this._bufferService.buffer.addMarker(e);r.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(r,i))}}getLinkData(t){return this._dataByLinkId.get(t)?.data}_getEntryIdKey(t){return`${t.id};;${t.uri}`}_removeMarkerFromLink(t,e){let r=t.lines.indexOf(e);r!==-1&&(t.lines.splice(r,1),t.lines.length===0&&(t.data.id!==void 0&&this._entriesWithId.delete(t.key),this._dataByLinkId.delete(t.id)))}};se=H([R(0,q)],se);var jt=!1,$e=class extends g{constructor(e){super();this._windowsWrappingHeuristics=this._register(new Ie);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._onRender=this._register(new b);this.onRender=this._onRender.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 ye,this.optionsService=this._register(new Re(e)),this._instantiationService.setService($,this.optionsService),this._logService=this._register(this._instantiationService.createInstance(z)),this._instantiationService.setService(j,this._logService),this._bufferService=this._register(this._instantiationService.createInstance(Q)),this._instantiationService.setService(q,this._bufferService),this.coreService=this._register(this._instantiationService.createInstance(te)),this._instantiationService.setService(xt,this.coreService),this.mouseStateService=this._register(this._instantiationService.createInstance(Oe)),this._instantiationService.setService(St,this.mouseStateService),this.unicodeService=this._register(this._instantiationService.createInstance(O)),this._instantiationService.setService(Tt,this.unicodeService),this._charsetService=this._instantiationService.createInstance(we),this._instantiationService.setService(Ct,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(se),this._instantiationService.setService(yt,this._oscLinkService),this._inputHandler=this._register(new Ke(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.mouseStateService,this.unicodeService)),this._register(A.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(A.forward(this._bufferService.onResize,this._onResize)),this._register(A.forward(this.coreService.onData,this._onData)),this._register(A.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(["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 qe((r,i)=>this._inputHandler.parse(r,i))),this._register(A.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new b),this._onScroll.event(e=>{this._onScrollApi?.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 r in e)this.optionsService.options[r]=e[r]}write(e,r){this._writeBuffer.write(e,r)}writeSync(e,r){this._logService.logLevel<=3&&!jt&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jt=!0),this._writeBuffer.writeSync(e,r)}input(e,r=!0){this.coreService.triggerDataEvent(e,r)}resize(e,r){isNaN(e)||isNaN(r)||(e=Math.max(e,at),r=Math.max(r,ot),this._writeBuffer.flushSync(),this._bufferService.resize(e,r))}scroll(e,r=!1){this._bufferService.scroll(e,r)}scrollLines(e,r){this._bufferService.scrollLines(e,r)}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 r=e-this._bufferService.buffer.ydisp;r!==0&&this.scrollLines(r)}registerEscHandler(e,r){return this._inputHandler.registerEscHandler(e,r)}registerDcsHandler(e,r){return this._inputHandler.registerDcsHandler(e,r)}registerCsiHandler(e,r){return this._inputHandler.registerCsiHandler(e,r)}registerOscHandler(e,r){return this._inputHandler.registerOscHandler(e,r)}registerApcHandler(e,r){return this._inputHandler.registerApcHandler(e,r)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.mouseStateService.reset()}_handleWindowsPtyOptionChange(){let e=!1,r=this.optionsService.rawOptions.windowsPty;r&&r.buildNumber!==void 0&&r.buildNumber!==void 0&&(e=r.backend==="conpty"&&r.buildNumber<21376),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(ht.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ht(this._bufferService),!1))),this._windowsWrappingHeuristics.value=F(()=>{for(let r of e)r.dispose()})}}};var Ve=class extends $e{constructor(e={}){super(e);this._onBell=this._register(new b);this.onBell=this._onBell.event;this._onCursorMove=this._register(new b);this.onCursorMove=this._onCursorMove.event;this._onTitleChange=this._register(new b);this.onTitleChange=this._onTitleChange.event;this._onA11yCharEmitter=this._register(new b);this.onA11yChar=this._onA11yCharEmitter.event;this._onA11yTabEmitter=this._register(new b);this.onA11yTab=this._onA11yTabEmitter.event;this._setup(),this._register(this._inputHandler.onRequestBell(()=>this.bell())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(A.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(A.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(A.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(A.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(A.forward(A.map(this._inputHandler.onRequestRefreshRows,r=>({start:r?.start??0,end:r?.end??this.rows-1})),this._onRender))}get buffer(){return this.buffers.active}get markers(){return this.buffer.markers}addMarker(e){if(this.buffer===this.buffers.normal)return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}bell(){this._onBell.fire()}input(e,r=!0){this.coreService.triggerDataEvent(e,r)}resize(e,r){e===this.cols&&r===this.rows||super.resize(e,r)}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){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(x));this._onScroll.fire({position:this.buffer.ydisp})}}reset(){this.options.rows=this.rows,this.options.cols=this.cols,this._setup(),super.reset()}};var Xe=class{constructor(){this._addons=[]}dispose(){for(let t=this._addons.length-1;t>=0;t--)this._addons[t].instance.dispose()}loadAddon(t,e){let r={instance:e,dispose:e.dispose,isDisposed:!1};this._addons.push(r),e.dispose=()=>this._wrappedAddonDispose(r),e.activate(t)}_wrappedAddonDispose(t){if(t.isDisposed)return;let e=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===t){e=r;break}if(e===-1)throw new Error("Could not dispose an addon that has not been loaded");t.isDisposed=!0,t.dispose.apply(t.instance),this._addons.splice(e,1)}};var br=["cols","rows"],zt=class extends g{constructor(t){super(),this._core=this._register(new Ve(t)),this._addonManager=this._register(new Xe),this._publicOptions={...this._core.options};let e=i=>this._core.options[i],r=(i,s)=>{this._checkReadonlyOptions(i),this._core.options[i]=s};for(let i in this._core.options){Object.defineProperty(this._publicOptions,i,{get:()=>this._core.options[i],set:o=>{this._checkReadonlyOptions(i),this._core.options[i]=o}});let s={get:e.bind(this,i),set:r.bind(this,i)};Object.defineProperty(this._publicOptions,i,s)}}_checkReadonlyOptions(t){if(br.includes(t))throw new Error(`Option "${t}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.options.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 onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get parser(){return this._parser??=new xe(this._core),this._parser}get unicode(){return this._checkProposedApi(),new Ce(this._core)}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer??=this._register(new Se(this._core)),this._buffer}get markers(){return this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.mouseStateService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,showCursor:!this._core.coreService.isCursorHidden,synchronizedOutputMode:t.synchronizedOutput,win32InputMode:t.win32InputMode,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}registerMarker(t=0){return this._verifyIntegers(t),this._core.addMarker(t)}addMarker(t){return this.registerMarker(t)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
|
|
19
|
+
`,e)}reset(){this._core.reset()}loadAddon(t){this._addonManager.loadAddon(this,t)}_verifyIntegers(...t){for(let e of t)if(e===1/0||isNaN(e)||e%1!==0)throw new Error("This API only accepts integers")}};export{zt as Terminal};
|
|
20
20
|
//# sourceMappingURL=xterm-headless.mjs.map
|