UNPKG

homebridge-config-ui-x

Version:

A web based management, configuration and control platform for Homebridge.

10 lines • 351 kB
import {a4 as w}from'./main-ONDCASUV.js';function Vs(e){return e?.ownerDocument?.defaultView?e.ownerDocument.defaultView:window}function Mi(e){return Vs(e).getComputedStyle(e,null)}var bn=class{activate(e){this._terminal=e;}dispose(){}fit(){let e=this.proposeDimensions();!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows)||this._terminal.resize(e.cols,e.rows);}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal.dimensions;if(!e||e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollbar?.showScrollbar??true,i=this._terminal.options.scrollback===0||!t?0:this._terminal.options.scrollbar?.width??14,s=Mi(this._terminal.element.parentElement),r=Math.max(0,parseInt(s.getPropertyValue("height"),10)||0),o=Math.max(0,parseInt(s.getPropertyValue("width"),10)||0),n=Mi(this._terminal.element),h={top:parseInt(n.getPropertyValue("padding-top"),10)||0,bottom:parseInt(n.getPropertyValue("padding-bottom"),10)||0,right:parseInt(n.getPropertyValue("padding-right"),10)||0,left:parseInt(n.getPropertyValue("padding-left"),10)||0},l=h.top+h.bottom,a=h.right+h.left,c=r-l,d=o-a-i;return {cols:Math.max(2,Math.floor(d/e.css.cell.width)),rows:Math.max(1,Math.floor(c/e.css.cell.height))}}};var Ys=class{constructor(e,t,i,s={}){this._terminal=e,this._regex=t,this._handler=i,this._options=s;}provideLinks(e,t){let i=js.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(i));}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(i,s)=>{if(this._options.hover){let{range:r}=t;this._options.hover(i,s,r);}},t))}};function Xs(e){try{let t=new URL(e),i=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(i.toLocaleLowerCase())}catch(t){return  false}}var js=class rt{static computeLink(t,i,s,r){let o=i.flags.includes("g")?i.flags:`${i.flags}g`,n=new RegExp(i.source,o),[h,l]=rt._getWindowedLineStrings(t-1,s),a=h.join(""),c,d=[];for(;c=n.exec(a);){let u=c[0];if(!Xs(u))continue;let[f,_]=rt._mapStrIdx(s,l,0,c.index),[g,v]=rt._mapStrIdx(s,f,_,u.length);if(f===-1||_===-1||g===-1||v===-1)continue;let S={start:{x:_+1,y:f+1},end:{x:v,y:g+1}};d.push({range:S,text:u,activate:r});}return d}static _getWindowedLineStrings(t,i){let s,r=t,o=t,n,h,l=[];if(s=i.buffer.active.getLine(t)){let a=s.translateToString(true);if(s.isWrapped&&a[0]!==" "){for(n=0;(s=i.buffer.active.getLine(--r))&&n<2048&&(h=s.translateToString(true),n+=h.length,l.push(h),!(!s.isWrapped||h.indexOf(" ")!==-1)););l.reverse();}for(l.push(a),n=0;(s=i.buffer.active.getLine(++o))&&s.isWrapped&&n<2048&&(h=s.translateToString(true),n+=h.length,l.push(h),h.indexOf(" ")===-1););}return [l,r]}static _mapStrIdx(t,i,s,r){let o=t.buffer.active,n=o.getNullCell(),h=s;for(;r;){let l=o.getLine(i);if(!l)return [-1,-1];for(let a=h;a<l.length;++a){l.getCell(a,n);let c=n.getChars();if(n.getWidth()&&(r-=c.length||1,a===l.length-1&&c==="")){let d=o.getLine(i+1);d&&d.isWrapped&&(d.getCell(0,n),n.getWidth()===2&&(r+=1));}if(r<0)return [i,a]}i++,h=0;}return [i,h]}},Gs=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Js(e,t){let i=window.open();if(i){try{i.opener=null;}catch(s){}i.location.href=t;}else console.warn("Opening link blocked as opener could not be cleared");}var kn=class{constructor(e=Js,t={}){this._handler=e,this._options=t;}activate(e){this._terminal=e;let t=this._options,i=t.urlRegex??Gs;this._linkProvider=this._terminal.registerLinkProvider(new Ys(this._terminal,i,this._handler,t));}dispose(){this._linkProvider?.dispose();}};var _s=Object.defineProperty,Zs=Object.getOwnPropertyDescriptor,Qs=(e,t)=>{for(var i in t)_s(e,i,{get:t[i],enumerable:true});},M=(e,t,i,s)=>{for(var r=s>1?void 0:s?Zs(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&_s(t,i,r),r},p=(e,t)=>(i,s)=>t(i,s,e),Ri="Terminal input",Wt={get:()=>Ri,set:e=>Ri=e},Li="Too much output to announce, navigate to rows manually to read",dt={get:()=>Li,set:e=>Li=e};function er(e){return e.replace(/\r?\n/g,"\r")}function tr(e,t){return t?`\x1B[200~${e.replace(/\x1b/g,"\u241B")}\x1B[201~`:e}function ir(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault();}function sr(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");us(r,t,i,s);}}function us(e,t,i,s){e=er(e),e=tr(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==true),i.triggerDataEvent(e,true),t.value="";}function fs(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus();}function Pi(e,t,i,s,r){fs(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select();}function me(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function De(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let o=e[r];o>65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o);}return s}var rr=class{constructor(){this._interim=0;}clear(){this._interim=0;}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let o=e.charCodeAt(r++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0;}for(let o=r;o<i;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=i)return this._interim=n,s;let h=e.charCodeAt(o);56320<=h&&h<=57343?t[s++]=(n-55296)*1024+h-56320+65536:(t[s++]=n,t[s++]=h);continue}n!==65279&&(t[s++]=n);}return s}},or=class{constructor(){this.interim=new Uint8Array(3);}clear(){this.interim.fill(0);}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,o,n,h,l,a=0;if(this.interim[0]){let u=false,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let _=0,g;for(;(g=this.interim[++_])&&_<4;)f<<=6,f|=g&63;let v=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,S=v-_;for(;a<S;){if(a>=i)return 0;if(g=e[a++],(g&192)!==128){a--,u=true;break}else this.interim[_++]=g,f<<=6,f|=g&63;}u||(v===2?f<128?a--:t[s++]=f:v===3?f<2048||f>=55296&&f<=57343||f===65279||(t[s++]=f):f<65536||f>1114111||(t[s++]=f)),this.interim.fill(0);}let c=i-4,d=a;for(;d<i;){for(;d<c&&!((r=e[d])&128)&&!((o=e[d+1])&128)&&!((n=e[d+2])&128)&&!((h=e[d+3])&128);)t[s++]=r,t[s++]=o,t[s++]=n,t[s++]=h,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((r&224)===192){if(d>=i)return this.interim[0]=r,s;if(o=e[d++],(o&192)!==128){d--;continue}if(l=(r&31)<<6|o&63,l<128){d--;continue}t[s++]=l;}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=o,s;if(n=e[d++],(n&192)!==128){d--;continue}if(l=(r&15)<<12|(o&63)<<6|n&63,l<2048||l>=55296&&l<=57343||l===65279)continue;t[s++]=l;}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=o,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=n,s;if(h=e[d++],(h&192)!==128){d--;continue}if(l=(r&7)<<18|(o&63)<<12|(n&63)<<6|h&63,l<65536||l>1114111)continue;t[s++]=l;}}return s}},Ze=class gs{constructor(){this.fg=0,this.bg=0,this.extended=new _t;}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 gs;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}},_t=class ps{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i;}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t;}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048;}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863;}get urlId(){return this._urlId}set urlId(t){this._urlId=t;}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384;}clone(){return new ps(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},oe=class vs extends Ze{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _t,this.combinedData="";}static fromCharData(t){let i=new vs;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?me(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=false;if(t[1].length>2)i=true;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=true;}else i=true;}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22);}getAsCharData(){return [this.fg,this.getChars(),this.getWidth(),this.getCode()]}attributesEquals(t){if(this.getFgColorMode()!==t.getFgColorMode()||this.getFgColor()!==t.getFgColor()||this.getBgColorMode()!==t.getBgColorMode()||this.getBgColor()!==t.getBgColor()||this.isInverse()!==t.isInverse()||this.isBold()!==t.isBold()||this.isUnderline()!==t.isUnderline())return  false;if(this.isUnderline()){if(this.getUnderlineStyle()!==t.getUnderlineStyle())return  false;let i=this.isUnderlineColorDefault(),s=t.isUnderlineColorDefault();if(!(i&&s)&&(i!==s||this.getUnderlineColor()!==t.getUnderlineColor()||this.getUnderlineColorMode()!==t.getUnderlineColorMode()))return  false}return !(this.isOverline()!==t.isOverline()||this.isBlink()!==t.isBlink()||this.isInvisible()!==t.isInvisible()||this.isItalic()!==t.isItalic()||this.isDim()!==t.isDim()||this.isStrikethrough()!==t.isStrikethrough())}},Lt=new Map;function nr(e){return e.di$dependencies||[]}function I(e){if(Lt.has(e))return Lt.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");ar(t,i,r);};return t._id=e,Lt.set(e,t),t}function ar(e,t,i){t.di$target===t?t.di$dependencies.push({id:e,index:i}):(t.di$dependencies=[{id:e,index:i}],t.di$target=t);}var V=I("BufferService"),mt=I("MouseStateService"),ue=I("CoreService"),hr=I("CharsetService"),ui=I("InstantiationService"),Me=I("LogService"),Y=I("OptionsService"),ms=I("OscLinkService"),lr=I("UnicodeService"),Qe=I("DecorationService"),zt=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i,this._workCell=new oe;}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,o=this._workCell,n=i.getTrimmedLength(),h=-1,l=-1,a=false;for(let c=0;c<n;c++)if(!(l===-1&&!i.hasContent(c))){if(i.loadCell(c,o),o.hasExtendedAttrs()&&o.extended.urlId)if(l===-1){l=c,h=o.extended.urlId;continue}else a=o.extended.urlId!==h;else l!==-1&&(a=true);if(a||l!==-1&&c===n-1){let d=this._oscLinkService.getLinkData(h)?.uri;if(d){let u=c+(!a&&c===n-1?1:0),f=this._getRangeWithLineWrap(e,l,u,h),_=false;if(!r?.allowNonHttpProtocols)try{let g=new URL(d);["http:","https:"].includes(g.protocol)||(_=!0);}catch(g){_=true;}_||s.push({text:d,range:f,activate:(g,v)=>r?r.activate(g,v,f):cr(g,v),hover:(g,v)=>r?.hover?.(g,v,f),leave:(g,v)=>r?.leave?.(g,v,f)});}a=false,o.hasExtendedAttrs()&&o.extended.urlId?(l=c,h=o.extended.urlId):(l=-1,h=-1);}}t(s);}_getRangeWithLineWrap(e,t,i,s){let r=e,o=t,n=e,h=i;for(;o===0&&this._bufferService.buffer.lines.get(r-1)?.isWrapped;){let l=this._bufferService.buffer.lines.get(r-2);if(!l)break;let a=l.getTrimmedLength();if(a===0||!this._hasUrlId(l,a-1,s))break;let c=a-1;for(;c>0&&this._hasUrlId(l,c-1,s);)c--;r--,o=c;}for(;;){let l=this._bufferService.buffer.lines.get(n-1);if(!l)break;let a=l.getTrimmedLength();if(h!==a)break;let c=this._bufferService.buffer.lines.get(n);if(!c?.isWrapped)break;let d=c.getTrimmedLength();if(d===0||!this._hasUrlId(c,0,s))break;let u=1;for(;u<d&&this._hasUrlId(c,u,s);)u++;n++,h=u;}return {start:{x:o+1,y:r},end:{x:h,y:n}}}_hasUrlId(e,t,i){let s=this._workCell;return e.loadCell(t,s),!!s.hasExtendedAttrs()&&s.extended.urlId===i}};zt=M([p(0,V),p(1,Y),p(2,ms)],zt);function cr(e,t){if(confirm(`Do you want to navigate to ${t}?

WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null;}catch(s){}i.location.href=t;}else console.warn("Opening link blocked as opener could not be cleared");}}var St=I("CharSizeService"),ce=I("CoreBrowserService"),wt=I("MouseCoordsService"),dr=I("MouseService"),de=I("RenderService"),Ss=I("SelectionService"),ws=I("CharacterJoinerService"),Re=I("ThemeService"),bs=I("LinkProviderService"),_r=I("KeyboardService");function k(e){return {dispose:e}}function Xe(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return []}return e.dispose(),e}var Le=class{constructor(){this._disposables=new Set,this._isDisposed=false;}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=true;for(let e of this._disposables)e.dispose();this._disposables.clear();}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear();}},C=class{constructor(){this._store=new Le;}dispose(){this._store.dispose();}_register(e){return this._store.add(e)}};C.None=Object.freeze({dispose(){}});var Z=class{constructor(){this._isDisposed=false;}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e);}clear(){this.value=void 0;}dispose(){this._isDisposed=true,this._value?.dispose(),this._value=void 0;}};function ur(e,t=0,i){let s=setTimeout(()=>{e();},t),r=k(()=>{clearTimeout(s);});return r}var bt=class{constructor(){this._token=-1,this._isDisposed=false;}dispose(){this.cancel(),this._isDisposed=true;}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1);}cancelAndSet(e,t){if(this._isDisposed)throw new Error("Calling cancelAndSet on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e();},t);}setIfNotSet(e,t){if(this._isDisposed)throw new Error("Calling setIfNotSet on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e();},t));}},fr=class{constructor(){this._isScheduled=false,this._isDisposed=false;}dispose(){this.cancel(),this._isDisposed=true;}cancel(){this._isScheduled=false;}set(e){if(this._isDisposed)throw new Error("Calling set on a disposed MicrotaskTimer");this._isScheduled||(this._isScheduled=true,queueMicrotask(()=>{this._isScheduled&&(this._isScheduled=false,e());}));}},gr=class{constructor(){this._isDisposed=false;}cancel(){this._disposable?.dispose(),this._disposable=void 0;}cancelAndSet(e,t,i=globalThis){if(this._isDisposed)throw new Error("Calling cancelAndSet on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e();},t);this._disposable={dispose:()=>{i.clearInterval(s),this._disposable=void 0;}};}dispose(){this.cancel(),this._isDisposed=true;}};function re(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView;let i=e;return i?.view?i.view:window}var pr=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s,e.addEventListener(t,i,s);}dispose(){!this._node||!this._handler||(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null);}};function b(e,t,i,s){return new pr(e,t,i,s)}function Ti(e,t,i,s){return b(e,t,i,s)}var le={CLICK:"click",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",POINTER_UP:"pointerup",MOUSE_WHEEL:"wheel"};function vr(e){let t=e.getBoundingClientRect(),i=re(e);return {left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var ys=class{constructor(e,t){this._runner=e,this.priority=t,this._canceled=false;}dispose(){this._canceled=true;}execute(){if(!this._canceled)try{this._runner();}catch(e){console.error(e);}}static sort(e,t){return t.priority-e.priority}},Ai=new Map;function Cs(e){let t=Ai.get(e);return t||(t={next:[],current:[],animFrameRequested:false,inAnimationFrameRunner:false},Ai.set(e,t)),t}function mr(e){let t=Cs(e);for(t.animFrameRequested=false,t.current=t.next,t.next=[],t.inAnimationFrameRunner=true;t.current.length>0;)t.current.sort(ys.sort),t.current.shift().execute();t.inAnimationFrameRunner=false;}function fi(e,t,i=0){let s=Cs(e),r=new ys(t,i);return s.next.push(r),s.animFrameRequested||(s.animFrameRequested=true,e.requestAnimationFrame(()=>mr(e))),r}var Sr=class extends gr{constructor(e){super(),this._defaultTarget=e?re(e):void 0;}cancelAndSet(e,t,i){super.cancelAndSet(e,t,i??this._defaultTarget??window);}},Ye=class{constructor(e){this.domNode=e,this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._className="",this._position="",this._layerHint=false,this._contain="none";}setWidth(e){let t=xe(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width);}setHeight(e){let t=xe(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height);}setTop(e){let t=xe(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top);}setLeft(e){let t=xe(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left);}setBottom(e){let t=xe(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom);}setRight(e){let t=xe(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right);}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className);}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className;}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position);}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,e?this.domNode.style.transform="translate3d(0px, 0px, 0px)":this.domNode.style.transform="");}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain);}setAttribute(e,t){this.domNode.setAttribute(e,t);}};function xe(e){return typeof e=="number"?`${e}px`:e}var ks={};Qs(ks,{getSafariVersion:()=>br,getZoomFactor:()=>xs,isChrome:()=>vi,isChromeOS:()=>Bs,isFirefox:()=>ut,isLegacyEdge:()=>wr,isLinux:()=>Si,isMac:()=>se,isNode:()=>gi,isSafari:()=>mi,isWindows:()=>yt});var gi=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),Pe=gi?"node":navigator.userAgent,pi=gi?"node":navigator.platform,ut=Pe.includes("Firefox"),vi=Pe.includes("Chrome"),wr=Pe.includes("Edge"),mi=/^((?!chrome|android).)*safari/i.test(Pe);function xs(e){return 1}function br(){if(!mi)return 0;let e=Pe.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1],10)}var se=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(pi),yt=["Windows","Win16","Win32","WinCE"].includes(pi),Si=pi.indexOf("Linux")>=0,Bs=/\bCrOS\b/.test(Pe),Ii=new WeakMap;function yr(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch(t){return null}return e.parent}var Cr=class{static _getSameOriginWindowChain(e){let t=Ii.get(e);if(!t){t=[],Ii.set(e,t);let i=e,s;do s=yr(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement??null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return {top:0,left:0};let i=0,s=0,r=this._getSameOriginWindowChain(e);for(let o of r){let n=o.window.deref();if(i+=n?.scrollY??0,s+=n?.scrollX??0,n===t||!o.iframeElement)break;let h=o.iframeElement.getBoundingClientRect();i+=h.top,s+=h.left;}return {top:i,left:s}}},Pt=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail??1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=Cr.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top;}preventDefault(){this.browserEvent.preventDefault();}stopPropagation(){this.browserEvent.stopPropagation();}},Oi=class{constructor(e,t=0,i=0){this.browserEvent=e??null,this.target=e?e.target??e.targetNode??e.srcElement??null:null,this.deltaY=i,this.deltaX=t;let s=false;if(vi){let r=navigator.userAgent.match(/Chrome\/(\d+)/);s=(r?parseInt(r[1],10):123)<=122;}if(e){let r=e,o=e,n=e.view?.devicePixelRatio??1;if(typeof r.wheelDeltaY<"u")s?this.deltaY=r.wheelDeltaY/(120*n):this.deltaY=r.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?ut&&!se?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40;}if(typeof r.wheelDeltaX<"u")mi&&yt?this.deltaX=-(r.wheelDeltaX/120):s?this.deltaX=r.wheelDeltaX/(120*n):this.deltaX=r.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?ut&&!se?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40;}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*n):this.deltaY=e.wheelDelta/120);}}preventDefault(){this.browserEvent?.preventDefault();}stopPropagation(){this.browserEvent?.stopPropagation();}},Es=class{constructor(){this._hooks=new Le,this._pointerMoveCallback=null,this._onStopCallback=null;}dispose(){this.stopMonitoring(false),this._hooks.dispose();}stopMonitoring(e){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let t=this._onStopCallback;this._onStopCallback=null,e&&t&&t();}isMonitoring(){return !!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(false),this._pointerMoveCallback=s,this._onStopCallback=r;let o=e;try{e.setPointerCapture(t),this._hooks.add(k(()=>{try{e.releasePointerCapture(t);}catch(n){}}));}catch(n){o=re(e);}this._hooks.add(b(o,le.POINTER_MOVE,n=>{if(n.buttons!==i){this.stopMonitoring(true);return}n.preventDefault(),this._pointerMoveCallback(n);})),this._hooks.add(b(o,le.POINTER_UP,n=>this.stopMonitoring(true)));}},wi=class extends C{_onclick(e,t){this._register(b(e,le.CLICK,i=>t(new Pt(re(e),i))));}_onmouseover(e,t){this._register(b(e,le.MOUSE_OVER,i=>t(new Pt(re(e),i))));}_onmouseleave(e,t){this._register(b(e,le.MOUSE_LEAVE,i=>t(new Pt(re(e),i))));}},kr=class extends wi{constructor(e){super(),this._handleActivate=e.handleActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="xterm-arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute";let t=Math.min(e.bgWidth,e.bgHeight);this.domNode.style.width=t+"px",this.domNode.style.height=t+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Es),this._register(Ti(this.bgDomNode,le.POINTER_DOWN,i=>this._arrowPointerDown(i))),this._register(Ti(this.domNode,le.POINTER_DOWN,i=>this._arrowPointerDown(i))),this._pointerdownRepeatTimer=this._register(new Sr),this._pointerdownScheduleRepeatTimer=this._register(new bt);}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._handleActivate(),1e3/24,re(e));};this._handleActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel();}),e.preventDefault();}},m=class{constructor(){this._listeners=[],this._disposed=false;}get event(){return this._event?this._event:(this._event=(e,t,i)=>{if(this._disposed)return k(()=>{});let s={fn:e,thisArgs:t};this._listeners.push(s);let r=k(()=>{let o=this._listeners.indexOf(s);o!==-1&&this._listeners.splice(o,1);});return i&&(Array.isArray(i)?i.push(r):i.add(r)),r},this._event)}fire(e){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:t,thisArgs:i}=this._listeners[0];t.call(i,e);return}default:{let t=this._listeners.slice();for(let{fn:i,thisArgs:s}of t)i.call(s,e);}}}dispose(){this._disposed||(this._disposed=true,this._listeners.length=0);}},J;(e=>{function t(o,n){return o(h=>n.fire(h))}e.forward=t;function i(o,n){return (h,l,a)=>o(c=>h.call(l,n(c)),void 0,a)}e.map=i;function s(...o){return (n,h,l)=>{let a=new Le;for(let c of o)a.add(c(d=>n.call(h,d)));return l&&(Array.isArray(l)?l.push(a):l.add(a)),a}}e.any=s;function r(o,n,h){return n(h),o(l=>n(l))}e.runAndSubscribe=r;})(J||={});var xr=class Kt{constructor(t,i,s,r,o,n,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,o=o|0,n=n|0,h=h|0),this.rawScrollLeft=r,this.rawScrollTop=h,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),o<0&&(o=0),h+o>n&&(h=n-o),h<0&&(h=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=o,this.scrollHeight=n,this.scrollTop=h;}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Kt(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Kt(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,n=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,l=this.scrollTop!==t.scrollTop;return {inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:n,scrollHeightChanged:h,scrollTopChanged:l}}},Ds=class extends C{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new m),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new xr(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null;}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose();}setSmoothScrollDuration(e){this._smoothScrollDuration=e;}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state);}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,false);}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0){this.setScrollPositionNow(e);return}if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new At(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=At.start(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s;}else {let i=this._state.withScrollPosition(e);this._smoothScrolling=At.start(this._state,i,this._smoothScrollDuration);}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling());});}hasPendingScrollAnimation(){return !!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,true),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling());});}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)));}},Hi=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i;}};function Tt(e,t){let i=t-e;return function(s){return e+i*Dr(s)}}function Br(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var At=class Ms{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations();}_initAnimations(){this._scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this._scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height);}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let r,o;return t<i?(r=t+.75*s,o=i-.75*s):(r=t-.75*s,o=i+.75*s),Br(Tt(t,r),Tt(o,i),.33)}return Tt(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null);}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations();}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this._scrollLeft(i),r=this._scrollTop(i);return new Hi(s,r,false)}return new Hi(this.to.scrollLeft,this.to.scrollTop,true)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new Ms(t,i,r,s)}};function Er(e){return Math.pow(e,3)}function Dr(e){return 1-Er(1-e)}var Mr=class extends C{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=false,this._isNeeded=false,this._rawShouldBeVisible=false,this._shouldBeVisible=false,this._revealTimer=this._register(new bt);}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible());}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible();}_applyVisibilitySetting(){return this._visibility===2?false:this._visibility===3?true:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility());}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility());}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(false);}ensureVisibility(){if(!this._isNeeded){this._hide(false);return}this._shouldBeVisible?this._reveal():this._hide(true);}_reveal(){this._isVisible||(this._isVisible=true,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName);},0));}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=false,this._domNode?.setClassName(this._invisibleClassName+(e?" xterm-fade":"")));}},Rr=140,Rs=class extends wi{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Mr(e.visibility,"xterm-visible xterm-scrollbar "+e.extraScrollbarClassName,"xterm-invisible xterm-scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Es),this._shouldRender=true,this.domNode=new Ye(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(b(this.domNode.domNode,le.POINTER_DOWN,t=>this._domNodePointerDown(t)));}_createArrow(e){let t=this._register(new kr(e));return this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode),t}_createSlider(e,t,i,s){this.slider=new Ye(document.createElement("div")),this.slider.setClassName("xterm-slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(true),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(b(this.slider.domNode,le.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r));})),this._onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation();});}_handleElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=true,this._lazyRender||this.render()),this._shouldRender}_handleElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=true,this._lazyRender||this.render()),this._shouldRender}_handleElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=true,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(true);}beginHide(){this._visibilityController.setShouldBeVisible(false);}render(){this._shouldRender&&(this._shouldRender=false,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()));}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._handlePointerDown(e);}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._handlePointerDown(e);}_handlePointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else {let r=vr(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top;}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e));}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("xterm-active",true),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),n=Math.abs(o-i);if(yt&&n>Rr){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h));},()=>{this.slider.toggleClassName("xterm-active",false),this._host.handleDragEnd();}),this._host.handleDragStart();}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t);}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=true,this._lazyRender||this.render();}isNeeded(){return this._scrollbarState.isNeeded()}},Ls=class $t{constructor(t,i,s,r,o,n){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=n,this._computedAvailableSize=0,this._computedIsNeeded=false,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues();}clone(){return new $t(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),true):false}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),true):false}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),true):false}setScrollbarSize(t){this._scrollbarSize=Math.round(t);}setArrowSize(t){let i=Math.round(t);this._arrowSize!==i&&(this._arrowSize=i,this._refreshComputedValues());}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t);}static _computeValues(t,i,s,r,o){let n=Math.max(0,s-t),h=Math.max(0,n-2*i),l=r>0&&r>s;if(!l)return {computedAvailableSize:Math.round(n),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let a=Math.round(Math.max(20,Math.floor(s*h/r))),c=(h-a)/(r-s),d=o*c;return {computedAvailableSize:Math.round(n),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:c,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=$t._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition;}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Lr=class extends Rs{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ls(t.horizontalHasArrows?t.horizontalScrollbarSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"xterm-horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize);}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t);}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0);}handleScroll(e){return this._shouldRender=this._handleElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._handleElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._handleElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e);}writeScrollPosition(e,t){e.scrollLeft=t;}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage;}},Pr=class extends Rs{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition(),o=t.verticalHasArrows;super({lazyRender:t.lazyRender,host:i,scrollbarState:new Ls(o?t.verticalScrollbarSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"xterm-vertical",scrollable:e,scrollByPage:t.scrollByPage}),this._arrowScrollDelta=0,this._setArrows(o,t.verticalScrollbarSize),this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0);}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t);}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0);}handleScroll(e){return this._shouldRender=this._handleElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._handleElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._handleElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e);}writeScrollPosition(e,t){e.scrollTop=t;}_arrowScroll(e){let t=this._scrollable.getCurrentScrollPosition();this._scrollable.setScrollPositionNow({scrollTop:t.scrollTop+e});}_setArrows(e,t){if(this._arrowScrollDelta=t,(!this._arrowUp||!this._arrowDown)&&(this._arrowUp=this._createArrow({className:"xterm-scra xterm-arrow-up",top:0,left:0,bgWidth:t,bgHeight:t,handleActivate:()=>this._arrowScroll(-this._arrowScrollDelta)}),this._arrowDown=this._createArrow({className:"xterm-scra xterm-arrow-down",bottom:0,left:0,bgWidth:t,bgHeight:t,handleActivate:()=>this._arrowScroll(this._arrowScrollDelta)})),this._updateArrowSize(this._arrowUp,t),this._updateArrowSize(this._arrowDown,t),!this._arrowUp||!this._arrowDown)return;let i=e?"":"none";this._arrowUp.bgDomNode.style.display=i,this._arrowUp.domNode.style.display=i,this._arrowDown.bgDomNode.style.display=i,this._arrowDown.domNode.style.display=i;}_updateArrowSize(e,t){e&&(e.bgDomNode.style.width=`${t}px`,e.bgDomNode.style.height=`${t}px`,e.domNode.style.width=`${t}px`,e.domNode.style.height=`${t}px`);}updateOptions(e){let t=e.verticalHasArrows?e.verticalScrollbarSize:0;this._scrollbarState.setArrowSize(t),this._setArrows(e.verticalHasArrows,e.verticalScrollbarSize),this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage;}},Tr=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0;}},Ut=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1;}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return  false;let t=1,i=0,s=1,r=this._rear;for(;r!==-1;){let o=r===this._front?t:Math.pow(2,-s);if(t-=o,i+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++;}return i<=.5}acceptStandardWheelEvent(t){if(vi){re(t.browserEvent);let s=xs();this.accept(Date.now(),t.deltaX*s,t.deltaY*s);}else this.accept(Date.now(),t.deltaX,t.deltaY);}accept(t,i,s){let r=null,o=new Tr(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,r);}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),n=Math.abs(i.deltaX),h=Math.abs(i.deltaY),l=Math.max(Math.min(r,n),1),a=Math.max(Math.min(o,h),1),c=Math.max(r,n),d=Math.max(o,h);c%l===0&&d%a===0&&(s-=.5);}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Ut.INSTANCE=new Ut;var Ar=Ut,Ir=class extends wi{constructor(e,t,i){super(),this._onScroll=this._register(new m),this.onScroll=this._onScroll.event,t=t??{};let s,r=!i;i?s=i:(t.mouseWheelSmoothScroll=false,s=new Ds({forceIntegerValues:true,smoothScrollDuration:0,scheduleAtNextAnimationFrame:n=>fi(re(e),n)})),this._options=Or(t),this._scrollable=s,this._register(this._scrollable.onScroll(n=>{this._handleScroll(n),this._onScroll.fire(n);})),r&&this._register(this._scrollable);let o={handleMouseWheel:n=>this._handleMouseWheel(n),handleDragStart:()=>this._handleDragStart(),handleDragEnd:()=>this._handleDragEnd()};this._verticalScrollbar=this._register(new Pr(this._scrollable,this._options,o)),this._horizontalScrollbar=this._register(new Lr(this._scrollable,this._options,o)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=new Ye(document.createElement("div")),this._leftShadowDomNode.setClassName("xterm-shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=new Ye(document.createElement("div")),this._topShadowDomNode.setClassName("xterm-shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=new Ye(document.createElement("div")),this._topLeftShadowDomNode.setClassName("xterm-shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode??this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this._onmouseover(this._listenOnDomNode,n=>this._handleMouseOver(n)),this._onmouseleave(this._listenOnDomNode,n=>this._handleMouseLeave(n)),this._hideTimeout=this._register(new bt),this._isDragging=false,this._mouseIsOver=false,this._shouldRender=true,this._revealOnScroll=true;}get options(){return this._options}dispose(){this._mouseWheelToDispose=Xe(this._mouseWheelToDispose),super.dispose();}getDomNode(){return this._domNode}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,false);}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e);}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}updateClassName(e){this._options.className=e,se&&(this._options.className+=" xterm-mac"),this._domNode.className="xterm-scrollable-element "+this._options.className;}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalHasArrows<"u"&&(this._options.horizontalHasArrows=e.horizontalHasArrows),typeof e.verticalHasArrows<"u"&&(this._options.verticalHasArrows=e.verticalHasArrows),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render();}delegateScrollFromMouseWheelEvent(e){this._handleMouseWheel(new Oi(e));}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Xe(this._mouseWheelToDispose),e)){let t=i=>{this._handleMouseWheel(new Oi(i));};this._mouseWheelToDispose.push(b(this._listenOnDomNode,le.MOUSE_WHEEL,t,{passive:false}));}}_handleMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=Ar.INSTANCE;t.acceptStandardWheelEvent(e);let i=false;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let n=!se&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||n)&&!o&&(o=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(r){let a=50*r,c=h.scrollTop-(a<0?Math.floor(a):Math.ceil(a));this._verticalScrollbar.writeScrollPosition(l,c);}if(o){let a=50*o,c=h.scrollLeft-(a<0?Math.floor(a):Math.ceil(a));this._horizontalScrollbar.writeScrollPosition(l,c);}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),i=true);}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=true),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=true),s&&(e.preventDefault(),e.stopPropagation());}_handleScroll(e){this._shouldRender=this._horizontalScrollbar.handleScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.handleScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=true),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render();}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render();}_render(){if(this._shouldRender&&(this._shouldRender=false,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" xterm-shadow-left":"",r=t?" xterm-shadow-top":"",o=i||t?" xterm-shadow-top-left-corner":"";this._leftShadowDomNode.setClassName(`xterm-shadow${s}`),this._topShadowDomNode.setClassName(`xterm-shadow${r}`),this._topLeftShadowDomNode.setClassName(`xterm-shadow${o}${r}${s}`);}}_handleDragStart(){this._isDragging=true,this._reveal();}_handleDragEnd(){this._isDragging=false,this._hide();}_handleMouseLeave(e){this._mouseIsOver=false,this._hide();}_handleMouseOver(e){this._mouseIsOver=true,this._reveal();}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide();}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide());}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),500);}};function Or(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:false,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:true,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:true,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:false,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:false,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:false,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:false,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:true,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:true,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:false,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:false,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:false};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,se&&(t.className+=" xterm-mac"),t}var qt=class extends C{constructor(e,t,i,s,r,o,n,h,l){super(),this._bufferService=i,this._coreService=r,this._optionsService=h,this._renderService=l,this._onRequestScrollLines=this._register(new m),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=false,this._isHandlingScroll=false,this._suppressOnScrollHandler=false,this._needsSyncOnRender=false;let a=this._register(new Ds({forceIntegerValues:false,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>fi(s.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{a.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration);})),this._scrollableElement=this._register(new Ir(t,w({vertical:1,horizontal:2,useShadows:false,mouseWheelSmoothScroll:true,verticalHasArrows:this._optionsService.rawOptions.scrollbar?.showArrows??false},this._getChangeOptions()),a)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","scrollbar"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)});})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(J.runAndSubscribe(n.onChangeColors,()=>{e.style.backgroundColor=n.colors.background.css,this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css;})),e.appendChild(this._scrollableElement.getDomNode()),this._register(k(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(k(()=>this._styleElement.remove())),this._register(J.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider {",`  background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider:hover {",`  background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .xterm-scrollbar > .xterm-slider.xterm-active {",`  background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
`);})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync();})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._renderService.onRender(()=>{this._needsSyncOnRender&&(this._needsSyncOnRender=false,this._sync());})),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)));}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:true,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height});}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height});}_getChangeOptions(){let e=this._optionsService.rawOptions.scrollbar?.showScrollbar??true,t=this._optionsService.rawOptions.scrollbar?.showArrows??false,i=e?this._optionsService.rawOptions.scrollbar?.width??14:0;return {mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,vertical:e?1:2,verticalScrollbarSize:i,verticalHasArrows:t}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp);}));}_sync(e=this._bufferService.buffer.ydisp){if(!(!this._renderService||this._isSyncing)){if(this._coreService.decPrivateModes.synchronizedOutput){this._needsSyncOnRender=true;return}this._isSyncing=true,this._suppressOnScrollHandler=true,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=false,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=false;}}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=true;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=false;}handleTouchScroll(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({scrollTop:t.scrollTop-e});}};qt=M([p(2,V),p(3,ce),p(4,ue),p(5,mt),p(6,Re),p(7,Y),p(8,de)],qt);var Vt=class extends C{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=false,this._dimensionsChanged=false,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=true,this._queueRefresh();})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt;})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(k(()=>{this._container.remove(),this._decorationElements.clear();}));}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0;}));}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=false;}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e);}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else {let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove();})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i);}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:"";}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose();}};Vt=M([p(1,V),p(2,ce),p(3,Qe),p(4,de)],Vt);var Hr=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0};}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0;}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++;}}setPadding(e){this._linePadding=e;}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t);}},ae={full:0,left:0,center:0,right:0},ve={full:0,left:0,center:0,right:0},Ne={full:0,left:0,center:0,right:0},ft=class extends C{constructor(e,t,i,s,r,o,n,h){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=o,this._themeService=n,this._coreBrowserService=h,this._colorZoneStore=new Hr,this._shouldUpdateDimensions=true,this._shouldUpdateAnchor=true,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(k(()=>this._canvas?.remove()));let l=this._canvas.getContext("2d");if(l)this._ctx=l;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,true))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,true))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block";})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding());})),this._register(this._renderService.onDimensionsChange(()=>this._queueRefresh(true))),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(true))),this._register(this._optionsService.onSpecificOptionChange("scrollbar",()=>this._queueRefresh(true))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._register(k(()=>{this._animationFrame!==void 0&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0);})),this._queueRefresh(true);}get _width(){let e=this._optionsService.rawOptions.scrollbar;return e?.showScrollbar??true?e?.width??0:0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ve.full=this._canvas.width,ve.left=e,ve.center=t,ve.right=e,this._refreshDrawHeightConstants(),Ne.full=1,Ne.left=1,Ne.center=1+ve.left,Ne.right=1+ve.left+ve.center;}_refreshDrawHeightConstants(){ae.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ae.left=t,ae.center=t,ae.right=t;}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ae.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ae.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ae.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ae.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length;}_refreshCanvasDimensions(){if(this._store.isDisposed||!this._renderService.hasRenderer())return;let e=this._renderService.dimensions.css.canvas.height,t=this._renderService.dimensions.device.canvas.height;this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${e}px`,this._canvas.height=t,this._refreshDrawConstants(),this._refreshColorZonePadding();}_refreshDecorations(){if(this._store.isDisposed||!this._renderService.hasRenderer())return;this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=false,this._shouldUpdateAnchor=false;}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.scrollbar?.overviewRuler?.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.scrollbar?.overviewRuler?.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height);}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ne[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ae[e.position||"full"]/2),ve[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ae[e.position||"full"]));}_queueRefresh(e,t){this._store.isDisposed||(this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._store.isDisposed||this._refreshDecorations(),this._animationFrame=void 0;})));}};ft=M([p(2,V),p(3,Qe),p(4,de),p(5,Y),p(6,Re),p(7,ce)],ft);var Yt=class{constructor(e,t,i,s,r,o){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=o,this._isComposing=false,this._isSendingComposition=false,this._compositionPosition={start:0,end:0},this._compositionSuffix="",this._dataAlreadySent="";}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=true;let e=this._textarea.selectionStart??this._textarea.value.length,t=this._textarea.selectionEnd??e;this._compositionPosition.start=Math.min(e,t),this._compositionPosition.end=Math.max(e,t),this._compositionSuffix=this._textarea.value.substring(this._compositionPosition.end),this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active");}compositionupdate(e){this._compositionView.textContent=`\u200E${e.data}\u200E`,this.updateCompositionElements(),setTimeout(()=>{let t=this._textarea.selectionEnd??this._textarea.value.length;this._compositionPosition.end=Math.max(this._compositionPosition.start,t);},0);}compositionend(){this._finalizeComposition(true);}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return  false;this._finalizeComposition(false);}return e.keyCode===229?(this._handleAnyTextareaChanges(),false):true}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=false,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end},i=this._compositionSuffix;this._isSendingComposition=true,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=false;let s;if(t.start+=this._dataAlreadySent.length,this._isComposing)s=this._textarea.value.substring(t.start,this._compositionPosition.start);else {let r=this._textarea.value,o=i.length>0&&r.endsWith(i)?r.length-i.length:r.length;s=r.substring(t.start,Math.max(t.start,o));}s.length>0&&this._coreService.triggerDataEvent(s,true);}},0);}else {this._isSendingComposition=false;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,true);}}_handleAnyTextareaChanges(){if(this._textareaChangeTimer)return;let e=this._textarea.value;this._textareaChangeTimer=window.setTimeout(()=>{if(this._textareaChangeTimer=void 0,!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,true):t.length<e.length?this._coreService.triggerDataEvent("\x7F",true):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,true);}},0);}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._bufferService.cols*this._renderService.dimensions.css.cell.width-r;this._compositionView.style.maxWidth=o+"px",this._compositionView.style.overflow="hidden",this._compositionView.style.direction="rtl";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px";}e||setTimeout(()=>this.updateCompositionElements(true),0);}}};Yt=M([p(2,V),p(3,Y),p(4,ue),p(5,de)],Yt);var W=0,z=0,K=0,P=0,Ni={css:"#00000000",rgba:0},A;(e=>{function t(r,o,n,h){return h!==void 0?`#${Se(r)}${Se(o)}${Se(n)}${Se(h)}`:`#${Se(r)}${Se(o)}${Se(n)}`}e.toCss=t;function i(r,o,n,h=255){return (r<<24|o<<16|n<<8|h)>>>0}e.toRgba=i;function s(r,o,n,h){return {css:e.toCss(r,o,n,h),rgba:e.toRgba(r,o,n,h)}}e.toColor=s;})(A||={});var D;(e=>{function t(l,a){if(P=(a.rgba&255)/255,P===1)return {css:a.css,rgba:a.rgba};let c=a.rgba>>24&255,d=a.rgba>>16&255,u=a.rgba>>8&255,f=l.rgba>>24&255,_=l.rgba>>16&255,g=l.rgba>>8&255;W=f+Math.round((c-f)*P),z=_+Math.round((d-_)*P),K=g+Math.round((u-g)*P);let v=A.toCss(W,z,K),S=A.toRgba(W,z,K);return {css:v,rgba:S}}e.blend=t;function i(l){return (l.rgba&255)===255}e.isOpaque=i;function s(l,a,c){let d=lt.ensureContrastRatio(l.rgba,a.rgba,c);if(d)return A.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=s;function r(l){let a=(l.rgba|255)>>>0;return [W,z,K]=lt.toChannels(a),{css:A.toCss(W,z,K),rgba:a}}e.opaque=r;function o(l,a){return P=Math.round(a*255),[W,z,K]=lt.toChannels(l.rgba),{css:A.toCss(W,z,K,P),rgba:A.toRgba(W,z,K,P)}}e.opacity=o;function n(l,a){return P=l.rgba&255,o(l,P*a/255)}e.multiplyOpacity=n;function h(l){return [l.rgba>>24&255,l.rgba>>16&255,l.rgba>>8&255]}e.toColorRGB=h;})(D||={});var R;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1));}catch(r){}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return W=parseInt(r.slice(1,2).repeat(2),16),z=parseInt(r.slice(2,3).repeat(2),16),K=parseInt(r.slice(3,4).repeat(2),16),A.toColor(W,z,K);case 5:return W=parseInt(r.slice(1,2).repeat(2),16),z=parseInt(r.slice(2,3).repeat(2),16),K=parseInt(r.slice(3,4).repeat(2),16),P=parseInt(r.slice(4,5).repeat(2),16),A.toColor(W,z,K,P);case 7:return {css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return {css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return W=parseInt(o[1],10),z=parseInt(o[2],10),K=parseInt(o[3],10),P=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),A.toColor(W,z,K,P);if(r==="transparent")return {css:"transparent",rgba:0};if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[W,z,K,P]=t.getImageData(0,0,1,1).data,P!==255)throw new Error("css.toColor: Unsupported css format");return {rgba:A.toRgba(W,z,K,P),css:r}}e.toColor=s;})(R||={});var $;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,o){let n=s/255,h=r/255,l=o/255,a=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),c=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4);return a*.2126+c*.7152+d*.0722}e.relativeLuminance2=i;})($||={});var lt;(e=>{function t(n,h){if(P=(h&255)/255,P===1)return h;let l=h>>24&255,a=h>>16&255,c=h>>8&255,d=n>>24&255,u=n>>16&255,f=n>>8&255;return W=d+Math.round((l-d)*P),z=u+Math.round((a-u)*P),K=f+Math.round((c-f)*P),A.toRgba(W,z,K)}e.blend=t;function i(n,h,l){let a=$.relativeLuminance(n>>8),c=$.relativeLuminance(h>>8);if(_e(a,c)<l){if(c<a){let f=s(n,h,l),_=_e(a,$.relativeLuminance(f>>8));if(_<l){let g=r(n,h,l),v=_e(a,$.relativeLuminance(g>>8));return _>v?f:g}return f}let d=r(n,h,l),u=_e(a,$.relativeLuminance(d>>8));if(u<l){let f=s(n,h,l),_=_e(a,$.relativeLuminance(f>>8));return u>_?d:f}return d}}e.ensureContrastRatio=i;function s(n,h,l){let a=n>>24&255,c=n>>16&255,d=n>>8&255,u=h>>24&255,f=h>>16&255,_=h>>8&255,g=_e($.relativeLuminance2(u,f,_),$.relativeLuminance2(a,c,d));for(;g<l&&(u>0||f>0||_>0);)u-=Math.max(0,Math.ceil(u*.1)),f-=Math.max(0,Math.ceil(f*.1)),_-=Math.max(0,Math.ceil(_*.1)),g=_e($.relativeLuminance2(u,f,_),$.relativeLuminance2(a,c,d));return (u<<24|f<<16|_<<8|255)>>>0}e.reduceLuminance=s;function r(n,h,l){let a=n>>24&255,c=n>>16&255,d=n>>8&255,u=h>>24&255,f=h>>16&255,_=h>>8&255,g=_e($.relativeLuminance2(u,f,_),$.relativeLuminance2(a,c,d));for(;g<l&&(u<255||f<255||_<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),g=_e($.relativeLuminance2(u,f,_),$.relativeLuminance2(a,c,d));return (u<<24|f<<16|_<<8|255)>>>0}e.increaseLuminance=r;function o(n){return [n>>24&255,n>>16&255,n>>8&255,n&255]}e.toChannels=o;})(lt||={});function Se(e){let t=e.toString(16);return t.length<2?"0"+t:t}function _e(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Nr=class extends Ze{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i;}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return [this.fg,this.getChars(),this.getWidth(),this.getCode()]}},gt=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new oe;}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),true;return  false}getJoinedCharacters(e){if(this._characterJoiners.length===0)return [];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return [];let i=[],s=t.translateToString(true),r=t.getTrimmedLength(),o=0,n=0,h=0,l=t.getFg(0),a=t.getBg(0);for(let c=0;c<r;c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==a){if(c-o>1){let d=this._getJoinedRanges(s,h,n,t,o);for(let u=0;u<d.length;u++)i.push(d[u]);}o=c,h=n,l=this._workCell.fg,a=this._workCell.bg;}n+=this._workCell.getChars().length||1;}if(r-o>1){let c=this._getJoinedRanges(s,h,n,t,o);for(let d=0;d<c.length;d++)i.push(c[d]);}return i}_getJoinedRanges(e,t,i,s,r){let o=e.substring(t,i),n=[];try{n=this._characterJoiners[0].handler(o);}catch(h){console.error(h);}for(let h=1;h<this._characterJoiners.length;h++)try{let l=this._characterJoiners[h].handler(o);for(let a=0;a<l.length;a++)gt._mergeRanges(n,l[a]);}catch(l){console.error(l);}return this._stringRangesToCellRanges(n,s,r),n}_stringRangesToCellRanges(e,t,i){let s=0,r=false,o=0,n=e[s];if(!n)return;let h=t.getTrimmedLength();for(let l=i;l<h;l++){let a=t.getWidth(l),c=t.getString(l).length||1;if(a!==0){if(!r&&n[0]<=o&&(n[0]=l,r=true),n[1]<=o){if(n[1]=l,n=e[++s],!n)break;n[0]<=o?(n[0]=l,r=true):r=false;}o+=c;}}n&&(n[1]=h);}static _mergeRanges(e,t){let i=false;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--;}else {if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=true);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};gt=M([p(0,V)],gt);function Fi(e){if(!e)throw new Error("value must not be falsy");return e}function Fr(e){return 57508<=e&&e<=57558}function Wr(e){return 9472<=e&&e<=9631}function zr(e){return Fr(e)||Wr(e)}function Kr(){return {css:{canvas:ot(),cell:ot()},device:{canvas:ot(),cell:ot(),char:{width:0,height:0,left:0,top:0}}}}function ot(){return {width:0,height:0}}var Xt=class{constructor(e,t,i,s,r,o,n){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=o,this._themeService=n,this._workCell=new oe,this._columnSelectMode=false,this.defaultSpacing=0;}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i;}createRow(e,t,i,s,r,o,n,h,l,a,c,d,u){let f=[];u&&(u.hasBlinkingCells=false);let _=this._characterJoinerService.getJoinedCharacters(t),g=this._themeService.colors,v=e.getNoBgTrimmedLength();i&&v<o+1&&(v=o+1);let S,E=0,w="",fe,Ci=0,ki=0,xi=0,Bi=false,Ei=0,et=false,Te,Di=0,L=[],qs=c!==-1&&d!==-1;for(let X=0;X<v;X++){e.loadCell(X,this._workCell);let kt=this._workCell.getWidth();if(kt===0)continue;let tt=false,ke=X>=Di,xt=X,y=this._workCell;if(_.length>0&&X===_[0][0]&&ke){let x=_.shift(),Rt=this._isCellInSelection(x[0],t);for(fe=x[0]+1;fe<x[1];fe++)ke&&=Rt===this._isCellInSelection(fe,t);ke&&=!i||o<x[0]||o>=x[1],ke?(tt=true,y=new Nr(this._workCell,e.translateToString(true,x[0],x[1]),x[1]-x[0]),xt=x[1]-1,kt=y.getWidth()):Di=x[1];}let Ae=this._isCellInSelection(X,t),Bt=i&&X===o,Et=qs&&X>=c&&X<=d;u&&y.isBlink()&&(u.hasBlinkingCells=true),!h&&y.isBlink()&&L.push("xterm-blink-hidden");let Dt=false;this._decorationService.forEachDecorationAtCell(X,t,void 0,x=>{Dt=true;});let it=y.getChars()||" ";if(it===" "&&(y.isUnderline()||y.isOverline())&&(it="\xA0"),Te=kt*l-a.get(it,y.isBold(),y.isItalic()),!S)S=this._document.createElement("span");else if(E&&(Ae&&et||!Ae&&!et&&y.bg===Ci)&&(Ae&&et&&g.selectionForeground||y.fg===ki)&&y.extended.ext===xi&&Et===Bi&&Te===Ei&&!Bt&&!tt&&!Dt&&ke){y.isInvisible()?w+=" ":w+=it,E++;continue}else E&&(S.textContent=w),S=this._document.createElement("span"),E=0,w="";if(Ci=y.bg,ki=y.fg,xi=y.extended.ext,Bi=Et,Ei=Te,et=Ae,tt&&o>=X&&o<=xt&&(o=X),!this._coreService.isCursorHidden&&Bt&&this._coreService.isCursorInitialized){if(L.push("xterm-cursor"),this._coreBrowserService.isFocused)n&&L.push("xterm-cursor-blink"),L.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case "outline":L.push("xterm-cursor-outline");break;case "block":L.push("xterm-cursor-block");break;case "bar":L.push("xterm-cursor-bar");break;case "underline":L.push("xterm-cursor-underline");break;}}if(y.isBold()&&L.push("xterm-bold"),y.isItalic()&&L.push("xterm-italic"),y.isDim()&&L.push("xterm-dim"),y.isInvisible()?w=" ":w=y.getChars()||" ",y.isUnderline()&&(L.push(`xterm-underline-${y.extended.underlineStyle}`),w===" "&&(w="\xA0"),!y.isUnderlineColorDefault()))if(y.isUnderlineColorRGB())S.style.textDecorationColor=`rgb(${Ze.toColorRGB(y.getUnderlineColor()).join(",")})`;else {let x=y.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&y.isBold()&&x<8&&(x+=8),S.style.textDecorationColor=g.ansi[x].css;}y.isOverline()&&(L.push("xterm-overline"),w===" "&&(w="\xA0")),y.isStrikethrough()&&L.push("xterm-strikethrough"),Et&&(S.style.textDecoration="underline");let te=y.getFgColor(),Ie=y.getFgColorMode(),ne=y.getBgColor(),Oe=y.getBgColorMode(),Mt=!!y.isInverse();if(Mt){let x=te;te=ne,ne=x;let Rt=Ie;Ie=Oe,Oe=Rt;}let ge,st,He=false;this._decorationService.forEachDecorationAtCell(X,t,void 0,x=>{x.options.layer!=="top"&&He||(x.backgroundColorRGB&&(Oe=50331648,ne=x.backgroundColorRGB.rgba>>8&16777215,ge=x.backgroundColorRGB),x.foregroundColorRGB&&(Ie=50331648,te=x.foregroundColorRGB.rgba>>8&16777215,st=x.foregroundColorRGB),He=x.options.layer==="top");}),!He&&Ae&&(ge=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,ne=ge.rgba>>8&16777215,Oe=50331648,He=true,g.selectionForeground&&(Ie=50331648,te=g.selectionForeground.rgba>>8&16777215,st=g.selectionForeground)),He&&L.push("xterm-decoration-top");let pe;switch(Oe){case 16777216:case 33554432:pe=g.ansi[ne],L.push(`xterm-bg-${ne}`);break;case 50331648:pe=A.toColor(ne>>16,ne>>8&255,ne&255),this._addStyle(S,`background-color:#${(ne>>>0).toString(16).padStart(6,"0")}`);break;default:Mt?(pe=g.foreground,L.push("xterm-bg-257")):pe=g.background;}switch(ge||y.isDim()&&(ge=D.multiplyOpacity(pe,.5)),Ie){case 16777216:case 33554432:y.isBold()&&te<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(te+=8),this._applyMinimumContrast(S,pe,g.ansi[te],y,ge,void 0)||L.push(`xterm-fg-${te}`);break;case 50331648:let x=A.toColor(te>>16&255,te>>8&255,te&255);this._applyMinimumContrast(S,pe,x,y,ge,st)||this._addStyle(S,`color:#${te.toString(16).padStart(6,"0")}`);break;default:this._applyMinimumContrast(S,pe,g.foreground,y,ge,st)||Mt&&L.push("xterm-fg-257");}L.length&&(S.className=L.join(" "),L.length=0),!Bt&&!tt&&!Dt&&ke?E++:S.textContent=w,Te!==this.defaultSpacing&&(S.style.letterSpacing=`${Te}px`),f.push(S),X=xt;}return S&&E&&(S.textContent=w),f}_applyMinimumContrast(e,t,i,s,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||zr(s.getCode()))return  false;let n=this._getContrastCache(s),h;if(!r&&!o&&(h=n.getColor(t.rgba,i.rgba)),h===void 0){let l=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=D.ensureContrastRatio(r??t,o??i,l),n.setColor((r??t).rgba,(o??i).rgba,h??null);}return h?(this._addStyle(e,`color:${h.css}`),true):false}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`);}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return !i||!s?false:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Xt=M([p(1,ws),p(2,Y),p(3,ce),p(4,ue),p(5,Qe),p(6,Re)],Xt);var $r=class{constructor(e=()=>new Ur){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._canvasElements=[],this._canvasElements=[e(),e(),e(),e()],this.clear();}dispose(){this._canvasElements.length=0,this._holey=void 0;}clear(){this._flat.fill(-9999),this._holey=new Map;}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._canvasElements[0].setFont(e,t,i,false),this._canvasElements[1].setFont(e,t,s,false),this._canvasElements[2].setFont(e,t,i,true),this._canvasElements[3].setFont(e,t,s,true),this.clear());}get(e,t,i){let s;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let n=this._measure(e,0);return n>0&&(this._flat[s]=n),n}let r=e;t&&(r+="B"),i&&(r+="I");let o=this._holey.get(r);if(o===void 0){let n=0;t&&(n|=1),i&&(n|=2),o=this._measure(e,n),o>0&&this._holey.set(r,o);}return o}_measure(e,t){return this._canvasElements[t].measure(e)}},Ur=class{constructor(){typeof OffscreenCanvas<"u"?(this._canvas=new OffscreenCanvas(1,1),this._ctx=Fi(this._canvas.getContext("2d"))):(this._canvas=document.createElement("canvas"),this._canvas.width=1,this._canvas.height=1,this._ctx=Fi(this._canvas.getContext("2d")));}setFont(e,t,i,s){let r=s?"italic":"";this._ctx.font=`${r} ${i} ${t}px ${e}`.trim();}measure(e){return this._ctx.measureText(e).width}},qr=class{constructor(){this.clear();}clear(){this.hasSelection=false,this.columnSelectMode=false,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0;}update(e,t,i,s=false){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,o=t[1]-r,n=i[1]-r,h=Math.max(o,0),l=Math.min(n,e.rows-1);if(h>=e.rows||l<0){this.clear();return}this.hasSelection=true,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=n,this.viewportCappedStartRow=h,this.viewportCappedEndRow=l,this.startCol=t[0],this.endCol=i[0];}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):false}};function Vr(){return new qr}var Yr=class extends C{constructor(e,t,i){super(),this._renderCallback=e,this._coreBrowserService=t,this._optionsService=i,this._intervalDuration=0,this._blinkOn=true,this._needsBlinkInViewport=false,this._isViewportVisible=true,this._register(this._optionsService.onSpecificOptionChange("blinkIntervalDuration",s=>{this.setIntervalDuration(s);})),this.setIntervalDuration(this._optionsService.rawOptions.blinkIntervalDuration),this._register(k(()=>this._clearInterval()));}get isBlinkOn(){return this._blinkOn}get isEnabled(){return this._intervalDuration>0}setNeedsBlinkInViewport(e){this._needsBlinkInViewport!==e&&(this._needsBlinkInViewport=e,this._updateIntervalState());}setViewportVisible(e){this._isViewportVisible!==e&&(this._isViewportVisible=e,this._updateIntervalState());}setIntervalDuration(e){e!==this._intervalDuration&&(this._intervalDuration=e,this._clearInterval(),this._updateIntervalState());}_updateIntervalState(){if(this._intervalDuration>0&&this._needsBlinkInViewport&&this._isViewportVisible){if(this._interval!==void 0)return;let e=this._blinkOn;this._blinkOn=true,this._interval=this._coreBrowserService.window.setInterval(()=>{this._blinkOn=!this._blinkOn,this._renderCallback();},this._intervalDuration),e||this._renderCallback();return}this._clearInterval(),this._blinkOn||(this._blinkOn=true,this._renderCallback());}_clearInterval(){this._interval!==void 0&&(this._coreBrowserService.window.clearInterval(this._interval),this._interval=void 0);}},Xr=1,jt=class extends C{constructor(e,t,i,s,r,o,n,h,l,a,c,d,u,f){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=o,this._linkifier2=n,this._charSizeService=l,this._optionsService=a,this._bufferService=c,this._coreService=d,this._coreBrowserService=u,this._themeService=f,this._terminalClass=Xr++,this._rowElements=[],this._selectionRenderModel=Vr(),this._lastSelectionColumnMode=false,this._rowHasBlinkingCells=[],this._rowHasBlinkingCellsCount=0,this._onRequestRedraw=this._register(new m),this.onRequestRedraw=this._onRequestRedraw.event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add("xterm-rows"),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add("xterm-selection"),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Kr(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(_=>this._injectCss(_))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(Xt,document),this._element.classList.add("xterm-dom-renderer-owner-"+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(_=>this._handleLinkHover(_))),this._register(this._linkifier2.onHideLinkUnderline(_=>this._handleLinkLeave(_))),this._cursorBlinkStateManager=new jr(this._rowContainer,this._coreBrowserService),this._register(b(this._document,"mousedown",()=>this._cursorBlinkStateManager.restartBlinkAnimation())),this._register(k(()=>this._cursorBlinkStateManager.dispose())),this._textBlinkStateManager=this._register(new Yr(()=>this._onRequestRedraw.fire({start:0,end:this._bufferService.rows-1}),this._coreBrowserService,this._optionsService)),this._register(k(()=>{this._element.classList.remove("xterm-dom-renderer-owner-"+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove();})),this._widthCache=new $r,this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing();}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .xterm-rows span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`;}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .xterm-rows { pointer-events: none; color: ${e.foreground.css};}`;t+=`${this._terminalSelector} .xterm-rows, ${this._terminalSelector} .xterm-rows span { font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`,t+=`${this._terminalSelector} .xterm-rows .xterm-dim { color: ${D.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}${this._terminalSelector} span.xterm-blink-hidden { visibility: hidden;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% {  border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% {  box-shadow: none; }}`,t+=`@keyframes ${r} { 0% {  background-color: ${e.cursor.css};  color: ${e.cursorAccent.css}; } 50% {  background-color: inherit;  color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .xterm-rows.xterm-focus .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .xterm-rows.xterm-focus .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .xterm-rows.xterm-focus .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .xterm-rows.xterm-cursor-blink-idle .xterm-cursor.xterm-cursor-blink { animation: none !important;}${this._terminalSelector} .xterm-rows .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .xterm-rows .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .xterm-rows .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .xterm-rows .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .xterm-rows .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .xterm-selection { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .xterm-selection div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .xterm-selection div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,n]of e.ansi.entries())t+=`${this._terminalSelector} .xterm-fg-${o} { color: ${n.css}; }${this._terminalSelector} .xterm-fg-${o}.xterm-dim { color: ${D.multiplyOpacity(n,.5).css}; }${this._terminalSelector} .xterm-bg-${o} { background-color: ${n.css}; }`;t+=`${this._terminalSelector} .xterm-fg-257 { color: ${D.opaque(e.background).css}; }${this._terminalSelector} .xterm-fg-257.xterm-dim { color: ${D.multiplyOpacity(D.opaque(e.background),.5).css}; }${this._terminalSelector} .xterm-bg-257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t;}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",false,false);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e;}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing();}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s),this._rowHasBlinkingCells.push(false);}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop()),this._rowHasBlinkingCells.pop()&&this._rowHasBlinkingCellsCount--;}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode);}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing();}handleBlur(){this._rowContainer.classList.remove("xterm-focus"),this._cursorBlinkStateManager.pause(),this.renderRows(0,this._bufferService.rows-1);}handleFocus(){this._rowContainer.classList.add("xterm-focus"),this._cursorBlinkStateManager.resume(),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y);}handleViewportVisibilityChange(e){this._textBlinkStateManager.setViewportVisible(e);}handleSelectionChanged(e,t,i){let s=this._bufferService.rows;this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i);let r=0,o=-1;this._lastSelectionStart&&this._lastSelectionEnd&&(this._selectionRenderModel.update(this._terminal,this._lastSelectionStart,this._lastSelectionEnd,this._lastSelectionColumnMode),this._selectionRenderModel.hasSelection&&(r=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow));let n=0,h=-1;if(!e||!t)return;if(this._selectionRenderModel.update(this._terminal,e,t,i),this._selectionRenderModel.hasSelection){let c=this._selectionRenderModel.viewportStartRow,d=this._selectionRenderModel.viewportEndRow,u=this._selectionRenderModel.viewportCappedStartRow,f=this._selectionRenderModel.viewportCappedEndRow;n=u,h=f;let _=this._document.createDocumentFragment();if(i){let g=e[0]>t[0];_.appendChild(this._createSelectionElement(u,g?t[0]:e[0],g?e[0]:t[0],f-u+1));}else {let g=c===u?e[0]:0,v=u===d?t[0]:this._bufferService.cols;_.appendChild(this._createSelectionElement(u,g,v));let S=f-u-1;if(_.appendChild(this._createSelectionElement(u+1,0,this._bufferService.cols,S)),u!==f){let E=d===f?t[0]:this._bufferService.cols;_.appendChild(this._createSelectionElement(f,0,E));}}this._selectionContainer.appendChild(_);}let l=Math.min(r,n),a=Math.max(o,h);if(a>=0){l=Math.max(l,0),a=Math.min(a,s-1);let c=this._bufferService.buffer.y;this._selectionRenderModel.hasSelection&&c>=0&&c<s&&(l=Math.min(l,c),a=Math.max(a,c)),this.renderRows(l,a);}this._lastSelectionStart=e,this._lastSelectionEnd=t,this._lastSelectionColumnMode=i;}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,n=this.dimensions.css.cell.width*(i-t);return o+n>this.dimensions.css.canvas.width&&(n=this.dimensions.css.canvas.width-o),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${n}px`,r}handleCursorMove(){this._cursorBlinkStateManager.restartBlinkAnimation();}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing();}clear(){for(let e of this._rowElements)e.replaceChildren();this._rowHasBlinkingCellsCount>0&&(this._rowHasBlinkingCells.fill(false),this._rowHasBlinkingCellsCount=0,this._textBlinkStateManager.setNeedsBlinkInViewport(false));}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,n=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle,l={hasBlinkingCells:false};for(let a=e;a<=t;a++){let c=a+i.ydisp,d=this._rowElements[a];if(!d)continue;let u=i.lines.get(c);if(!u){d.replaceChildren(),this._setRowBlinkState(a,false);continue}d.replaceChildren(...this._rowFactory.createRow(u,c,c===s,n,h,r,o,this._textBlinkStateManager.isBlinkOn,this.dimensions.css.cell.width,this._widthCache,-1,-1,l)),this._setRowBlinkState(a,l.hasBlinkingCells);}this._updateTextBlinkState();}get _terminalSelector(){return `.xterm-dom-renderer-owner-${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,true);}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,false);}_setCellUnderline(e,t,i,s,r,o){i<0&&(e=0),s<0&&(t=0);let n=this._bufferService.rows-1;i=Math.max(Math.min(i,n),0),s=Math.max(Math.min(s,n),0),r=Math.min(r,this._bufferService.cols);let h=this._bufferService.buffer,l=h.ybase+h.y,a=Math.min(h.x,r-1),c=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle,f={hasBlinkingCells:false};for(let _=i;_<=s;++_){let g=_+h.ydisp,v=this._rowElements[_];if(!v)continue;let S=h.lines.get(g);if(!S){v.replaceChildren(),this._setRowBlinkState(_,false);continue}v.replaceChildren(...this._rowFactory.createRow(S,g,g===l,d,u,a,c,this._textBlinkStateManager.isBlinkOn,this.dimensions.css.cell.width,this._widthCache,o?_===i?e:0:-1,o?(_===s?t:r)-1:-1,f)),this._setRowBlinkState(_,f.hasBlinkingCells);}this._updateTextBlinkState();}_setRowBlinkState(e,t){this._rowHasBlinkingCells[e]!==t&&(this._rowHasBlinkingCells[e]=t,this._rowHasBlinkingCellsCount+=t?1:-1);}_updateTextBlinkState(){this._textBlinkStateManager.setNeedsBlinkInViewport(this._rowHasBlinkingCellsCount>0);}};jt=M([p(7,ui),p(8,St),p(9,Y),p(10,V),p(11,ue),p(12,ce),p(13,Re)],jt);var jr=class{constructor(e,t){this._rowContainer=e,this._coreBrowserService=t,this._isIdlePaused=false,this._coreBrowserService.isFocused&&this._resetIdleTimer();}dispose(){this._clearIdleTimer();}restartBlinkAnimation(){this._isIdlePaused&&this._rowContainer.classList.remove("xterm-cursor-blink-idle"),this._resetIdleTimer();}pause(){this._isIdlePaused=false,this._clearIdleTimer();}resume(){this._isIdlePaused=false,this._rowContainer.classList.remove("xterm-cursor-blink-idle"),this._resetIdleTimer();}_resetIdleTimer(){this._isIdlePaused=false,this._clearIdleTimer(),this._idleTimeout=this._coreBrowserService.window.setTimeout(()=>{this._stopBlinkingDueToIdle();},3e5);}_clearIdleTimer(){this._idleTimeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0);}_stopBlinkingDueToIdle(){this._rowContainer.classList.add("xterm-cursor-blink-idle"),this._isIdlePaused=true,this._idleTimeout=void 0;}},Gt=class extends C{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new m),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Jr(this._optionsService));}catch(s){this._measureStrategy=this._register(new Gr(e,t,this._optionsService));}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()));}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire());}};Gt=M([p(2,Y)],Gt);var Ps=class extends C{constructor(){super(...arguments),this._result={width:0,height:0};}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t);}},Gr=class extends Ps{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement);}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Jr=class extends Ps{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Zr=class extends C{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=false,this._cachedIsFocused=void 0,this._onDprChange=this._register(new m),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new m),this.onWindowChange=this._onWindowChange.event,this._screenDprMonitor=this._register(new Qr(this._window)),this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(J.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(b(this._textarea,"focus",()=>this._isFocused=true)),this._register(b(this._textarea,"blur",()=>this._isFocused=false));}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window));}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Qr=class extends C{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Z),this._onDprChange=this._register(new m),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(k(()=>this.clearListener()));}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers();}_setWindowResizeListener(){this._windowResizeListener.value=b(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers());}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr();}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener));}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0);}},eo=class extends C{constructor(){super(),this.linkProviders=[],this._register(k(()=>this.linkProviders.length=0));}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1);}}}};function bi(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),o=parseInt(r.getPropertyValue("padding-left"),10),n=parseInt(r.getPropertyValue("padding-top"),10);return [t.clientX-s.left-o,t.clientY-s.top-n]}function to(e,t,i,s,r,o,n,h,l){if(!o)return;let a=bi(e,t,i);return a[0]=Math.ceil((a[0]+(l?n/2:0))/n),a[1]=Math.ceil(a[1]/h),a[0]=Math.min(Math.max(a[0],1),s+(l?1:0)),a[1]=Math.min(Math.max(a[1],1),r),a}var Jt=class{constructor(e,t){this._charSizeService=e,this._renderService=t;}getCoords(e,t,i,s,r){return to(re(t),e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=bi(re(t),e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Jt=M([p(0,St),p(1,de)],Jt);var Wi=typeof window=="object"?window:globalThis;function Q(e,t=0){return e[e.length-(1+t)]}function io(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r||!s)throw new Error("not supported");let o=`$memoize$${t}`,n=i;n[s]=function(...h){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:false,enumerable:false,writable:false,value:r.apply(this,h)}),this[o]};}var Zt=class Qt{constructor(t){this.element=t,this.next=Qt.Undefined,this.prev=Qt.Undefined;}};Zt.Undefined=new Zt(void 0);var G=Zt,zi=class{constructor(){this._first=G.Undefined,this._last=G.Undefined;}push(e){return this._insert(e,true)}_insert(e,t){let i=new G(e);if(this._first===G.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i;}else {let r=this._first;this._first=i,i.next=r,r.prev=i;}let s=false;return ()=>{s||(s=true,this._remove(i));}}_remove(e){if(e.prev!==G.Undefined&&e.next!==G.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t;}else e.prev===G.Undefined&&e.next===G.Undefined?(this._first=G.Undefined,this._last=G.Undefined):e.next===G.Undefined?(this._last=this._last.prev,this._last.next=G.Undefined):e.prev===G.Undefined&&(this._first=this._first.next,this._first.prev=G.Undefined);}*[Symbol.iterator](){let e=this._first;for(;e!==G.Undefined;)yield e.element,e=e.next;}},ie;(e=>(e.TAP="-xterm-gesturetap",e.CHANGE="-xterm-gesturechange",e.START="-xterm-gesturestart",e.END="-xterm-gesturesend",e.CONTEXT_MENU="-xterm-gesturecontextmenu"))(ie||={});var $e=class U extends C{constructor(){super(),this._dispatched=false,this._targets=new zi,this._ignoreTargets=new zi,this._activeTouches={},this._handle=null,this._lastSetTapCountTime=0;let t=Wi;this._register(b(t.document,"touchstart",i=>this._handleTouchStart(i),{passive:false})),this._register(b(t.document,"touchend",i=>this._handleTouchEnd(t,i))),this._register(b(t.document,"touchmove",i=>this._handleTouchMove(i),{passive:false}));}static addTarget(t){if(!U.isTouchDevice())return C.None;U._instance||(U._instance=new U);let i=U._instance._targets.push(t);return k(i)}static ignoreTarget(t){if(!U.isTouchDevice())return C.None;U._instance||(U._instance=new U);let i=U._instance._ignoreTargets.push(t);return k(i)}static isTouchDevice(){return "ontouchstart"in Wi||navigator.maxTouchPoints>0}dispose(){this._handle&&(this._handle.dispose(),this._handle=null),super.dispose();}_handleTouchStart(t){let i=Date.now();this._handle&&(this._handle.dispose(),this._handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let o=t.targetTouches.item(s);this._activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:i,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[i],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let n=this._newGestureEvent(ie.START,o.target);n.pageX=o.pageX,n.pageY=o.pageY,this._dispatchEvent(n);}this._dispatched&&(t.preventDefault(),t.stopPropagation(),this._dispatched=false);}_handleTouchEnd(t,i){let s=Date.now(),r=Object.keys(this._activeTouches).length;for(let o=0,n=i.changedTouches.length;o<n;o++){let h=i.changedTouches.item(o);if(!this._activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let l=this._activeTouches[h.identifier],a=Date.now()-l.initialTimeStamp;if(a<U._holdDelay&&Math.abs(l.initialPageX-Q(l.rollingPageX))<30&&Math.abs(l.initialPageY-Q(l.rollingPageY))<30){let c=this._newGestureEvent(ie.TAP,l.initialTarget);c.pageX=Q(l.rollingPageX),c.pageY=Q(l.rollingPageY),this._dispatchEvent(c);}else if(a>=U._holdDelay&&Math.abs(l.initialPageX-Q(l.rollingPageX))<30&&Math.abs(l.initialPageY-Q(l.rollingPageY))<30){let c=this._newGestureEvent(ie.CONTEXT_MENU,l.initialTarget);c.pageX=Q(l.rollingPageX),c.pageY=Q(l.rollingPageY),this._dispatchEvent(c);}else if(r===1){let c=Q(l.rollingPageX),d=Q(l.rollingPageY),u=Q(l.rollingTimestamps)-l.rollingTimestamps[0],f=c-l.rollingPageX[0],_=d-l.rollingPageY[0],g=[...this._targets].filter(v=>l.initialTarget instanceof Node&&v.contains(l.initialTarget));this._inertia(t,g,s,Math.abs(f)/u,f>0?1:-1,c,Math.abs(_)/u,_>0?1:-1,d);}this._dispatchEvent(this._newGestureEvent(ie.END,l.initialTarget)),delete this._activeTouches[h.identifier];}this._dispatched&&(i.preventDefault(),i.stopPropagation(),this._dispatched=false);}_newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,false,true),s.initialTarget=i,s.tapCount=0,s}_dispatchEvent(t){if(t.type===ie.TAP){let i=new Date().getTime(),s;i-this._lastSetTapCountTime>U._clearTapCountTime?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s;}else (t.type===ie.CHANGE||t.type===ie.CONTEXT_MENU)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this._ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this._targets)if(s.contains(t.initialTarget)){let r=0,o=t.initialTarget;for(;o&&o!==s;)r++,o=o.parentElement;i.push([r,s]);}i.sort((s,r)=>s[0]-r[0]);for(let[,s]of i)s.dispatchEvent(t),this._dispatched=true;}}_inertia(t,i,s,r,o,n,h,l,a){this._handle=fi(t,()=>{let c=Date.now(),d=c-s,u=0,f=0,_=true;r+=U._scrollFriction*d,h+=U._scrollFriction*d,r>0&&(_=false,u=o*r*d),h>0&&(_=false,f=l*h*d);let g=this._newGestureEvent(ie.CHANGE);g.translationX=u,g.translationY=f,i.forEach(v=>v.dispatchEvent(g)),_||this._inertia(t,i,c,r,o,n+u,h,l,a+f);});}_handleTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let o=t.changedTouches.item(s);if(!this._activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let n=this._activeTouches[o.identifier],h=this._newGestureEvent(ie.CHANGE,n.initialTarget);h.translationX=o.pageX-Q(n.rollingPageX),h.translationY=o.pageY-Q(n.rollingPageY),h.pageX=o.pageX,h.pageY=o.pageY,h.clientX=o.clientX,h.clientY=o.clientY,this._dispatchEvent(h),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(o.pageX),n.rollingPageY.push(o.pageY),n.rollingTimestamps.push(i);}this._dispatched&&(t.preventDefault(),t.stopPropagation(),this._dispatched=false);}};$e._scrollFriction=-5e-3,$e._holdDelay=700,$e._clearTapCountTime=400,M([io],$e,"isTouchDevice",1);var so=$e,ei=class{constructor(e,t,i,s,r,o,n,h,l){this._renderService=e,this._mouseCoordsService=t,this._mouseStateService=i,this._coreService=s,this._bufferService=r,this._optionsService=o,this._selectionService=n,this._logService=h,this._coreBrowserService=l,this._lastEvent=null,this._wheelPartialScroll=0,this._touchScrollAccumulator=0;}bindMouse(e,t,i){let{element:s,document:r}=e,o={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=new Z,h=new Z;t(n),t(h);let l={target:e,focus:i,requestedEvents:o,mouseupListener:n,mousedragListener:h},a={mouseup:c=>this._handleMouseUp(l,c),wheel:c=>this._handleWheel(l,c),mousedrag:c=>this._handleMouseDrag(l,c),mousemove:c=>this._handleMouseMove(l,c)};this._altMouseCursor=new ro(s,r,()=>this._mouseStateService.areMouseEventsActive&&!!this._optionsService.rawOptions.mouseEventsRequireAlt),t(this._altMouseCursor),t(this._mouseStateService.onProtocolChange(c=>{this._handleProtocolChange(l,a,c);})),t(this._optionsService.onSpecificOptionChange("mouseEventsRequireAlt",()=>{this._syncMouseModeState(s),this._altMouseCursor?.sync();})),this._mouseStateService.activeProtocol=this._mouseStateService.activeProtocol,t(b(s,"mousedown",c=>this._handleMouseDown(l,c))),t(b(s,"wheel",c=>this._handlePassiveWheel(l,c),{passive:false})),t(so.addTarget(e.screenElement)),t(b(e.screenElement,ie.START,()=>this._handleTouchStart())),t(b(e.screenElement,ie.CHANGE,c=>this._handleTouchChange(l,c)));}_sendEvent(e,t){let i=this._mouseCoordsService.getMouseReportCoords(t,e.target.screenElement);if(!i)return  false;let s,r;switch(t.overrideType||t.type){case "mousemove":r=32,t.buttons===void 0?(s=3,t.button!==void 0&&(s=t.button<3?t.button:3)):s=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case "mouseup":r=0,s=t.button<3?t.button:3;break;case "mousedown":r=1,s=t.button<3?t.button:3;break;case "wheel":if(!this._mouseStateService.allowCustomWheelEvent(t))return  false;let n=t.deltaY;if(n===0||this._consumeWheelEvent(t,this._renderService?.dimensions?.device?.cell?.height,this._coreBrowserService?.dpr)===0)return  false;r=n<0?0:1,s=4;break;default:return  false}if(r===void 0||s===void 0||s>4||s!==4&&this._optionsService.rawOptions.mouseEventsRequireAlt&&this._mouseStateService.areMouseEventsActive&&!t.altKey)return  false;let o=s!==4&&this._optionsService.rawOptions.mouseEventsRequireAlt&&this._mouseStateService.areMouseEventsActive;return this._triggerMouseEvent({col:i.col,row:i.row,x:i.x,y:i.y,button:s,action:r,ctrl:t.ctrlKey,alt:o?false:t.altKey,shift:t.shiftKey})}_handleMouseUp(e,t){this._sendEvent(e,t),t.buttons||(e.mouseupListener.clear(),e.mousedragListener.clear());}_handleWheel(e,t){return this._sendEvent(e,t),t.preventDefault(),t.stopPropagation(),false}_handleMouseDrag(e,t){t.buttons&&this._sendEvent(e,t);}_handleMouseMove(e,t){t.buttons||this._sendEvent(e,t);}_handleMouseDown(e,t){if(t.preventDefault(),e.focus(),!this._mouseStateService.areMouseEventsActive||this._selectionService.shouldForceSelection(t))return;this._sendEvent(e,t);let{element:i,document:s}=e.target,r=i.ownerDocument??s;e.requestedEvents.mouseup&&(e.mouseupListener.value=b(r,"mouseup",e.requestedEvents.mouseup)),e.requestedEvents.mousedrag&&(e.mousedragListener.value=b(r,"mousemove",e.requestedEvents.mousedrag));}_handlePassiveWheel(e,t){if(!e.requestedEvents.wheel){if(!this._mouseStateService.allowCustomWheelEvent(t))return  false;if(!this._bufferService.buffer.hasScrollback){if(t.deltaY===0)return  false;if(this._consumeWheelEvent(t,this._renderService?.dimensions?.device?.cell?.height,this._coreBrowserService?.dpr)===0)return t.preventDefault(),t.stopPropagation(),false;let i="\x1B"+(this._coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(t.deltaY<0?"A":"B");return this._coreService.triggerDataEvent(i,true),t.preventDefault(),t.stopPropagation(),false}}}_handleTouchStart(){this._touchScrollAccumulator=0;}_handleTouchChange(e,t){if(t.preventDefault(),t.stopPropagation(),e.requestedEvents.wheel){this._handleTouchScrollAsWheel(e,t);return}if(!this._bufferService.buffer.hasScrollback){this._handleTouchScrollAsKeys(t);return}e.target.handleTouchScroll?.(t.translationY);}_handleTouchScrollAsKeys(e){let t=this._renderService?.dimensions.css.cell.height;if(!t)return;this._touchScrollAccumulator-=e.translationY;let i=Math.trunc(this._touchScrollAccumulator/t);if(i===0)return;this._touchScrollAccumulator-=i*t;let s="\x1B"+(this._coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i<0?"A":"B");for(let r=0;r<Math.abs(i);r++)this._coreService.triggerDataEvent(s,true);}_handleTouchScrollAsWheel(e,t){let i=this._renderService?.dimensions.css.cell.height;if(!i)return;this._touchScrollAccumulator-=t.translationY;let s=Math.trunc(this._touchScrollAccumulator/i);if(s===0)return;this._touchScrollAccumulator-=s*i;let r=this._mouseCoordsService.getMouseReportCoords(t,e.target.screenElement);if(r)for(let o=0;o<Math.abs(s);o++)this._triggerMouseEvent({col:r.col,row:r.row,x:r.x,y:r.y,button:4,action:s<0?0:1,ctrl:false,alt:false,shift:false});}reset(){this._lastEvent=null,this._wheelPartialScroll=0,this._touchScrollAccumulator=0;}_syncMouseModeState(e){this._mouseStateService.areMouseEventsActive?this._optionsService.rawOptions.mouseEventsRequireAlt?(this._altMouseCursor?.resetClass(),this._selectionService.enable()):(e.classList.add("enable-mouse-events"),this._selectionService.disable()):(e.classList.remove("enable-mouse-events"),this._selectionService.enable());}_handleProtocolChange(e,t,i){let{element:s}=e.target,{requestedEvents:r}=e;i?this._optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this._explainEvents(i)):this._logService.debug("Unbinding from mouse events."),this._syncMouseModeState(s),this._altMouseCursor?.sync(),i&8?r.mousemove||(s.addEventListener("mousemove",t.mousemove),r.mousemove=t.mousemove):(r.mousemove&&s.removeEventListener("mousemove",r.mousemove),r.mousemove=null),i&16?r.wheel||(s.addEventListener("wheel",t.wheel,{passive:false}),r.wheel=t.wheel):(r.wheel&&s.removeEventListener("wheel",r.wheel),r.wheel=null),i&2?r.mouseup??=t.mouseup:(e.mouseupListener.clear(),r.mouseup=null),i&4?r.mousedrag??=t.mousedrag:(e.mousedragListener.clear(),r.mousedrag=null);}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}_consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_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._mouseStateService.isPixelEncoding))||!this._mouseStateService.restrictMouseEvent(e))return  false;let t=this._mouseStateService.encodeMouseEvent(e);return t&&(this._mouseStateService.isDefaultEncoding?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,true)),this._lastEvent=e,true}_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  false}else if(e.col!==t.col||e.row!==t.row)return  false;return !(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ei=M([p(0,de),p(1,wt),p(2,mt),p(3,ue),p(4,V),p(5,Y),p(6,Ss),p(7,Me),p(8,ce)],ei);var ro=class{constructor(e,t,i){this._element=e,this._document=t,this._isActive=i,this._listeners=new Z;}dispose(){this._listeners.dispose();}sync(){if(this._listeners.clear(),!this._isActive())return;let e=new Le,t=s=>this.syncFromModifier(s);e.add(b(this._document,"keydown",t)),e.add(b(this._document,"keyup",t)),e.add(b(this._element,"mousemove",t));let i=this._element.ownerDocument?.defaultView;i&&e.add(b(i,"blur",()=>{this._isActive()&&this.resetClass();})),this._listeners.value=e;}resetClass(){this._updateClass(false);}syncFromModifier(e){this._isActive()&&this._updateClass(e.getModifierState("Alt"));}_updateClass(e){e?this._element.classList.add("enable-mouse-events"):this._element.classList.remove("enable-mouse-events");}},oo=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[];}dispose(){this._animationFrame!==void 0&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0);}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame??=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e??0,t=t??this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()));}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks();}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[];}},Ts=class{constructor(e){this._tasks=[],this._i=0,this._logService=e;}enqueue(e){this._tasks.push(e),this._start();}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear();}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0;}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)));}_process(e){this._idleCallback=void 0;let t,i=0,s=e.timeRemaining(),r;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&this._logService.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r;}this.clear();}},no=class extends Ts{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e);}_createDeadline(e){let t=performance.now()+e;return {timeRemaining:()=>Math.max(0,t-performance.now())}}},ao=class extends Ts{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e);}},pt="requestIdleCallback"in globalThis?ao:no,ho=class{constructor(e){this._queue=new pt(e);}set(e){this._queue.clear(),this._queue.enqueue(e);}flush(){this._queue.flush();}dispose(){this._queue.clear();}},ti=class extends C{constructor(e,t,i,s,r,o,n,h,l,a){super(),this._rowCount=e,this._optionsService=i,this._logService=s,this._charSizeService=r,this._coreService=o,this._coreBrowserService=l,this._renderer=this._register(new Z),this._observerDisposable=this._register(new Z),this._isPaused=false,this._needsFullRefresh=false,this._isNextRenderRedrawOnly=true,this._needsSelectionRefresh=false,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:false},this._onDimensionsChange=this._register(new m),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new m),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new m),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new m),this.onRefreshRequest=this._onRefreshRequest.event,this._pausedResizeTask=this._register(new ho(this._logService)),this._renderDebouncer=new oo((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new lo(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(k(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(h.onResize(()=>this._fullRefresh())),this._register(h.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(h.cols,h.rows),this._fullRefresh();})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(h.buffer.y,h.buffer.y,void 0,true))),this._register(a.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)));}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});this._observerDisposable.value=k(()=>{this._intersectionObserver?.disconnect(),this._intersectionObserver=void 0;}),this._intersectionObserver=i,i.observe(t);}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,this._renderer.value?.handleViewportVisibilityChange?.(!this._isPaused),!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=false);}refreshRows(e,t,i=false,s=false){if(this._isPaused){this._needsFullRefresh=true;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),s||(this._isNextRenderRedrawOnly=false),i?this._renderRows(e,t):this._renderDebouncer.refresh(e,t,this._rowCount);}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=false),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=true;}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize();}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize());}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions));}hasRenderer(){return !!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,t.sync,true)),this._needsSelectionRefresh=true,this._fullRefresh());}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=true:this.refreshRows(0,this._rowCount-1);}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh());}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1));}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh());}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged();}handleBlur(){this._renderer.value?.handleBlur();}handleFocus(){this._renderer.value?.handleFocus();}handleSelectionChanged(e,t,i){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,this._renderer.value?.handleSelectionChanged(e,t,i);}handleCursorMove(){this._renderer.value?.handleCursorMove();}clear(){this._renderer.value?.clear();}};ti=M([p(2,Y),p(3,Me),p(4,St),p(5,ue),p(6,Qe),p(7,V),p(8,ce),p(9,Re)],ti);var lo=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=false;}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=true),this._timeout??=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=false,this._onTimeout();},1e3);}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=false,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0);}};function co(e,t,i,s){let r=i.buffer.x,o=i.buffer.y;if(!i.buffer.hasScrollback)return fo(r,o,e,t,i,s)+Ct(o,t,i,s)+go(r,o,e,t,i,s);let n;if(o===t)return n=r>e?"D":"C",Ge(Math.abs(r-e),je(n,s));n=o>t?"D":"C";let h=Math.abs(o-t),l=uo(o>t?e:r,i)+(h-1)*i.cols+1+_o(o>t?r:e);return Ge(l,je(n,s))}function _o(e,t){return e-1}function uo(e,t){return t.cols-e}function fo(e,t,i,s,r,o){return Ct(t,s,r,o).length===0?"":Ge(Is(e,t,e,t-Ce(t,r),false,r).length,je("D",o))}function Ct(e,t,i,s){let r=e-Ce(e,i),o=t-Ce(t,i),n=Math.abs(r-o)-po(e,t,i);return Ge(n,je(As(e,t),s))}function go(e,t,i,s,r,o){let n;Ct(t,s,r,o).length>0?n=s-Ce(s,r):n=t;let h=s,l=vo(e,t,i,s,r,o);return Ge(Is(e,n,i,h,l==="C",r).length,je(l,o))}function po(e,t,i){let s=0,r=e-Ce(e,i),o=t-Ce(t,i);for(let n=0;n<Math.abs(r-o);n++){let h=As(e,t)==="A"?-1:1;i.buffer.lines.get(r+h*n)?.isWrapped&&s++;}return s}function Ce(e,t){let i=0,s=t.buffer.lines.get(e),r=s?.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s?.isWrapped;return i}function vo(e,t,i,s,r,o){let n;return Ct(t,s,r,o).length>0?n=s-Ce(s,r):n=t,e<i&&n<=s||e>=i&&n<s?"C":"D"}function As(e,t){return e>t?"A":"B"}function Is(e,t,i,s,r,o){let n=e,h=t,l="";for(;(n!==i||h!==s)&&h>=0&&h<o.buffer.lines.length;)n+=r?1:-1,r&&n>o.cols-1?(l+=o.buffer.translateBufferLineToString(h,false,e,n),n=0,e=0,h++):!r&&n<0&&(l+=o.buffer.translateBufferLineToString(h,false,0,e+1),n=o.cols-1,e=n,h--);return l+o.buffer.translateBufferLineToString(h,false,e,n)}function je(e,t){return "\x1B"+(t?"O":"[")+e}function Ge(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var mo=class{constructor(e){this._bufferService=e,this.isSelectAllActive=false,this.selectionStartLength=0;}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=false,this.selectionStartLength=0;}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return [this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return !e||!t?false:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),true):this.selectionStart&&this.selectionStart[1]<0?(this.selectionStart=[0,0],true):false}};function Ki(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var So="\xA0",wo=new RegExp(So,"g"),ii=class extends C{constructor(e,t,i,s,r,o,n,h,l,a){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseCoordsService=o,this._optionsService=n,this._mouseStateService=h,this._renderService=l,this._coreBrowserService=a,this._dragScrollAmount=0,this._enabled=true,this._trimListener=this._register(new Z),this._workCell=new oe,this._mouseDownTimeStamp=0,this._oldHasSelection=false,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new m),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new m),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new m),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new m),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection();}),this._trimListener.value=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new mo(this._bufferService),this._activeSelectionMode=0,this._register(k(()=>{this._removeMouseDownListeners();})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection();}));}reset(){this.clearSelection();}disable(){this.clearSelection(),this._enabled=false;}enable(){this._enabled=true;}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return !e||!t?false:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return "";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return "";let r=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let n=e[1];n<=t[1];n++){let h=i.translateBufferLineToString(n,true,r,o);s.push(h);}}else {let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],true,e[0],r));for(let o=e[1]+1;o<=t[1]-1;o++){let n=i.lines.get(o),h=i.translateBufferLineToString(o,true);n?.isWrapped?s[s.length-1]+=h:s.push(h);}if(e[1]!==t[1]){let o=i.lines.get(t[1]),n=i.translateBufferLineToString(t[1],true,0,t[0]);o&&o.isWrapped?s[s.length-1]+=n:s.push(n);}}return s.map(r=>r.replace(wo," ")).join(yt?`\r
`:`
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire();}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Si&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText);}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3});}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return !i||!s||!t?false:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return !i||!s?false:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let i=this._linkifier.currentLink?.link?.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=Ki(i,this._bufferService.cols),this._model.selectionEnd=void 0,true;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,true):false}selectAll(){this._model.isSelectAllActive=true,this.refresh(),this._onSelectionChange.fire();}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire();}_handleTrim(e){this._model.handleTrim(e)&&this.refresh();}_getMouseBufferCoords(e){let t=this._mouseCoordsService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,true);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=bi(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-50),50),t/=50,t/Math.abs(t)+Math.round(t*14))}shouldForceSelection(e){return this._optionsService.rawOptions.mouseEventsRequireAlt&&this._mouseStateService.areMouseEventsActive?!e.altKey:se?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0&&!(this._optionsService.rawOptions.mouseEventsRequireAlt&&this._mouseStateService.areMouseEventsActive&&e.altKey)){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation();}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(true);}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50);}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0;}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e));}_handleSingleClick(e){let t=this.hasSelection;if(this._model.selectionStartLength=0,this._model.isSelectAllActive=false,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0,t&&this._fireOnSelectionChange(this._model.finalSelectionStart,this._model.finalSelectionEnd,false);let i=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);i&&i.length!==this._model.selectionStart[0]&&i.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++;}_handleDoubleClick(e){this._selectWordAtCursor(e,true)&&(this._activeSelectionMode=1);}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]));}shouldColumnSelect(e){return this._optionsService.rawOptions.mouseEventsRequireAlt&&this._mouseStateService.areMouseEventsActive?false:e.altKey&&!(se&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(true);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++;}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(true);}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:false});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows-1,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh();}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseCoordsService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,false);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=co(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,true);}}}else this._fireEventIfSelectionChanged();}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i);}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire();}_handleBufferActivate(e){this.clearSelection(),this._trimListener.value=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t));}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1);}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged();}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,false)&&this.refresh(true),this._fireEventIfSelectionChanged());}_getWordAt(e,t,i=true,s=true){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(e[1]);if(!o)return;let n=r.translateBufferLineToString(e[1],false),h=this._convertViewportColToCharacterIndex(o,e[0]),l=h,a=e[0]-h,c=0,d=0,u=0,f=0;if(n.charAt(h)===" "){for(;h>0&&n.charAt(h-1)===" ";)h--;for(;l<n.length&&n.charAt(l+1)===" ";)l++;}else {let v=e[0],S=e[0];o.getWidth(v)===0&&(c++,v--),o.getWidth(S)===2&&(d++,S++);let E=o.getString(S).length;for(E>1&&(f+=E-1,l+=E-1);v>0&&h>0&&!this._isCharWordSeparator(o.loadCell(v-1,this._workCell));){o.loadCell(v-1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===0?(c++,v--):w>1&&(u+=w-1,h-=w-1),h--,v--;}for(;S<o.length&&l+1<n.length&&!this._isCharWordSeparator(o.loadCell(S+1,this._workCell));){o.loadCell(S+1,this._workCell);let w=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,S++):w>1&&(f+=w-1,l+=w-1),l++,S++;}}l++;let _=h+a-c+u,g=Math.min(this._bufferService.cols,l-h+c+d-u-f);if(!(!t&&n.slice(h,l).trim()==="")){if(i&&_===0&&o.getCodePoint(0)!==32){let v=r.lines.get(e[1]-1);if(v&&o.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let S=this._getWordAt([this._bufferService.cols-1,e[1]-1],false,true,false);if(S){let E=this._bufferService.cols-S.start;_-=E,g+=E;}}}if(s&&_+g===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let v=r.lines.get(e[1]+1);if(v?.isWrapped&&v.getCodePoint(0)!==32){let S=this._getWordAt([0,e[1]+1],false,false,true);S&&(g+=S.length);}}return {start:_,length:g}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length;}}_selectToWordAt(e){let t=this._getWordAt(e,true);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i];}}_isCharWordSeparator(e){return e.getWidth()===0?false:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Ki(i,this._bufferService.cols);}};ii=M([p(3,V),p(4,ue),p(5,wt),p(6,Y),p(7,mt),p(8,de),p(9,ce)],ii);var $i=class{constructor(){this._data={};}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i;}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={};}},Ui=class{constructor(){this._color=new $i,this._css=new $i;}setCss(e,t,i){this._css.set(e,t,i);}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i);}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear();}},O=Object.freeze((()=>{let e=[R.toColor("#2e3436"),R.toColor("#cc0000"),R.toColor("#4e9a06"),R.toColor("#c4a000"),R.toColor("#3465a4"),R.toColor("#75507b"),R.toColor("#06989a"),R.toColor("#d3d7cf"),R.toColor("#555753"),R.toColor("#ef2929"),R.toColor("#8ae234"),R.toColor("#fce94f"),R.toColor("#729fcf"),R.toColor("#ad7fa8"),R.toColor("#34e2e2"),R.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],o=t[i%6];e.push({css:A.toCss(s,r,o),rgba:A.toRgba(s,r,o)});}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:A.toCss(s,s,s),rgba:A.toRgba(s,s,s)});}return e})()),we=R.toColor("#ffffff"),Ue=R.toColor("#000000"),qi=R.toColor("#ffffff"),Vi=Ue,Fe={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},bo=we,si=class extends C{constructor(e){super(),this._optionsService=e,this._contrastCache=new Ui,this._halfContrastCache=new Ui,this._onChangeColors=this._register(new m),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:we,background:Ue,cursor:qi,cursorAccent:Vi,selectionForeground:void 0,selectionBackgroundTransparent:Fe,selectionBackgroundOpaque:D.blend(Ue,Fe),selectionInactiveBackgroundTransparent:Fe,selectionInactiveBackgroundOpaque:D.blend(Ue,Fe),scrollbarSliderBackground:D.opacity(we,.2),scrollbarSliderHoverBackground:D.opacity(we,.4),scrollbarSliderActiveBackground:D.opacity(we,.5),overviewRulerBorder:we,ansi:O.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)));}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=B(e.foreground,we),t.background=B(e.background,Ue),t.cursor=D.blend(t.background,B(e.cursor,qi)),t.cursorAccent=D.blend(t.background,B(e.cursorAccent,Vi)),t.selectionBackgroundTransparent=B(e.selectionBackground,Fe),t.selectionBackgroundOpaque=D.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=B(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=D.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?B(e.selectionForeground,Ni):void 0,t.selectionForeground===Ni&&(t.selectionForeground=void 0),D.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=D.opacity(t.selectionBackgroundTransparent,.3)),D.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=D.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=B(e.scrollbarSliderBackground,D.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=B(e.scrollbarSliderHoverBackground,D.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=B(e.scrollbarSliderActiveBackground,D.opacity(t.foreground,.5)),t.overviewRulerBorder=B(e.overviewRulerBorder,bo),t.ansi=O.slice(),t.ansi[0]=B(e.black,O[0]),t.ansi[1]=B(e.red,O[1]),t.ansi[2]=B(e.green,O[2]),t.ansi[3]=B(e.yellow,O[3]),t.ansi[4]=B(e.blue,O[4]),t.ansi[5]=B(e.magenta,O[5]),t.ansi[6]=B(e.cyan,O[6]),t.ansi[7]=B(e.white,O[7]),t.ansi[8]=B(e.brightBlack,O[8]),t.ansi[9]=B(e.brightRed,O[9]),t.ansi[10]=B(e.brightGreen,O[10]),t.ansi[11]=B(e.brightYellow,O[11]),t.ansi[12]=B(e.brightBlue,O[12]),t.ansi[13]=B(e.brightMagenta,O[13]),t.ansi[14]=B(e.brightCyan,O[14]),t.ansi[15]=B(e.brightWhite,O[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=B(e.extendedAnsi[s],O[s+16]);}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors);}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors);}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e];}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors);}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()};}};si=M([p(0,Y)],si);function B(e,t){if(e!==void 0)try{return R.toColor(e)}catch(i){}return t}var yo={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function Co(e,t,i,s){let r={type:0,cancel:false,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key="\x1BOA":r.key="\x1B[A":e.key==="UIKeyInputLeftArrow"?t?r.key="\x1BOD":r.key="\x1B[D":e.key==="UIKeyInputRightArrow"?t?r.key="\x1BOC":r.key="\x1B[C":e.key==="UIKeyInputDownArrow"&&(t?r.key="\x1BOB":r.key="\x1B[B");break;case 8:r.key=e.ctrlKey?"\b":"\x7F",e.altKey&&(r.key="\x1B"+r.key);break;case 9:if(e.shiftKey){r.key="\x1B[Z";break}r.key="	",r.cancel=true;break;case 13:e.key==="c"&&e.ctrlKey?r.key="":r.key=e.altKey?"\x1B\r":"\r",r.cancel=true;break;case 27:r.key="\x1B",e.altKey&&(r.key="\x1B\x1B"),r.cancel=true;break;case 37:if(e.metaKey)break;o?r.key="\x1B[1;"+(o+1)+"D":t?r.key="\x1BOD":r.key="\x1B[D";break;case 39:if(e.metaKey)break;o?r.key="\x1B[1;"+(o+1)+"C":t?r.key="\x1BOC":r.key="\x1B[C";break;case 38:if(e.metaKey)break;o?r.key="\x1B[1;"+(o+1)+"A":t?r.key="\x1BOA":r.key="\x1B[A";break;case 40:if(e.metaKey)break;o?r.key="\x1B[1;"+(o+1)+"B":t?r.key="\x1BOB":r.key="\x1B[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key="\x1B[2~");break;case 46:o?r.key="\x1B[3;"+(o+1)+"~":r.key="\x1B[3~";break;case 36:o?r.key="\x1B[1;"+(o+1)+"H":t?r.key="\x1BOH":r.key="\x1B[H";break;case 35:o?r.key="\x1B[1;"+(o+1)+"F":t?r.key="\x1BOF":r.key="\x1B[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key="\x1B[5;"+(o+1)+"~":r.key="\x1B[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key="\x1B[6;"+(o+1)+"~":r.key="\x1B[6~";break;case 112:o?r.key="\x1B[1;"+(o+1)+"P":r.key="\x1BOP";break;case 113:o?r.key="\x1B[1;"+(o+1)+"Q":r.key="\x1BOQ";break;case 114:o?r.key="\x1B[1;"+(o+1)+"R":r.key="\x1BOR";break;case 115:o?r.key="\x1B[1;"+(o+1)+"S":r.key="\x1BOS";break;case 116:o?r.key="\x1B[15;"+(o+1)+"~":r.key="\x1B[15~";break;case 117:o?r.key="\x1B[17;"+(o+1)+"~":r.key="\x1B[17~";break;case 118:o?r.key="\x1B[18;"+(o+1)+"~":r.key="\x1B[18~";break;case 119:o?r.key="\x1B[19;"+(o+1)+"~":r.key="\x1B[19~";break;case 120:o?r.key="\x1B[20;"+(o+1)+"~":r.key="\x1B[20~";break;case 121:o?r.key="\x1B[21;"+(o+1)+"~":r.key="\x1B[21~";break;case 122:o?r.key="\x1B[23;"+(o+1)+"~":r.key="\x1B[23~";break;case 123:o?r.key="\x1B[24;"+(o+1)+"~":r.key="\x1B[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key="\0":e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key="\x7F":e.key==="/"?r.key="":e.keyCode===219?r.key="\x1B":e.keyCode===220?r.key="":e.keyCode===221&&(r.key="");else if((!i||s)&&e.altKey&&!e.metaKey){let n=yo[e.keyCode]?.[e.shiftKey?1:0];if(n)r.key="\x1B"+n;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key="\x1B"+l;}else if(e.keyCode===32)r.key="\x1B"+(e.ctrlKey?"\0":" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key="\x1B"+h,r.cancel=true;}}else if(i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey)e.keyCode===65&&(r.type=1);else if(e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1)r.key=e.key;else if(e.key&&e.ctrlKey&&e.shiftKey)switch(e.code){case "Minus":r.key="";break;case "Digit2":r.key="\0";break;case "Digit6":r.key="";break}break}return r}var Yi=class{constructor(){this._functionalKeyCodes={Escape:27,Enter:13,Tab:9,Backspace:127,CapsLock:57358,ScrollLock:57359,NumLock:57360,PrintScreen:57361,Pause:57362,ContextMenu:57363,F13:57376,F14:57377,F15:57378,F16:57379,F17:57380,F18:57381,F19:57382,F20:57383,F21:57384,F22:57385,F23:57386,F24:57387,F25:57388,KP_0:57399,KP_1:57400,KP_2:57401,KP_3:57402,KP_4:57403,KP_5:57404,KP_6:57405,KP_7:57406,KP_8:57407,KP_9:57408,KP_Decimal:57409,KP_Divide:57410,KP_Multiply:57411,KP_Subtract:57412,KP_Add:57413,KP_Enter:57414,KP_Equal:57415,ShiftLeft:57441,ShiftRight:57447,ControlLeft:57442,ControlRight:57448,AltLeft:57443,AltRight:57449,MetaLeft:57444,MetaRight:57450,MediaPlayPause:57430,MediaStop:57432,MediaTrackNext:57435,MediaTrackPrevious:57436,AudioVolumeDown:57438,AudioVolumeUp:57439,AudioVolumeMute:57440},this._csiTildeKeys={Insert:2,Delete:3,PageUp:5,PageDown:6,F5:15,F6:17,F7:18,F8:19,F9:20,F10:21,F11:23,F12:24},this._csiLetterKeys={ArrowUp:"A",ArrowDown:"B",ArrowRight:"C",ArrowLeft:"D",Home:"H",End:"F"},this._ss3FunctionKeys={F1:"P",F2:"Q",F3:"R",F4:"S"};}_getNumpadKeyCode(e){if(e.code.startsWith("Numpad")){let t=e.code.slice(6);if(t>="0"&&t<="9")return 57399+parseInt(t,10);switch(t){case "Decimal":return 57409;case "Divide":return 57410;case "Multiply":return 57411;case "Subtract":return 57412;case "Add":return 57413;case "Enter":return 57414;case "Equal":return 57415}}}_getModifierKeyCode(e){switch(e.code){case "ShiftLeft":return 57441;case "ShiftRight":return 57447;case "ControlLeft":return 57442;case "ControlRight":return 57448;case "AltLeft":return 57443;case "AltRight":return 57449;case "MetaLeft":return 57444;case "MetaRight":return 57450}}_encodeModifiers(e){let t=0;return e.shiftKey&&(t|=1),e.altKey&&(t|=2),e.ctrlKey&&(t|=4),e.metaKey&&(t|=8),t>0?t+1:0}_getKeyCode(e,t){let i=this._getNumpadKeyCode(e);if(i!==void 0)return i;let s=this._getModifierKeyCode(e);if(s!==void 0)return s;let r=this._functionalKeyCodes[e.key];if(r!==void 0)return r;if((e.shiftKey||t&&e.altKey)&&e.code){if(e.code.startsWith("Digit")&&e.code.length===6){let o=e.code.charAt(5);if(o>="0"&&o<="9")return o.charCodeAt(0)}if(e.code.startsWith("Key")&&e.code.length===4)return e.code.charAt(3).toLowerCase().charCodeAt(0)}if(e.key.length===1){let o=e.key.codePointAt(0);return o>=65&&o<=90?o+32:o}}_isModifierKey(e){return e.key==="Shift"||e.key==="Control"||e.key==="Alt"||e.key==="Meta"}_isLockKey(e){return e.key==="CapsLock"||e.key==="NumLock"||e.key==="ScrollLock"}_buildCsiLetterSequence(e,t,i,s){let r=s&&i!==1;if(t>0||r){let o="\x1B[1;"+(t>0?t:"1");return r&&(o+=":"+i),o+=e,o}return "\x1B["+e}_buildSs3Sequence(e,t,i,s){let r=s&&i!==1;if(t>0||r){let o="\x1B[1;"+(t>0?t:"1");return r&&(o+=":"+i),o+=e,o}return "\x1BO"+e}_buildCsiTildeSequence(e,t,i,s){let r=s&&i!==1,o="\x1B["+e;return (t>0||r)&&(o+=";"+(t>0?t:"1"),r&&(o+=":"+i)),o+="~",o}_buildCsiUSequence(e,t,i,s,r,o,n){let h=!!(r&2),l=!!(r&4),a="\x1B["+t,c;l&&e.shiftKey&&e.key.length===1&&!o&&!n&&(c=e.key.codePointAt(0),a+=":"+c);let d=r&16&&s!==3&&e.key.length===1&&!o&&!n&&!e.ctrlKey?e.key.codePointAt(0):void 0,u=h&&s!==1&&(s===3||d===void 0);return (i>0||u||d!==void 0)&&(a+=";",i>0?a+=i:u&&(a+="1"),u&&(a+=":"+s)),d!==void 0&&(a+=";"+d),a+="u",a}evaluate(e,t,i=1,s=false){let r={type:0,cancel:false,key:void 0},o=this._encodeModifiers(e),n=this._isModifierKey(e),h=!!(t&2);if(!h&&i===3||n&&!(t&8)||this._isLockKey(e)&&!(t&8))return r;let l=this._csiLetterKeys[e.key];if(l)return r.key=this._buildCsiLetterSequence(l,o,i,h),r.cancel=true,r;let a=this._ss3FunctionKeys[e.key];if(a)return r.key=this._buildSs3Sequence(a,o,i,h),r.cancel=true,r;let c=this._csiTildeKeys[e.key];if(c!==void 0)return r.key=this._buildCsiTildeSequence(c,o,i,h),r.cancel=true,r;let d=this._getKeyCode(e,s);if(d===void 0)return r;let u=d===13||d===9||d===127;if(u&&i===3&&!(t&8))return r;let f=this._functionalKeyCodes[e.key]!==void 0||this._getNumpadKeyCode(e)!==void 0;if(t&8||h&&i===3||(t&1||h)&&(f&&!u||o>0&&e.key.length!==1||o-1>1))r.key=this._buildCsiUSequence(e,d,o,i,t,f,n),r.cancel=true;else {let _=d===13?"\r":d===9?"	":d===127?"\x7F":void 0;_?r.key=_:e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&(r.key=e.key);}return r}static shouldUseProtocol(e){return e>0}},ko=class{constructor(){this._codeToVk={KeyA:65,KeyB:66,KeyC:67,KeyD:68,KeyE:69,KeyF:70,KeyG:71,KeyH:72,KeyI:73,KeyJ:74,KeyK:75,KeyL:76,KeyM:77,KeyN:78,KeyO:79,KeyP:80,KeyQ:81,KeyR:82,KeyS:83,KeyT:84,KeyU:85,KeyV:86,KeyW:87,KeyX:88,KeyY:89,KeyZ:90,Digit0:48,Digit1:49,Digit2:50,Digit3:51,Digit4:52,Digit5:53,Digit6:54,Digit7:55,Digit8:56,Digit9:57,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,Numpad0:96,Numpad1:97,Numpad2:98,Numpad3:99,Numpad4:100,Numpad5:101,Numpad6:102,Numpad7:103,Numpad8:104,Numpad9:105,NumpadMultiply:106,NumpadAdd:107,NumpadSeparator:108,NumpadSubtract:109,NumpadDecimal:110,NumpadDivide:111,NumpadEnter:13,NumLock:144,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Home:36,End:35,PageUp:33,PageDown:34,Insert:45,Delete:46,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,MetaLeft:91,MetaRight:92,CapsLock:20,ScrollLock:145,Escape:27,Enter:13,Tab:9,Space:32,Backspace:8,Pause:19,ContextMenu:93,PrintScreen:44,Semicolon:186,Equal:187,Comma:188,Minus:189,Period:190,Slash:191,Backquote:192,BracketLeft:219,Backslash:220,BracketRight:221,Quote:222,IntlBackslash:226},this._codeToScancode={KeyQ:16,KeyW:17,KeyE:18,KeyR:19,KeyT:20,KeyY:21,KeyU:22,KeyI:23,KeyO:24,KeyP:25,KeyA:30,KeyS:31,KeyD:32,KeyF:33,KeyG:34,KeyH:35,KeyJ:36,KeyK:37,KeyL:38,KeyZ:44,KeyX:45,KeyC:46,KeyV:47,KeyB:48,KeyN:49,KeyM:50,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Digit0:11,F1:59,F2:60,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,F10:68,F11:87,F12:88,Numpad0:82,Numpad1:79,Numpad2:80,Numpad3:81,Numpad4:75,Numpad5:76,Numpad6:77,Numpad7:71,Numpad8:72,Numpad9:73,NumpadMultiply:55,NumpadAdd:78,NumpadSubtract:74,NumpadDecimal:83,NumpadDivide:53,NumpadEnter:28,NumLock:69,ArrowUp:72,ArrowDown:80,ArrowLeft:75,ArrowRight:77,Home:71,End:79,PageUp:73,PageDown:81,Insert:82,Delete:83,ShiftLeft:42,ShiftRight:54,ControlLeft:29,ControlRight:29,AltLeft:56,AltRight:56,CapsLock:58,ScrollLock:70,Escape:1,Enter:28,Tab:15,Space:57,Backspace:14,Pause:69,Semicolon:39,Equal:13,Comma:51,Minus:12,Period:52,Slash:53,Backquote:41,BracketLeft:26,Backslash:43,BracketRight:27,Quote:40},this._enhancedKeyCodes=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Insert","Delete","NumpadEnter","NumpadDivide","ControlRight","AltRight","PrintScreen","Pause","ContextMenu","MetaLeft","MetaRight"]),this._keyToControlChar={Enter:13,Backspace:8,Tab:9,Escape:27};}_getVirtualKeyCode(e){let t=this._codeToVk[e.code];return t!==void 0?t:e.keyCode||0}_getScanCode(e){return this._codeToScancode[e.code]||0}_getUnicodeChar(e){if(e.ctrlKey&&!e.altKey&&!e.metaKey){if(e.key==="Enter")return 10;if(e.key==="Backspace")return 127}let t=this._keyToControlChar[e.key];if(t!==void 0)return t;if(e.key.length===1){let i=e.key.codePointAt(0)||0;if(e.ctrlKey&&!e.altKey&&!e.metaKey){if(i>=65&&i<=90)return i-64;if(i>=97&&i<=122)return i-96}return i}return 0}_getControlKeyState(e){let t=0;return e.shiftKey&&(t|=16),e.ctrlKey&&(e.code==="ControlRight"?t|=4:t|=8),e.altKey&&(e.code==="AltRight"?t|=1:t|=2),this._enhancedKeyCodes.has(e.code)&&(t|=256),t}evaluateKeyboardEvent(e,t){let i=this._getVirtualKeyCode(e),s=this._getScanCode(e),r=this._getUnicodeChar(e),o=t?1:0,n=this._getControlKeyState(e);return {type:0,cancel:true,key:`\x1B[${i};${s};${r};${o};${n};1_`}}},ri=class{constructor(e,t){this._coreService=e,this._optionsService=t;}_getWin32InputMode(){return this._win32InputMode??=new ko,this._win32InputMode}_getKittyKeyboard(){return this._kittyKeyboard??=new Yi,this._kittyKeyboard}evaluateKeyDown(e){if(this.useWin32InputMode)return this._getWin32InputMode().evaluateKeyboardEvent(e,true);let t=this._coreService.kittyKeyboard.flags;return this.useKitty?this._getKittyKeyboard().evaluate(e,t,e.repeat?2:1,se&&this._optionsService.rawOptions.macOptionIsMeta):Co(e,this._coreService.decPrivateModes.applicationCursorKeys,se,this._optionsService.rawOptions.macOptionIsMeta)}evaluateKeyUp(e){if(this.useWin32InputMode)return this._getWin32InputMode().evaluateKeyboardEvent(e,false);let t=this._coreService.kittyKeyboard.flags;if(this.useKitty&&t&2)return this._getKittyKeyboard().evaluate(e,t,3,se&&this._optionsService.rawOptions.macOptionIsMeta)}get useKitty(){let e=this._coreService.kittyKeyboard.flags;return !!(this._optionsService.rawOptions.vtExtensions?.kittyKeyboard&&Yi.shouldUseProtocol(e))}get useWin32InputMode(){return !!(this._optionsService.rawOptions.vtExtensions?.win32InputMode&&this._coreService.decPrivateModes.win32InputMode)}};ri=M([p(0,ue),p(1,Y)],ri);var xo=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i);}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i);}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Bo=class{constructor(){this._services=new xo,this._services.set(ui,this);}setService(e,t){this._services.set(e,t);}getService(e){return this._services.get(e)}createInstance(e,...t){let i=nr(e).sort((o,n)=>o.index-n.index),s=[];for(let o of i){let n=this._services.get(o.id);if(!n)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(n);}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Eo={trace:0,debug:1,info:2,warn:3,error:4,off:5},Do="xterm.js: ",oi=class extends C{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=Eo[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?"":Do)+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);}};oi=M([p(0,Y)],oi);var Xi=class extends C{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new m),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new m),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new m),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0;}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0;}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e;}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t;}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++;}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t});}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s);}else this._length+=i.length;}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e);}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1);}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s));}}_getCyclicIndex(e){return (this._startIndex+e)%this._maxLength}},Os=class{constructor(){this._chunks=[],this._length=0;}get length(){return this._length}reset(){this._chunks.length=0,this._length=0;}append(e){this._chunks.push(e),this._length+=e.length;}toString(){return this._chunks.join("")}},yi=class{constructor(e){this._limit=e,this._builder=new Os;}get length(){return this._builder.length}get limit(){return this._limit}reset(){this._builder.reset();}append(e){return this._builder.append(e),this._builder.length>this._limit?(this._builder.reset(),true):false}toString(){return this._builder.toString()}},N=Object.freeze(new Ze),nt=0,ji=new oe,at=new Os,qe=class Hs{constructor(t,i,s,r=false){this._stringCache=t,this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(i*3);let o=s??oe.fromCharData([0,"",1,0]);for(let n=0;n<i;++n)this.setCell(n,o);this.length=i;}get(t){let i=this._data[t*3+0],s=i&2097151;return [this._data[t*3+1],i&2097152?this._combined[t]:s?me(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._invalidateStringCache(),this._data[t*3+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*3+0]=t|2097152|i[2]<<22):this._data[t*3+0]=i[1].charCodeAt(0)|i[2]<<22;}getWidth(t){return this._data[t*3+0]>>22}hasWidth(t){return this._data[t*3+0]&12582912}getFg(t){return this._data[t*3+1]}getBg(t){return this._data[t*3+2]}hasContent(t){return this._data[t*3+0]&4194303}getCodePoint(t){let i=this._data[t*3+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*3+0]&2097152}getString(t){let i=this._data[t*3+0];return i&2097152?this._combined[t]:i&2097151?me(i&2097151):""}isProtected(t){return this._data[t*3+2]&536870912}loadCell(t,i){return nt=t*3,i.content=this._data[nt+0],i.fg=this._data[nt+1],i.bg=this._data[nt+2],i.content&2097152?i.combinedData=this._combined[t]:i.combinedData="",i.bg&268435456?i.extended=this._extendedAttrs[t]:i.extended=N.extended.clone(),i}setCell(t,i){this._invalidateStringCache(),i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*3+0]=i.content,this._data[t*3+1]=i.fg,this._data[t*3+2]=i.bg;}setCellFromCodepoint(t,i,s,r){this._invalidateStringCache(),r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*3+0]=i|s<<22,this._data[t*3+1]=r.fg,this._data[t*3+2]=r.bg;}addCodepointToCell(t,i,s){this._invalidateStringCache();let r=this._data[t*3+0];r&2097152?this._combined[t]+=me(i):r&2097151?(this._combined[t]=me(r&2097151)+me(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*3+0]=r;}insertCells(t,i,s){if(this._invalidateStringCache(),t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){for(let r=this.length-t-i-1;r>=0;--r)this.setCell(t+i+r,this.loadCell(t+r,ji));for(let r=0;r<i;++r)this.setCell(t+r,s);}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s);}deleteCells(t,i,s){if(this._invalidateStringCache(),t%=this.length,i<this.length-t){for(let r=0;r<this.length-t-i;++r)this.setCell(t+r,this.loadCell(t+i+r,ji));for(let r=this.length-i;r<this.length;++r)this.setCell(r,s);}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s);}replaceCells(t,i,s,r=false){if(this._invalidateStringCache(),r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s);}resize(t,i){if(this._invalidateStringCache(),t===this.length)return this._data.length*4*2<this._data.buffer.byteLength;let s=t*3;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else {let r=new Uint32Array(s);r.set(this._data),this._data=r;}for(let r=this.length;r<t;++r)this.setCell(r,i);}else {this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let n=0;n<r.length;n++){let h=parseInt(r[n],10);h>=t&&delete this._combined[h];}let o=Object.keys(this._extendedAttrs);for(let n=0;n<o.length;n++){let h=parseInt(o[n],10);h>=t&&delete this._extendedAttrs[h];}}return this.length=t,s*4*2<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*2<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=false){if(this._invalidateStringCache(),i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t);}copyFrom(t){this._invalidateStringCache(),this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._copySparseMapsFrom(t),this.isWrapped=t.isWrapped;}clone(){let t=new Hs(this._stringCache,0,void 0,false);return t._data=new Uint32Array(this._data),t.length=this.length,t._copySparseMapsFrom(this),t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*3+0]&4194303)return t+(this._data[t*3+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*3+0]&4194303||this._data[t*3+2]&50331648)return t+(this._data[t*3+0]>>22);return 0}copyCellsFrom(t,i,s,r,o){this._invalidateStringCache();let n=t._data;if(o)for(let h=r-1;h>=0;h--){for(let l=0;l<3;l++)this._data[(s+h)*3+l]=n[(i+h)*3+l];this._copyCellMapsFrom(t,i+h,s+h);}else for(let h=0;h<r;h++){for(let l=0;l<3;l++)this._data[(s+h)*3+l]=n[(i+h)*3+l];this._copyCellMapsFrom(t,i+h,s+h);}}translateToString(t,i,s,r){let o=(i===void 0||i===0)&&s===void 0&&r===void 0;o&&this._stringCache.touch?.();let n=o?this._getStringCacheEntry(false):void 0;if(o&&n?.value!==void 0){if(t)return n.isTrimmed?n.value:n.value.trimEnd();if(!n.isTrimmed)return n.value}for(i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0),at.reset();i<s;){let l=this._data[i*3+0],a=l&2097151,c=l&2097152?this._combined[i]:a?me(a):" ";if(at.append(c),r)for(let d=0;d<c.length;++d)r.push(i);i+=l>>22||1;}r&&r.push(i);let h=at.toString();if(at.reset(),o){let l=this._getStringCacheEntry(true);l.value=h,l.isTrimmed=!!t;}return h}_getStringCacheEntry(t){let i=this._stringCacheEntryRef?.deref();if(i&&i.generation===this._stringCache.generation)return i;if(!t)return;let s=this._stringCache.allocateEntry();return this._stringCacheEntryRef=new WeakRef(s),s}_invalidateStringCache(){let t=this._getStringCacheEntry(false);t&&(t.value=void 0,t.isTrimmed=false);}_copyCellMapsFrom(t,i,s){let r=i*3;t._data[r+0]&2097152&&(this._combined[s]=t._combined[i]),t._data[r+2]&268435456&&(this._extendedAttrs[s]=t._extendedAttrs[i]);}_copySparseMapsFrom(t){this._combined={},this._extendedAttrs={};for(let i=0;i<t.length;i++)this._copyCellMapsFrom(t,i,i);}},Mo=class extends C{constructor(){super(),this.generation=0,this.entries=new Set,this._clearTimeout=this._register(new Z),this._lastAccessTimestamp=0,this._register(k(()=>this.entries.clear()));}touch(){this._scheduleClear();}allocateEntry(){let e={value:void 0,isTrimmed:false,generation:this.generation};return this.entries.add(e),this._scheduleClear(),e}clear(){this._clearTimeout.clear(),this._lastAccessTimestamp=0,this.generation++;for(let e of this.entries)e.value=void 0,e.isTrimmed=false;this.entries.clear();}_scheduleClear(){this._lastAccessTimestamp=Date.now(),!this._clearTimeout.value&&this._scheduleClearTimeout(15e3);}_scheduleClearTimeout(e){this._clearTimeout.value=ur(()=>{let t=Date.now()-this._lastAccessTimestamp;if(t>=15e3){this.clear();return}this._scheduleClearTimeout(15e3-t);},e);}};function Ro(e,t,i,s,r,o){let n=[];for(let h=0;h<e.length-1;h++){let l=h,a=e.get(++l);if(!a.isWrapped)continue;let c=[e.get(h)];for(;l<e.length&&a.isWrapped;)c.push(a),a=e.get(++l);if(!o&&s>=h&&s<l){h+=c.length-1;continue}let d=0,u=Je(c,d,t),f=1,_=0;for(;f<c.length;){let v=Je(c,f,t),S=v-_,E=i-u,w=Math.min(S,E);c[d].copyCellsFrom(c[f],_,u,w,false),u+=w,u===i&&(d++,u=0),_+=w,_===v&&(f++,_=0),u===0&&d!==0&&c[d-1].getWidth(i-1)===2&&(c[d].copyCellsFrom(c[d-1],i-1,u++,1,false),c[d-1].setCell(i-1,r));}c[d].replaceCells(u,i,r);let g=0;for(let v=c.length-1;v>0&&(v>d||c[v].getTrimmedLength()===0);v--)g++;g>0&&(n.push(h+c.length-g),n.push(g)),h+=c.length-1;}return n}function Lo(e,t){let i=[],s=0,r=t[s],o=0;for(let n=0;n<e.length;n++)if(r===n){let h=t[++s];e.onDeleteEmitter.fire({index:n-o,amount:h}),n+=h-1,o+=h,r=t[++s];}else i.push(n);return {layout:i,countRemoved:o}}function Po(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length;}function To(e,t,i){let s=[],r=0;for(let l=0;l<e.length;l++)r+=Je(e,l,t);let o=0,n=0,h=0;for(;h<r;){if(r-h<i){s.push(r-h);break}o+=i;let l=Je(e,n,t);o>l&&(o-=l,n++);let a=e[n].getWidth(o-1)===2;a&&o--;let c=a?i-1:i;s.push(c),h+=c;}return s}function Je(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var Ao=(()=>{let e=class Ns{constructor(i){this.line=i,this.isDisposed=false,this._disposables=[],this._id=Ns._nextId++,this._onDispose=this.register(new m),this.onDispose=this._onDispose.event;}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=true,this.line=-1,this._onDispose.fire(),Xe(this._disposables),this._disposables.length=0);}register(i){return this._disposables.push(i),i}};return e._nextId=1,e})(),Io=Ao,F={},be=F.B;F[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"};F.A={"#":"\xA3"};F.B=void 0;F[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};F.C=F[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};F.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};F.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};F.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};F.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};F.E=F[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};F.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};F.H=F[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};F["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};var Gi=4294967295,Ji=class extends C{constructor(e,t,i,s){super(),this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this._logService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=N.clone(),this.savedCharset=be,this.savedCharsets=[],this.savedGlevel=0,this.savedOriginMode=false,this.savedWraparoundMode=true,this.markers=[],this._nullCell=oe.fromCharData([0,"",1,0]),this._whitespaceCell=oe.fromCharData([0," ",1,32]),this._isClearing=false,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Xi(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops(),this._memoryCleanupQueue=new pt(this._logService),this._register(k(()=>this._memoryCleanupQueue.clear())),this._register(k(()=>this.clearAllMarkers())),this._stringCache=this._register(new Mo);}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new _t),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new _t),this._whitespaceCell}getBlankLine(e,t){return new qe(this._stringCache,this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Gi?Gi:t}fillViewportRows(e){if(this.lines.length===0){e??=N;let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e));}}clear(){this._stringCache.clear(),this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Xi(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops();}resize(e,t){let i=this.getNullCell(N);this._stringCache.clear();let s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);let o=0;if(this._rows<t)for(let n=this._rows;n<t;n++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new qe(this._stringCache,e,i,false)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new qe(this._stringCache,e,i,false)));else for(let n=this._rows;n>t;n--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let n=this.lines.length-r;n>0&&(this.lines.trimStart(n),this.ybase=Math.max(this.ybase-n,0),this.ydisp=Math.max(this.ydisp-n,0),this.savedY=Math.max(this.savedY-n,0)),this.lines.maxLength=r;}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0;}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);if(this._cols=e,this._rows=t,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(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()));}_batchedMemoryCleanup(){let e=true;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=false);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return  true;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t));}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=Ro(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(N),i);if(s.length>0){let r=Lo(this.lines,s);Po(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved);}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(N),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new qe(this._stringCache,e,s,false))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0);}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(N),r=[],o=0;for(let n=this.lines.length-1;n>=0;n--){let h=this.lines.get(n);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let l=[h];for(;h.isWrapped&&n>0;)h=this.lines.get(--n),l.unshift(h);if(!i){let w=this.ybase+this.y;if(w>=n&&w<n+l.length)continue}let a=l[l.length-1].getTrimmedLength(),c=To(l,this._cols,e),d=c.length-l.length,u;this.ybase===0&&this.y!==this.lines.length-1?u=Math.max(0,this.y-this.lines.maxLength+d):u=Math.max(0,this.lines.length-this.lines.maxLength+d);let f=[];for(let w=0;w<d;w++){let fe=this.getBlankLine(N,true);f.push(fe);}f.length>0&&(r.push({start:n+l.length+o,newLines:f}),o+=f.length),l.push(...f);let _=c.length-1,g=c[_];g===0&&(_--,g=c[_]);let v=l.length-d-1,S=a;for(;v>=0;){let w=Math.min(S,g);if(l[_]===void 0)break;if(l[_].copyCellsFrom(l[v],S-w,g-w,w,true),g-=w,g===0&&(_--,g=c[_]),S-=w,S===0){v--;let fe=Math.max(v,0);S=Je(l,fe,this._cols);}}for(let w=0;w<l.length;w++)c[w]<e&&l[w].setCell(c[w],s);let E=d-u;for(;E-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1);}if(r.length>0){let n=[],h=[];for(let g=0;g<this.lines.length;g++)h.push(this.lines.get(g));let l=this.lines.length,a=l-1,c=0,d=r[c];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let u=0;for(let g=Math.min(this.lines.maxLength-1,l+o-1);g>=0;g--)if(d&&d.start>a+u){for(let v=d.newLines.length-1;v>=0;v--)this.lines.set(g--,d.newLines[v]);g++,n.push({index:a+1,amount:d.newLines.length}),u+=d.newLines.length,d=r[++c];}else this.lines.set(g,h[a--]);let f=0;for(let g=n.length-1;g>=0;g--)n[g].index+=f,this.lines.onInsertEmitter.fire(n[g]),f+=n[g].amount;let _=Math.max(0,l+o-this.lines.maxLength);_>0&&this.lines.onTrimEmitter.fire(_);}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return {first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=true;}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=true;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=false;}clearAllMarkers(){this._isClearing=true;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=false;}addMarker(e){let t=new Io(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose();})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount);})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount);})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1);}},Oo=class extends C{constructor(e,t,i){super(),this._optionsService=e,this._bufferService=t,this._logService=i,this._normalBuffer=this._register(new Z),this._altBuffer=this._register(new Z),this._onBufferActivate=this._register(new m),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 Ji(true,this._optionsService,this._bufferService,this._logService),this._normalBuffer.value=this._normal,this._normal.fillViewportRows(),this._alt=new Ji(false,this._optionsService,this._bufferService,this._logService),this._altBuffer.value=this._alt,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);}},ni=class extends C{constructor(e,t){super(),this.isUserScrolling=false,this._onResize=this._register(new m),this.onResize=this._onResize.event,this._onScroll=this._register(new m),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new Oo(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=false;}scroll(e,t=false){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,o=i.ybase+i.scrollBottom;if(i.scrollTop===0){let n=i.lines.isFull;o===i.lines.length-1?n?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(o+1,0,s.clone()),n?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++);}else {let n=o-r+1;i.lines.shiftElements(r+1,n-1,-1),i.lines.set(o,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=true;}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=false);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));}};ni=M([p(0,Y),p(1,Me)],ni);var Be={cols:80,rows:24,showCursorImmediately:false,cursorBlink:false,blinkIntervalDuration:0,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",drawBoldTextInBrightColors:true,documentOverride:null,fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:false,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollbar:{showScrollbar:true},scrollOnEraseInDisplay:false,scrollOnUserInput:true,scrollSensitivity:1,screenReaderMode:false,smoothScrollDuration:0,macOptionIsMeta:false,macOptionClickForcesSelection:false,minimumContrastRatio:1,mouseEventsRequireAlt:false,disableStdin:false,allowProposedApi:false,allowTransparency:false,tabStopWidth:8,theme:{},reflowCursorLine:false,rescaleOverlappingGlyphs:false,rightClickSelectsWord:se,windowOptions:{},windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:true,convertEol:false,termName:"xterm",quirks:{},vtExtensions:{}},Ho=["normal","bold","100","200","300","400","500","600","700","800","900"],No=class extends C{constructor(e){super(),this._onOptionChange=this._register(new m),this.onOptionChange=this._onOptionChange.event;let t=w({},Be);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=w({},t),this._setupOptions(),this._register(k(()=>{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 Be))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Be))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=Be[e]),!Fo(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case "wordSeparator":t||(t=Be[e]);break;case "fontWeight":case "fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Ho.includes(t)?t:Be[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 Fo(e){return e==="block"||e==="underline"||e==="bar"}var Zi=Object.freeze({insertMode:false}),Qi=Object.freeze({applicationCursorKeys:false,applicationKeypad:false,bracketedPasteMode:false,colorSchemeUpdates:false,cursorBlink:void 0,cursorStyle:void 0,origin:false,reverseWraparound:false,sendFocus:false,synchronizedOutput:false,win32InputMode:false,wraparound:true}),es=()=>({flags:0,mainFlags:0,altFlags:0,mainStack:[],altStack:[]}),ai=class extends C{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorHidden=false,this._onData=this._register(new m),this.onData=this._onData.event,this._onUserInput=this._register(new m),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new m),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new m),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.isCursorInitialized=i.rawOptions.showCursorImmediately??false,this.modes=structuredClone(Zi),this.decPrivateModes=structuredClone(Qi),this.kittyKeyboard=es();}reset(){this.modes=structuredClone(Zi),this.decPrivateModes=structuredClone(Qi),this.kittyKeyboard=es();}triggerDataEvent(e,t=false){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));}};ai=M([p(0,V),p(1,Me),p(2,Y)],ai);var ts={NONE:{events:0,restrict:()=>false},X10:{events:1,restrict:e=>e.button===4||e.action!==1?false:(e.ctrl=false,e.alt=false,e.shift=false,true)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>true}};function It(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Ot=String.fromCharCode,is={DEFAULT:e=>{let t=[It(e,false)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ot(t[0])}${Ot(t[1])}${Ot(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return `\x1B[<${It(e,true)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return `\x1B[<${It(e,true)};${e.x};${e.y}${t}`}},Wo=class extends C{constructor(){super(),this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._onProtocolChange=this._register(new m),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(ts))this.addProtocol(e,ts[e]);for(let e of Object.keys(is))this.addEncoding(e,is[e]);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";}setCustomWheelEventHandler(e){this._customWheelEventHandler=e;}allowCustomWheelEvent(e){return this._customWheelEventHandler?this._customWheelEventHandler(e)!==false:true}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"}},ye=class ct{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new m,this.onChange=this._onChange.event;}static extractShouldJoin(t){return (t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=false){return (t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose();}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t);}register(t){this._providers[t.version]=t,this._active||(this.activeVersion=t.version);}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let o=0;o<r;++o){let n=t.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return i+this.wcwidth(n);let a=t.charCodeAt(o);56320<=a&&a<=57343?n=(n-55296)*1024+a-56320+65536:i+=this.wcwidth(a);}let h=this.charProperties(n,s),l=ct.extractWidth(h);ct.extractShouldJoin(h)&&(l-=ct.extractWidth(s)),i+=l,s=h;}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},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]],zo=[[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]],H;function Ko(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return  false;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return  true;return  false}var $o=class{constructor(){if(this.version="6",!H){H=new Uint8Array(65536),H.fill(1),H[0]=0,H.fill(0,1,32),H.fill(0,127,160),H.fill(2,4352,4448),H[9001]=2,H[9002]=2,H.fill(2,11904,42192),H[12351]=1,H.fill(2,44032,55204),H.fill(2,63744,64256),H.fill(2,65040,65050),H.fill(2,65072,65136),H.fill(2,65280,65377),H.fill(2,65504,65511);for(let e=0;e<Ht.length;++e)H.fill(0,Ht[e][0],Ht[e][1]+1);}}wcwidth(e){return e<32?0:e<127?1:e<65536?H[e]:Ko(e,zo)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=ye.extractWidth(t);r===0?s=false:r>i&&(i=r);}return ye.createPropertyValue(0,i,s)}},Uo=class{constructor(){this.glevel=0,this._charsets=[];}get charsets(){return this._charsets}reset(){this.charset=void 0,this._charsets=[],this.glevel=0;}setgLevel(e){this.glevel=e,this.charset=this._charsets[e];}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t);}};function ss(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32);}var Fs=class hi{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=false,this._rejectSubDigits=false,this._digitIsSub=false;}static fromArray(t){let i=new hi;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let o=0;o<r.length;++o)i.addSubParam(r[o]);else i.addParam(r);}return i}clone(){let t=new hi(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r));}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=false,this._rejectSubDigits=false,this._digitIsSub=false;}resetZdm(){this.length=1,this._subParamsLength=0,this._rejectDigits=false,this._rejectSubDigits=false,this._digitIsSub=false,this._subParamsIdx[0]=0,this.params[0]=0;}addParam(t){if(this._digitIsSub=false,this.length>=this.maxLength){this._rejectDigits=true;return}if(t<-1)throw new Error("values less than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>2147483647?2147483647:t;}addSubParam(t){if(this._digitIsSub=true,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=true;return}if(t<-1)throw new Error("values less than -1 are not allowed");this._subParams[this._subParamsLength++]=t>2147483647?2147483647:t,this._subParamsIdx[this.length-1]++;}}hasSubParams(t){return (this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r));}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,2147483647):t;}},We=[],qo=class{constructor(){this._state=0,this._active=We,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:false,loopPosition:0,fallThrough:false};}registerHandler(e,t){this._handlers[e]??=[];let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1);}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e];}setHandlerFallback(e){this._handlerFb=e;}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=We;}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(false);this._stack.paused=false,this._active=We,this._id=-1,this._state=0;}_start(){if(this._active=this._handlers[this._id]||We,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start();}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",De(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);}start(){this.reset(),this._state=1;}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48;}this._state===2&&i-t>0&&this._put(e,t,i);}}end(e,t=true){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else {let i=false,s=this._active.length-1,r=false;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=false),!r&&i===false){for(;s>=0&&(i=this._active[s].end(e),i!==true);s--)if(i instanceof Promise)return this._stack.paused=true,this._stack.loopPosition=s,this._stack.fallThrough=false,i;s--;}for(;s>=0;s--)if(i=this._active[s].end(false),i instanceof Promise)return this._stack.paused=true,this._stack.loopPosition=s,this._stack.fallThrough=true,i}this._active=We,this._id=-1,this._state=0;}}},Ws=class zs{constructor(t){this._handler=t,this._data=new yi(zs._payloadLimit),this._hitLimit=false;}start(){this._data.reset(),this._hitLimit=false;}put(t,i,s){this._hitLimit||this._data.append(De(t,i,s))&&(this._hitLimit=true);}end(t){let i=false;if(this._hitLimit)i=false;else if(t&&(i=this._handler(this._data.toString()),i instanceof Promise))return i.then(s=>(this._data.reset(),this._hitLimit=false,s));return this._data.reset(),this._hitLimit=false,i}};Ws._payloadLimit=1e7;var ee=Ws,ze=[],Vo=class{constructor(){this._handlers=Object.create(null),this._active=ze,this._ident=0,this._handlerFb=()=>{},this._stack={paused:false,loopPosition:0,fallThrough:false};}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ze;}registerHandler(e,t){this._handlers[e]??=[];let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1);}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e];}setHandlerFallback(e){this._handlerFb=e;}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(false);this._stack.paused=false,this._active=ze,this._ident=0;}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ze,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t);}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",De(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);}unhook(e,t=true){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else {let i=false,s=this._active.length-1,r=false;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=false),!r&&i===false){for(;s>=0&&(i=this._active[s].unhook(e),i!==true);s--)if(i instanceof Promise)return this._stack.paused=true,this._stack.loopPosition=s,this._stack.fallThrough=false,i;s--;}for(;s>=0;s--)if(i=this._active[s].unhook(false),i instanceof Promise)return this._stack.paused=true,this._stack.loopPosition=s,this._stack.fallThrough=true,i}this._active=ze,this._ident=0;}},Ve=new Fs;Ve.addParam(0);var Yo=(()=>{let e=class Ks{constructor(i){this._handler=i,this._data=new yi(Ks._payloadLimit),this._params=Ve,this._hitLimit=false;}hook(i){this._params=i.length>1||i.params[0]?i.clone():Ve,this._data.reset(),this._hitLimit=false;}put(i,s,r){this._hitLimit||this._data.append(De(i,s,r))&&(this._hitLimit=true);}unhook(i){let s=false;if(this._hitLimit)s=false;else if(i&&(s=this._handler(this._data.toString(),this._params),s instanceof Promise))return s.then(r=>(this._params=Ve,this._data.reset(),this._hitLimit=false,r));return this._params=Ve,this._data.reset(),this._hitLimit=false,s}};return e._payloadLimit=1e7,e})(),rs=Yo,Ke=[],Xo=class{constructor(){this._handlers=Object.create(null),this._active=Ke,this._ident=0,this._handlerFb=()=>{},this._stack={paused:false,loopPosition:0,fallThrough:false};}registerHandler(e,t){this._handlers[e]??=[];let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1);}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e];}setHandlerFallback(e){this._handlerFb=e;}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ke;}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(false);this._stack.paused=false,this._active=Ke,this._ident=0;}start(e){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ke,!this._active.length)this._handlerFb(this._ident,"START");else for(let t=this._active.length-1;t>=0;t--)this._active[t].start();}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",De(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i);}end(e,t=true){if(!this._active.length)this._handlerFb(this._ident,"END",e);else {let i=false,s=this._active.length-1,r=false;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=false),!r&&i===false){for(;s>=0&&(i=this._active[s].end(e),i!==true);s--)if(i instanceof Promise)return this._stack.paused=true,this._stack.loopPosition=s,this._stack.fallThrough=false,i;s--;}for(;s>=0;s--)if(i=this._active[s].end(false),i instanceof Promise)return this._stack.paused=true,this._stack.loopPosition=s,this._stack.fallThrough=true,i}this._active=Ke,this._ident=0;}},$s=class Us{constructor(t){this._handler=t,this._data=new yi(Us._payloadLimit),this._hitLimit=false;}start(){this._data.reset(),this._hitLimit=false;}put(t,i,s){this._hitLimit||this._data.append(De(t,i,s))&&(this._hitLimit=true);}end(t){let i=false;if(this._hitLimit)i=false;else if(t&&(i=this._handler(this._data.toString()),i instanceof Promise))return i.then(s=>(this._data.reset(),this._hitLimit=false,s));return this._data.reset(),this._hitLimit=false,i}};$s._payloadLimit=1e7;var jo=$s,Go=class{constructor(e){this.table=new Uint16Array(e);}setDefault(e,t){this.table.fill(e<<8|t);}add(e,t,i,s){this.table[t<<8|e]=i<<8|s;}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<8|s;}},q=160,Jo=(function(){let e=new Go(4257),t=Array.apply(null,Array(256)).map((n,h)=>h),i=(n,h)=>t.slice(n,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let o=i(0,17);e.setDefault(1,0),e.addMany(s,0,2,0);for(let n of o)e.addMany([24,26,153,154],n,3,0),e.addMany(i(128,144),n,3,0),e.addMany(i(144,152),n,3,0),e.add(156,n,0,0),e.add(27,n,11,1),e.add(157,n,4,8),e.addMany([152,158],n,0,7),e.add(159,n,11,14),e.add(155,n,11,3),e.add(144,n,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(95,1,11,14),e.addMany(r,14,0,14),e.add(127,14,0,14),e.addMany(i(32,48),14,9,15),e.addMany(i(48,127),14,15,16),e.addMany(i(48,127),15,15,16),e.addMany(r,15,0,15),e.addMany(i(32,48),15,9,15),e.add(127,15,0,15),e.addMany(s,16,16,16),e.addMany(r,16,0,16),e.addMany(i(8,14),16,16,16),e.add(127,16,0,16),e.addMany([27,156,24,26],16,17,0),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(q,0,2,0),e.add(q,8,5,8),e.add(q,6,0,6),e.add(q,11,0,11),e.add(q,13,13,13),e.add(q,16,16,16),e})(),Zo=class extends C{constructor(e=Jo){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 Fs,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._executeHandlersArr=new Array(24).fill(void 0),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(k(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._executeHandlersArr=new Array(24).fill(void 0),this._escHandlers=Object.create(null);})),this._oscParser=this._register(new qo),this._dcsParser=this._register(new Vo),this._apcParser=this._register(new Xo),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>true);}_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>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let o=e.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=o;}}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 r=s.indexOf(t);r!==-1&&s.splice(r,1);}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])];}setEscHandlerFallback(e){this._escHandlerFb=e;}setExecuteHandler(e,t){let i=e.charCodeAt(0);this._executeHandlers[i]=t,i<24&&(this._executeHandlersArr[i]=t);}clearExecuteHandler(e){let t=e.charCodeAt(0);this._executeHandlers[t]&&delete this._executeHandlers[t],t<24&&(this._executeHandlersArr[t]=void 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 r=s.indexOf(t);r!==-1&&s.splice(r,1);}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)];}setCsiHandlerFallback(e){this._csiHandlerFb=e;}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e));}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e);}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e);}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e);}registerApcHandler(e,t){return e.prefix=void 0,this._apcParser.registerHandler(this._identifier(e,[48,126]),t)}clearApcHandler(e){e.prefix=void 0,this._apcParser.clearHandler(this._identifier(e,[48,126]));}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.resetZdm(),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[]);}_preserveStack(e,t,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r;}parse(e,t,i){let s,r,o=0,n;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=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 h=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===false&&l>-1){for(;l>=0&&(n=h[l](this._params),n!==true);l--)if(n instanceof Promise)return this._parseStack.handlerPos=l,n}this._parseStack.handlers=[];break;case 4:if(i===false&&l>-1){for(;l>=0&&(n=h[l](),n!==true);l--)if(n instanceof Promise)return this._parseStack.handlerPos=l,n}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],n=this._dcsParser.unhook(s!==24&&s!==26,i),n)return n;s===27&&(this._parseStack.transition|=1),this._params.resetZdm(),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],n=this._oscParser.end(s!==24&&s!==26,i),n)return n;s===27&&(this._parseStack.transition|=1),this._params.resetZdm(),this._collect=0;break;case 7:if(s=e[this._parseStack.chunkPos],n=this._apcParser.end(s!==24&&s!==26,i),n)return n;s===27&&(this._parseStack.transition|=1),this._params.resetZdm(),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&255;}for(let h=o;h<t;++h){if(s=e[h],s<24&&this.currentState<=6){(this._executeHandlersArr[s]??this._executeHandlerFb)(s),this.precedingJoinState=0;continue}if(s===27&&this.currentState<8&&h+2<t&&e[h+1]===91){this._params.resetZdm(),this._collect=0;let l=h+2,a=e[l];a>=60&&a<=63&&(this._collect=a,l++);let c=false;for(;l<t;l++)if(a=e[l],a>=48&&a<=57)this._params.addDigit(a-48);else if(a===59)this._params.addParam(0);else if(a===58)this._params.addSubParam(-1);else if(a>=64&&a<=126){let d=this._csiHandlers[this._collect<<8|a],u=d?d.length-1:-1;for(;u>=0&&(n=d[u](this._params),n!==true);u--)if(n instanceof Promise)return r=1792,this._preserveStack(3,d,u,r,l),n;u<0&&this._csiHandlerFb(this._collect<<8|a,this._params),this.precedingJoinState=0,h=l,this.currentState=0,c=true;break}else break;c||(h=l-1,this.currentState=4);continue}switch(r=this._transitions.table[this.currentState<<8|(s<q?s:q)],r>>8){case 2:let l=h,a=t-4;for(;l<a&&e[++l]>=32&&(e[l]<=126||e[l]>=q)&&e[++l]>=32&&(e[l]<=126||e[l]>=q)&&e[++l]>=32&&(e[l]<=126||e[l]>=q)&&e[++l]>=32&&(e[l]<=126||e[l]>=q););if(l>=a)for(;l<t&&e[l]>=32&&(e[l]<=126||e[l]>=q);)l++;this._printHandler(e,h,l),h=l-1;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:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:false}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|s],d=c?c.length-1:-1;for(;d>=0&&(n=c[d](this._params),n!==true);d--)if(n instanceof Promise)return this._preserveStack(3,c,d,r,h),n;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(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let u=this._escHandlers[this._collect<<8|s],f=u?u.length-1:-1;for(;f>=0&&(n=u[f](),n!==true);f--)if(n instanceof Promise)return this._preserveStack(4,u,f,r,h),n;f<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.resetZdm(),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let _=h+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<q){this._dcsParser.put(e,h,_),h=_-1;break}break;case 14:if(n=this._dcsParser.unhook(s!==24&&s!==26),n)return this._preserveStack(6,[],0,r,h),n;s===27&&(r|=1),this._params.resetZdm(),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=h+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<q){this._oscParser.put(e,h,_),h=_-1;break}break;case 6:if(n=this._oscParser.end(s!==24&&s!==26),n)return this._preserveStack(5,[],0,r,h),n;s===27&&(r|=1),this._params.resetZdm(),this._collect=0,this.precedingJoinState=0;break;case 15:this._apcParser.start(this._collect<<8|s);break;case 16:for(let _=h+1;;++_)if(!(_<t&&(e[_]>=32&&e[_]<127||e[_]>=8&&e[_]<14||e[_]>=q))){this._apcParser.put(e,h,_),h=_-1;break}break;case 17:if(n=this._apcParser.end(s!==24&&s!==26),n)return this._preserveStack(7,[],0,r,h),n;s===27&&(r|=1),this._params.resetZdm(),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&255;}}},Qo=/^([\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})$/,en=/^[\da-f]+$/;function os(e){if(!e)return;let t=e.toLowerCase();if(t.startsWith("rgb:")){t=t.slice(4);let i=Qo.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return [Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.startsWith("#")&&(t=t.slice(1),en.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?o<<4:i===2?o:i===3?o>>4:o>>8;}return s}}function Nt(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return (s+s).slice(0,3);default:return s+s}}function tn(e,t=16){let[i,s,r]=e;return `rgb:${Nt(i,t)}/${Nt(s,t)}/${Nt(r,t)}`}var sn="6.1.0-beta.290",rn={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function ns(e,t){if(e>24)return t.setWinLines||false;switch(e){case 1:return !!t.restoreWin;case 2:return !!t.minimizeWin;case 3:return !!t.setWinPosition;case 4:return !!t.setWinSizePixels;case 5:return !!t.raiseWin;case 6:return !!t.lowerWin;case 7:return !!t.refreshWin;case 8:return !!t.setWinSizeChars;case 9:return !!t.maximizeWin;case 10:return !!t.fullscreenWin;case 11:return !!t.getWinState;case 13:return !!t.getWinPosition;case 14:return !!t.getWinSizePixels;case 15:return !!t.getScreenSizePixels;case 16:return !!t.getCellSizePixels;case 18:return !!t.getWinSizeChars;case 19:return !!t.getScreenSizeChars;case 20:return !!t.getIconTitle;case 21:return !!t.getWinTitle;case 22:return !!t.pushTitle;case 23:return !!t.popTitle;case 24:return !!t.setWinLines}return  false}var as=0,on=class extends C{constructor(e,t,i,s,r,o,n,h,l=new Zo){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=o,this._mouseStateService=n,this._unicodeService=h,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rr,this._utf8Decoder=new or,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=N.clone(),this._eraseAttrDataInternal=N.clone(),this._onRequestBell=this._register(new m),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new m),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new m),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new m),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new m),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new m),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new m),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new m),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new m),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new m),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new m),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new m),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new m),this.onColor=this._onColor.event,this._onRequestColorSchemeQuery=this._register(new m),this.onRequestColorSchemeQuery=this._onRequestColorSchemeQuery.event,this._parseStack={paused:false,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new li(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(a=>this._activeBuffer=a.activeBuffer)),this._parser.setCsiHandlerFallback((a,c)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(a),params:c.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,c,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:a,action:c,data:d});}),this._parser.setDcsHandlerFallback((a,c,d)=>{c==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(a),action:c,payload:d});}),this._parser.setApcHandlerFallback((a,c,d)=>{this._logService.debug("Unknown APC code: ",{identifier:this._parser.identToString(a),action:c,payload:d});}),this._parser.setPrintHandler((a,c,d)=>this.print(a,c,d)),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,false)),this._parser.registerCsiHandler({prefix:"?",final:"J"},a=>this.eraseInDisplay(a,true)),this._parser.registerCsiHandler({final:"K"},a=>this.eraseInLine(a,false)),this._parser.registerCsiHandler({prefix:"?",final:"K"},a=>this.eraseInLine(a,true)),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,true)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},a=>this.requestMode(a,false)),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(`
`,()=>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 ee(a=>(this.setTitle(a),this.setIconName(a),true))),this._parser.registerOscHandler(1,new ee(a=>this.setIconName(a))),this._parser.registerOscHandler(2,new ee(a=>this.setTitle(a))),this._parser.registerOscHandler(4,new ee(a=>this.setOrReportIndexedColor(a))),this._parser.registerOscHandler(8,new ee(a=>this.setHyperlink(a))),this._parser.registerOscHandler(10,new ee(a=>this.setOrReportFgColor(a))),this._parser.registerOscHandler(11,new ee(a=>this.setOrReportBgColor(a))),this._parser.registerOscHandler(12,new ee(a=>this.setOrReportCursorColor(a))),this._parser.registerOscHandler(104,new ee(a=>this.restoreIndexedColor(a))),this._parser.registerOscHandler(110,new ee(a=>this.restoreFgColor(a))),this._parser.registerOscHandler(111,new ee(a=>this.restoreBgColor(a))),this._parser.registerOscHandler(112,new ee(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 F)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 rs((a,c)=>this.requestStatusString(a,c)));}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=true,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,r)=>{t=setTimeout(()=>r("#SLOW_TIMEOUT"),5e3);});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 5000 ms");});}}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,o=0,n=this._parseStack.paused;if(n){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=false,e.length>131072&&(o=this._parseStack.position+131072);}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<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),n||this._dirtyRowTracker.clearRange(),e.length>131072)for(let a=o;a<e.length;a+=131072){let c=a+131072<e.length?a+131072:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(a,c),this._parseBuffer):this._utf8Decoder.decode(e.subarray(a,c),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,r,d,a),this._logSlowResolvingAsync(i),i}else if(!n){let a=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,a))return this._preserveStack(s,r,a,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)});}print(e,t,i){let s,r,o=this._charsetService.charset,n=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,a=this._coreService.modes.insertMode,c=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);if(!d)return;this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,c);let u=this._parser.precedingJoinState;for(let f=t;f<i;++f){if(s=e[f],s===173)continue;if(s<127&&o){let E=o[String.fromCharCode(s)];E&&(s=E.charCodeAt(0));}let _=this._unicodeService.charProperties(s,u);r=ye.extractWidth(_);let g=ye.extractShouldJoin(_),v=g?ye.extractWidth(u):0;u=_,n&&this._onA11yChar.fire(me(s));let S=this._getCurrentLinkId();if(S&&this._oscLinkService.addLineToLink(S,this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-v>h){if(l){let E=d,w=this._activeBuffer.x-v;if(this._activeBuffer.x=v,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),true)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=true),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),!d)return;for(v>0&&d instanceof qe&&d.copyCellsFrom(E,w,0,v,false);w<h;)E.setCellFromCodepoint(w++,0,1,c);}else if(this._activeBuffer.x=h-1,r===2)continue}if(g&&this._activeBuffer.x){let E=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-E,s,r);for(let w=r-v;--w>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);continue}if(a&&(d.insertCells(this._activeBuffer.x,r-v,this._activeBuffer.getNullCell(c)),d.getWidth(h-1)===2&&d.setCellFromCodepoint(h-1,0,1,c)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,c),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,c);}this._parser.precedingJoinState=u,this._activeBuffer.x<h&&i-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,c),this._dirtyRowTracker.markDirty(this._activeBuffer.y);}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>ns(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):true):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new rs(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new ee(t))}registerApcHandler(e,t){return this._parser.registerApcHandler(e,new jo(t))}bell(){return this._onRequestBell.fire(),true}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=false,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),true}carriageReturn(){return this._activeBuffer.x=0,true}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,true;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=false,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(),true}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return  true;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),true}shiftOut(){return this._charsetService.setgLevel(1),true}shiftIn(){return this._charsetService.setgLevel(0),true}_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)),true}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),true}cursorForward(e){return this._moveCursor(e.params[0]||1,0),true}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),true}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,true}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,true}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),true}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),true}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),true}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),true}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),true}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),true}hVPosition(e){return this.cursorPosition(e),true}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),true}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return  true;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return  true}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return  true;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return  true}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),true}_eraseInBufferLine(e,t,i,s=false,r=false){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o&&(o.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(o.isWrapped=false));}_resetBufferLine(e,t=false){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=false);}eraseInDisplay(e,t=false){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,true,t),this._activeBuffer.x+1>=this._bufferService.cols){let r=this._activeBuffer.lines.get(i+1);r&&(r.isWrapped=false);}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  true}eraseInLine(e,t=false){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,false,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,true,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),true}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return  true;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,true}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return  true;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,true}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)),true}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)),true}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),true}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(N));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),true}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return  true;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=false;}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),true}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return  true;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=false;}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),true}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return  true;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=false;}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),true}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return  true;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=false;}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),true}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)),true}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return  true;let i=e.params[0]||1,s=ye.extractWidth(t),r=this._activeBuffer.x-s,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),n=new Uint32Array(o.length*i),h=0;for(let a=0;a<o.length;){let c=o.codePointAt(a)||0;n[h++]=c,a+=c>65535?2:1;}let l=h;for(let a=1;a<i;++a)n.copyWithin(l,0,h),l+=h;return this.print(n,0,l),true}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")),true}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")),true}sendXtVersion(e){return e.params[0]>0||this._coreService.triggerDataEvent(`\x1BP>|xterm.js(${sn})\x1B\\`),true}_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=true;break;case 20:this._optionsService.options.convertEol=true;break}return  true}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=true;break;case 2:this._charsetService.setgCharset(0,be),this._charsetService.setgCharset(1,be),this._charsetService.setgCharset(2,be),this._charsetService.setgCharset(3,be);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=true,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=true;break;case 12:this._optionsService.rawOptions.quirks?.allowSetCursorBlink&&(this._optionsService.options.cursorBlink=true);break;case 45:this._coreService.decPrivateModes.reverseWraparound=true;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=true,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=true,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=false;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=true,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=true;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=true;break;case 2031:(this._optionsService.rawOptions.vtExtensions?.colorSchemeQuery??true)&&(this._coreService.decPrivateModes.colorSchemeUpdates=true);break;case 9001:this._optionsService.rawOptions.vtExtensions?.win32InputMode&&(this._coreService.decPrivateModes.win32InputMode=true);break}return  true}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=false;break;case 20:this._optionsService.options.convertEol=false;break}return  true}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=false;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=false,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=false;break;case 12:this._optionsService.rawOptions.quirks?.allowSetCursorBlink&&(this._optionsService.options.cursorBlink=false);break;case 45:this._coreService.decPrivateModes.reverseWraparound=false;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=false,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._mouseStateService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=false;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=true;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=true,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=false;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=false,this._onRequestRefreshRows.fire(void 0);break;case 2031:(this._optionsService.rawOptions.vtExtensions?.colorSchemeQuery??true)&&(this._coreService.decPrivateModes.colorSchemeUpdates=false);break;case 9001:this._optionsService.rawOptions.vtExtensions?.win32InputMode&&(this._coreService.decPrivateModes.win32InputMode=false);break}return  true}requestMode(e,t){let i;(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(i||={});let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._mouseStateService,n=this._coreService,{buffers:h,cols:l}=this._bufferService,{active:a,alt:c}=h,d=this._optionsService.rawOptions,u=(g,v)=>(n.triggerDataEvent(`\x1B[${t?"":"?"}${g};${v}$y`),true),f=g=>g?1:2,_=e.params[0];return t?_===2?u(_,4):_===4?u(_,f(n.modes.insertMode)):_===12?u(_,3):_===20?u(_,f(d.convertEol)):u(_,0):_===1?u(_,f(s.applicationCursorKeys)):_===3?u(_,d.windowOptions.setWinLines?l===80?2:l===132?1:0:0):_===6?u(_,f(s.origin)):_===7?u(_,f(s.wraparound)):_===8?u(_,3):_===9?u(_,f(r==="X10")):_===12?u(_,f(d.cursorBlink)):_===25?u(_,f(!n.isCursorHidden)):_===45?u(_,f(s.reverseWraparound)):_===66?u(_,f(s.applicationKeypad)):_===67?u(_,4):_===1e3?u(_,f(r==="VT200")):_===1002?u(_,f(r==="DRAG")):_===1003?u(_,f(r==="ANY")):_===1004?u(_,f(s.sendFocus)):_===1005?u(_,4):_===1006?u(_,f(o==="SGR")):_===1015?u(_,4):_===1016?u(_,f(o==="SGR_PIXELS")):_===1048?u(_,1):_===47||_===1047||_===1049?u(_,f(a===c)):_===2004?u(_,f(s.bracketedPasteMode)):_===2026?u(_,f(s.synchronizedOutput)):_===9001&&this._optionsService.rawOptions.vtExtensions?.win32InputMode?u(_,f(s.win32InputMode)):u(_,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=Ze.fromColorRGB([i,s,r])):t===5&&(e&=-67108864,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,o=0;do{if(s[o+r]=e.params[t+o],e.hasSubParams(t+o)){let n=e.getSubParams(t+o),h=0;do s[1]===5&&(r=1),s[o+h+1+r]=n[h];while(++h<n.length&&h+o+1+r<s.length);break}if(s[1]===5&&o+r>=2||s[1]===2&&o+r>=5)break;s[1]&&(r=1);}while(++o+t<e.length&&o+r<s.length);for(let n=2;n<s.length;++n)s[n]===-1&&(s[n]=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 o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended();}_processSGR0(e){e.fg=N.fg,e.bg=N.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),true;let t=e.length,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-67108864,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-67108864,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-67108864,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-67108864,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=N.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=N.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===221&&(this._optionsService.rawOptions.vtExtensions?.kittySgrBoldFaintControl??true)?s.fg&=-134217729:i===222&&(this._optionsService.rawOptions.vtExtensions?.kittySgrBoldFaintControl??true)?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  true}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  true}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??true)&&this._onRequestColorSchemeQuery.fire();break}return  true}softReset(e){return this._coreService.isCursorHidden=false,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=N.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=false,true}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  true}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)),true}windowOptions(e){if(!ns(e.params[0],this._optionsService.rawOptions.windowOptions))return  true;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>10&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&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  true}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,true}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(),true}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),true}setIconName(e){return this._iconName=e,true}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let o=parseInt(s,10);if(hs(o))if(r==="?")t.push({type:0,index:o});else {let n=os(r);n&&t.push({type:1,index:o,color:n});}}}return t.length&&this._onColor.fire(t),true}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return  true;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?false:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(o=>o.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),true}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),true}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else {let r=os(i[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}]);}return  true}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}]),true;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s],10);hs(r)&&t.push({type:2,index:r});}return t.length&&this._onColor.fire(t),true}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),true}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),true}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),true}nextLine(){return this._activeBuffer.x=0,this.index(),true}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=true,this._onRequestSyncScrollBar.fire(),true}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=false,this._onRequestSyncScrollBar.fire(),true}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,be),true}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),true):(e[0]==="/"||this._charsetService.setgCharset(rn[e[0]],F[e[1]]??be),true)}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(),true}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=true,true}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  true}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),true}reset(){this._curAttrData=N.clone(),this._eraseAttrDataInternal=N.clone();}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),true}screenAlignmentPattern(){let e=new oe;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=false);}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),true}requestStatusString(e,t){let i=n=>(this._coreService.triggerDataEvent(`\x1B${n}\x1B\\`),true),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t);}kittyKeyboardSet(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return  true;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  true}kittyKeyboardQuery(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return  true;let t=this._coreService.kittyKeyboard.flags;return this._coreService.triggerDataEvent(`\x1B[?${t}u`),true}kittyKeyboardPush(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return  true;let t=e.params[0]||0,i=this._coreService.kittyKeyboard,s=this._bufferService.buffer===this._bufferService.buffers.alt?i.altStack:i.mainStack;return s.length>=16&&s.shift(),s.push(i.flags),i.flags=t,true}kittyKeyboardPop(e){if(!this._optionsService.rawOptions.vtExtensions?.kittyKeyboard)return  true;let t=Math.max(1,e.params[0]||1),i=this._coreService.kittyKeyboard,s=this._bufferService.buffer===this._bufferService.buffers.alt?i.altStack:i.mainStack;for(let r=0;r<t&&s.length>0;r++)i.flags=s.pop();return s.length===0&&t>0&&(i.flags=0),true}},li=class{constructor(e){this._bufferService=e,this.clearRange();}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y;}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e);}markRangeDirty(e,t){e>t&&(as=e,e=t,t=as),e<this.start&&(this.start=e),t>this.end&&(this.end=t);}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1);}};li=M([p(0,V)],li);function hs(e){return 0<=e&&e<256}var nn=class extends C{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=false,this._syncCalls=0,this._didUserInput=false,this._innerWriteTimer=this._register(new bt),this._onWriteParsed=this._register(new m),this.onWriteParsed=this._onWriteParsed.event,this._register(k(()=>{this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0;}));}handleUserInput(){this._didUserInput=true;}flushSync(){if(this._store.isDisposed||this._isSyncWriting)return;this._isSyncWriting=true;let e,t=false;for(;e=this._writeBuffer.shift();){t=true,this._action(e);let i=this._callbacks.shift();i&&i();}this._pendingData=0,this._bufferOffset=2147483647,this._writeBuffer.length=0,this._callbacks.length=0,this._isSyncWriting=false,t&&this._onWriteParsed.fire();}writeSync(e,t){if(this._store.isDisposed)return;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=true;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=false,this._syncCalls=0;}write(e,t){if(!this._store.isDisposed){if(this._pendingData>5e7)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=false,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}this._scheduleInnerWrite();}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t);}}_scheduleInnerWrite(e=0,t=true){this._store.isDisposed||this._innerWriteTimer.cancelAndSet(()=>this._innerWrite(e,t),0);}_innerWrite(e=0,t=true){if(this._store.isDisposed)return;let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let n=h=>{this._store.isDisposed||(performance.now()-i>=12?this._scheduleInnerWrite(0,h):this._innerWrite(i,h));};r.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(false))).then(n);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),this._scheduleInnerWrite()):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire();}},ci=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map;}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let h=t.addMarker(t.ybase+t.y),l={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(l,h)),this._dataByLinkId.set(l.id,l),l.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let o=t.addMarker(t.ybase+t.y),n={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(n,o)),this._entriesWithId.set(n.key,n),this._dataByLinkId.set(n.id,n),n.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s));}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return `${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)));}};ci=M([p(0,V)],ci);var ls=false,an=class extends C{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Z),this._onBinary=this._register(new m),this.onBinary=this._onBinary.event,this._onData=this._register(new m),this.onData=this._onData.event,this._onLineFeed=this._register(new m),this.onLineFeed=this._onLineFeed.event,this._onRender=this._register(new m),this.onRender=this._onRender.event,this._onResize=this._register(new m),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new m),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new m),this._instantiationService=new Bo,this.optionsService=this._register(new No(e)),this._instantiationService.setService(Y,this.optionsService),this._logService=this._register(this._instantiationService.createInstance(oi)),this._instantiationService.setService(Me,this._logService),this._bufferService=this._register(this._instantiationService.createInstance(ni)),this._instantiationService.setService(V,this._bufferService),this.coreService=this._register(this._instantiationService.createInstance(ai)),this._instantiationService.setService(ue,this.coreService),this.mouseStateService=this._register(this._instantiationService.createInstance(Wo)),this._instantiationService.setService(mt,this.mouseStateService),this.unicodeService=this._register(this._instantiationService.createInstance(ye)),this.unicodeService.register(new $o),this._instantiationService.setService(lr,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Uo),this._instantiationService.setService(hr,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ci),this._instantiationService.setService(ms,this._oscLinkService),this._inputHandler=this._register(new on(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.mouseStateService,this.unicodeService)),this._register(J.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(J.forward(this._bufferService.onResize,this._onResize)),this._register(J.forward(this.coreService.onData,this._onData)),this._register(J.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(true))),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 nn((t,i)=>this._inputHandler.parse(t,i))),this._register(J.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed));}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new m),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&&!ls&&(this._logService.warn("writeSync is unreliable and will be removed soon."),ls=true),this._writeBuffer.writeSync(e,t);}input(e,t=true){this.coreService.triggerDataEvent(e,t);}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,2),t=Math.max(t,1),this._writeBuffer.flushSync(),this._bufferService.resize(e,t));}scroll(e,t=false){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.mouseStateService.reset();}_handleWindowsPtyOptionChange(){let e=false,t=this.optionsService.rawOptions.windowsPty;t&&t.backend!==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(ss.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ss(this._bufferService),false))),this._windowsWrappingHeuristics.value=k(()=>{for(let t of e)t.dispose();});}}},T=0,hn=class{constructor(e,t){this._getKey=e,this._array=[],this._insertedValues=[],this._isFlushingInserted=false,this._deletedIndices=[],this._isFlushingDeleted=false,this._flushInsertedTask=new pt(t),this._flushDeletedTask=new pt(t);}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=false,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=false;}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e);}_flushInserted(){let e=this._insertedValues.sort((r,o)=>this._getKey(r)-this._getKey(o)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0;}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush();}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return  false;let t=this._getKey(e);if(t===void 0||(T=this._search(t),T===-1)||this._getKey(this._array[T])!==t)return  false;do if(this._array[T]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(T),true;while(++T<this._array.length&&this._getKey(this._array[T])===t);return  false}_flushDeleted(){this._isFlushingDeleted=true;let e=this._deletedIndices.sort((r,o)=>r-o),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=false;}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush();}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(T=this._search(e),!(T<0||T>=this._array.length)&&this._getKey(this._array[T])===e))do yield this._array[T];while(++T<this._array.length&&this._getKey(this._array[T])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(T=this._search(e),!(T<0||T>=this._array.length)&&this._getKey(this._array[T])===e))do t(this._array[T]);while(++T<this._array.length&&this._getKey(this._array[T])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else {for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Ee=0,ht=0,di=class extends C{constructor(e,t){super(),this._logService=e,this._bufferService=t,this._lineCache=this._register(new ln),this._onDecorationRegistered=this._register(new m),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new m),this.onDecorationRemoved=this._onDecorationRemoved.event,this._decorations=new hn(i=>i?.marker.line,this._logService),this._register(k(()=>this.reset())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._lineCache.attachToBufferLines(this._bufferService.buffer.lines);})),this._lineCache.attachToBufferLines(this._bufferService.buffer.lines);}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new cn(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&(this._lineCache.remove(t),this._onDecorationRemoved.fire(t)),i.dispose());});this._decorations.insert(t),this._lineCache.add(t),this._onDecorationRegistered.fire(t);}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear(),this._lineCache.clear();}*getDecorationsAtCell(e,t,i){let s=this._lineCache.getDecorationsOnLine(t);if(s)for(let r of s)Ee=r.options.x??0,ht=Ee+(r.options.width??1),e>=Ee&&e<ht&&(!i||(r.options.layer??"bottom")===i)&&(yield r);}forEachDecorationAtCell(e,t,i,s){let r=this._lineCache.getDecorationsOnLine(t);if(r)for(let o of r)Ee=o.options.x??0,ht=Ee+(o.options.width??1),e>=Ee&&e<ht&&(!i||(o.options.layer??"bottom")===i)&&s(o);}};di=M([p(0,Me),p(1,V)],di);var ln=class extends C{constructor(){super(...arguments),this._decorationsByLine=new Map,this._decorations=new Set,this._bufferLineListeners=this._register(new Z),this._lineIndexSyncTimer=this._register(new fr),this._lineIndexSyncCallbacks=[];}clear(){this._lineIndexSyncCallbacks.length=0,this._lineIndexSyncTimer.cancel(),this._decorationsByLine.clear(),this._decorations.clear();}add(e){this._decorations.add(e),this._addToLineBuckets(e);}remove(e){this._decorations.delete(e),this._removeFromLineBuckets(e);}getDecorationsOnLine(e){return this._decorationsByLine.get(e)}attachToBufferLines(e){let t=new Le;this._bufferLineListeners.value=t,t.add(e.onTrim(i=>this._handleBufferLinesTrim(i))),t.add(e.onInsert(i=>this._handleBufferLinesInsert(i))),t.add(e.onDelete(i=>this._handleBufferLinesDelete(i)));}_getDecorationHeight(e){return e.options.height??1}_addToLineBuckets(e){let t=e.marker.line;if(t<0)return;e._indexedStartLine=t;let i=this._getDecorationHeight(e);for(let s=t;s<t+i;s++){let r=this._decorationsByLine.get(s);r||(r=[],this._decorationsByLine.set(s,r)),r.push(e);}}_removeFromLineBuckets(e){let t=e._indexedStartLine,i=this._getDecorationHeight(e);for(let s=t;s<t+i;s++){let r=this._decorationsByLine.get(s);if(!r)continue;let o=r.indexOf(e);o!==-1&&r.splice(o,1),r.length===0&&this._decorationsByLine.delete(s);}}_reindexDecoration(e){this._removeFromLineBuckets(e),!e.marker.isDisposed&&e.marker.line>=0&&this._addToLineBuckets(e);}_scheduleLineIndexSync(e){this._lineIndexSyncCallbacks.push(e),this._lineIndexSyncTimer.set(()=>{let t=this._lineIndexSyncCallbacks;this._lineIndexSyncCallbacks=[];for(let i of t)i();});}_handleBufferLinesTrim(e){if(e<=0)return;let t=new Map;for(let[i,s]of this._decorationsByLine){let r=i-e;r<0||this._mergeLineBucket(t,r,s);}this._decorationsByLine.clear();for(let[i,s]of t)this._decorationsByLine.set(i,s);for(let i of this._decorations)i.marker.isDisposed||(i._indexedStartLine-=e);}_handleBufferLinesInsert(e){this._scheduleLineIndexSync(()=>this._applyBufferLinesInsert(e));}_handleBufferLinesDelete(e){this._scheduleLineIndexSync(()=>this._applyBufferLinesDelete(e));}_mergeLineBucket(e,t,i){let s=e.get(t);if(s)for(let r=0,o=i.length;r<o;r++)s.push(i[r]);else e.set(t,i.slice());}_applyBufferLinesInsert(e){let{index:t,amount:i}=e,s=[];for(let o of this._decorations){if(o.marker.isDisposed)continue;let n=o._indexedStartLine;n<t&&n+this._getDecorationHeight(o)>t&&(s.push(o),this._removeFromLineBuckets(o));}let r=new Map;for(let[o,n]of this._decorationsByLine){let h=o>=t?o+i:o;this._mergeLineBucket(r,h,n);}this._decorationsByLine.clear();for(let[o,n]of r)this._decorationsByLine.set(o,n);for(let o of this._decorations)o.marker.isDisposed||o._indexedStartLine>=t&&(o._indexedStartLine=o.marker.line);for(let o of s)this._addToLineBuckets(o);}_applyBufferLinesDelete(e){let t=e.index+e.amount,i=new Map;for(let[r,o]of this._decorationsByLine){if(r>=e.index&&r<t)continue;let n=r>=t?r-e.amount:r;this._mergeLineBucket(i,n,o);}this._decorationsByLine.clear();for(let[r,o]of i)this._decorationsByLine.set(r,o);let s=[];for(let r of this._decorations){if(r.marker.isDisposed)continue;let o=r._indexedStartLine,n=this._getDecorationHeight(r);o>=t?r._indexedStartLine=r.marker.line:o<e.index&&o+n>t&&s.push(r);}for(let r of s)this._reindexDecoration(r);}},cn=class extends Le{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new m),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new m),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this._indexedStartLine=e.marker.line,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full");}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=R.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=R.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose();}},dn=1e3,_n=class{constructor(e,t=dn){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=false;}dispose(){this._refreshTimeoutID&&(clearTimeout(this._refreshTimeoutID),this._refreshTimeoutID=void 0),this._additionalRefreshRequested=false;}refresh(e,t,i){this._rowCount=i,e=e??0,t=t??this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._refreshTimeoutID!==void 0&&(clearTimeout(this._refreshTimeoutID),this._refreshTimeoutID=void 0,this._additionalRefreshRequested=false),this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=true,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=false,this._refreshTimeoutID=void 0;},o);}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t);}},vt=class extends C{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new _n(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(b(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(k(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0;}));}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ");}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent=dt.get())));}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0;}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e);}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows);}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let o=i.lines.get(i.ydisp+r),n=[],h=o?.translateToString(true,void 0,void 0,n)||"",l=(i.ydisp+r+1).toString(),a=this._rowElements[r];a&&(h.length===0?(a.textContent="\xA0",this._rowColumns.set(a,[0,1])):(a.textContent=h,this._rowColumns.set(a,n)),a.setAttribute("aria-posinset",l),a.setAttribute("aria-setsize",s),this._alignRowWidth(a));}this._announceCharacters();}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent===dt.get()&&this._clearLiveRegion(),this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="");}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||e.relatedTarget!==s)return;let n,h;if(t===0?(n=i,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(n=this._rowElements.shift(),h=i,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l);}else {let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l);}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation();}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:s.textContent?.length??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let a=h instanceof Text?h.parentNode:h,c=parseInt(a?.getAttribute("aria-posinset"),10)-1;if(isNaN(c))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(a);if(!d)return console.warn("columns is null. Race condition?"),null;let u=l<d.length?d[l]:d.slice(-1)[0]+1;return u>=this._terminal.cols&&(++c,u=0),{row:c,column:u}},o=r(t),n=r(i);if(!(!o||!n)){if(o.row>n.row||o.row===n.row&&o.column>=n.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(n.row-o.row)*this._terminal.cols-o.column+n.column);}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions();}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e]);}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`;}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,i=this._rowColumns.get(e)?.slice(-1)?.[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`;}};vt=M([p(1,ui),p(2,ce),p(3,de)],vt);var _i=class extends C{constructor(e,t,i,s,r){super(),this._element=e,this._mouseCoordsService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=true,this._wasResized=false,this._activeLine=-1,this._onShowLinkUnderline=this._register(new m),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new m),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(k(()=>{Xe(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear();})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=true;})),this._register(b(this._element,"mouseleave",()=>{this._isMouseOut=true,this._clearCurrentLink();})),this._register(b(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(b(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(b(this._element,"mouseup",this._handleMouseUp.bind(this)));}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element);if(!t)return;this._isMouseOut=false;let i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t);}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,false),this._wasResized=false;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,true));}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(s=>{s?.forEach(r=>{r.link.dispose&&r.link.dispose();});}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=false;for(let[s,r]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(s)&&(i=this._checkLinkProviderResult(s,e,i)):r.provideLinks(e.y,o=>{if(this._isMouseOut)return;let n=o?.map(h=>({link:h}));this._activeProviderReplies?.set(s,n),i=this._checkLinkProviderResult(s,e,i),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies);});}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let o=0;o<r.length;o++){let n=r[o],h=n.link.range.start.y<e?0:n.link.range.start.x,l=n.link.range.end.y>e?this._bufferService.cols:n.link.range.end.x;for(let a=h;a<=l;a++){if(i.has(a)){r.splice(o--,1);break}i.add(a);}}}}_checkLinkProviderResult(e,t,i){if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=false;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=true);if(!r&&s){let o=s.find(n=>this._linkAtPosition(n.link,t));o&&(i=true,this._handleNewLink(o));}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let n=this._activeProviderReplies.get(o)?.find(h=>this._linkAtPosition(h.link,t));if(n){i=true,this._handleNewLink(n);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink;}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element);t&&this._mouseDownLink&&un(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text);}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Xe(this._linkCacheDisposables),this._linkCacheDisposables.length=0);}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?true:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?true:e.link.decorations.pointerCursor},isHovered:true},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:i=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i));}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i));}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element);o&&this._askForLink(o,false);}})));}_linkHover(e,t,i){this._currentLink?.state&&(this._currentLink.state.isHovered=true,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,true),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text);}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r);}_linkLeave(e,t,i){this._currentLink?.state&&(this._currentLink.state.isHovered=false,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,false),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text);}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t){let i=this._mouseCoordsService.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return {x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return {x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};_i=M([p(1,wt),p(2,de),p(3,V),p(4,bs)],_i);function un(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var fn=class extends an{constructor(e={}){super(e),this._linkifier=this._register(new Z),this.browser=ks,this._keyDownHandled=false,this._keyDownSeen=false,this._keyPressHandled=false,this._unprocessedDeadKey=false,this._accessibilityManager=this._register(new Z),this._onCursorMove=this._register(new m),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new m),this.onKey=this._onKey.event,this._onSelectionChange=this._register(new m),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new m),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new m),this.onBell=this._onBell.event,this._onFocus=this._register(new m),this._onBlur=this._register(new m),this._onA11yCharEmitter=this._register(new m),this._onA11yTabEmitter=this._register(new m),this._onWillOpen=this._register(new m),this._onDimensionsChange=this._register(new m),this.onDimensionsChange=this._onDimensionsChange.event,this._setup(),this._decorationService=this._instantiationService.createInstance(di),this._instantiationService.setService(Qe,this._decorationService),this._keyboardService=this._instantiationService.createInstance(ri),this._instantiationService.setService(_r,this._keyboardService),this._linkProviderService=this._instantiationService.createInstance(eo),this._instantiationService.setService(bs,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(zt)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(J.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(J.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(J.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(J.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(k(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element);}));}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}get dimensions(){if(!this._renderService)return;let e=this._renderService.dimensions;return {css:{canvas:w({},e.css.canvas),cell:w({},e.css.cell)},device:{canvas:w({},e.device.canvas),cell:w({},e.device.cell),char:w({},e.device.char)}}}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s;switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index;}switch(t.type){case 0:let r=D.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`\x1B]${s};${tn(r)}\x1B\\`);break;case 1:if(i==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=A.toColor(...t.color));else {let o=i;this._themeService.modifyColors(n=>n[o]=A.toColor(...t.color));}break;case 2:this._themeService.restoreColor(t.index);break}}}_reportColorScheme(){if(!this._themeService)return;let e=$.relativeLuminance(this._themeService.colors.background.rgba>>8),t=$.relativeLuminance(this._themeService.colors.foreground.rgba>>8),i=e<t?1:2;this.coreService.triggerDataEvent(`\x1B[?997;${i}n`);}_setup(){super._setup(),this._customKeyEventHandler=void 0;}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:true});}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(vt,this)):this._accessibilityManager.clear();}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent("\x1B[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire();}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent("\x1B[O"),this.element.classList.remove("focus"),this._onBlur.fire();}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),o=this._renderService.dimensions.css.cell.width*r,n=this.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=n+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5";}_initGlobal(){this._bindKeys(),this._register(b(this.element,"copy",t=>{this.hasSelection()&&ir(t,this._selectionService);}));let e=t=>sr(t,this.textarea,this.coreService,this.optionsService);this._register(b(this.textarea,"paste",e)),this._register(b(this.element,"paste",e)),ut?this._register(b(this.element,"mousedown",t=>{t.button===2&&Pi(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord);})):this._register(b(this.element,"contextmenu",t=>{Pi(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord);})),Si&&this._register(b(this.element,"auxclick",t=>{t.button===1&&fs(t,this.textarea,this.screenElement);}));}_bindKeys(){this._register(b(this.textarea,"keyup",e=>this._keyUp(e),true)),this._register(b(this.textarea,"keydown",e=>this._keyDown(e),true)),this._register(b(this.textarea,"keypress",e=>this._keyPress(e),true)),this._register(b(this.textarea,"compositionstart",()=>{this._syncTextArea(),this._compositionHelper.compositionstart(),this._compositionHelper.updateCompositionElements();})),this._register(b(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(b(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(b(this.textarea,"input",e=>this._inputEvent(e),true)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()));}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),this.element.classList.toggle("allow-transparency",this.options.allowTransparency),this._register(this.optionsService.onSpecificOptionChange("allowTransparency",n=>this.element.classList.toggle("allow-transparency",n))),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(b(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Wt.get()),Bs||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Zr,this.textarea,e.ownerDocument.defaultView??window,this._document??(typeof window<"u"?window.document:null))),this._instantiationService.setService(ce,this._coreBrowserService),this._register(b(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(b(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Gt,this._document,this._helperContainer),this._instantiationService.setService(St,this._charSizeService),this._themeService=this._instantiationService.createInstance(si),this._instantiationService.setService(Re,this._themeService),this._register(this._inputHandler.onRequestColorSchemeQuery(()=>this._reportColorScheme())),this._register(this._themeService.onChangeColors(()=>{this.coreService.decPrivateModes.colorSchemeUpdates&&this._reportColorScheme();})),this._characterJoinerService=this._instantiationService.createInstance(gt),this._instantiationService.setService(ws,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(ti,this.rows,this.screenElement)),this._instantiationService.setService(de,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this._register(this._renderService.onDimensionsChange(n=>this._onDimensionsChange.fire({css:{canvas:w({},n.css.canvas),cell:w({},n.css.cell)},device:{canvas:w({},n.device.canvas),cell:w({},n.device.cell),char:w({},n.device.char)}}))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Yt,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseCoordsService=this._instantiationService.createInstance(Jt),this._instantiationService.setService(wt,this._mouseCoordsService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(_i,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element);}catch(n){this._logService.error("onWillOpen handler threw an exception",n);}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea();})),this._register(this.onResize(()=>{this._renderService.handleResize(this.cols,this.rows),this._syncTextArea();})),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(qt,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,false),this.refresh(0,this.rows-1);})),this._selectionService=this._register(this._instantiationService.createInstance(ii,this.element,this.screenElement,s)),this._instantiationService.setService(Ss,this._selectionService),this._mouseService=this._instantiationService.createInstance(ei),this._instantiationService.setService(dr,this._mouseService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select();})),this._register(J.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync();})),this._register(this._instantiationService.createInstance(Vt,this.screenElement)),this._register(b(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),this.mouseStateService.areMouseEventsActive&&!this.options.mouseEventsRequireAlt?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):(this._selectionService.enable(),this.element.classList.remove("enable-mouse-events")),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(vt,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n)));let r=this.options.scrollbar?.showScrollbar??true,o=this.options.scrollbar?.width;r&&o&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ft,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("scrollbar",n=>{let h=(n?.showScrollbar??true)&&!!n?.width;!this._overviewRulerRenderer&&h&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ft,this._viewportElement,this.screenElement)));}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this._mouseService.bindMouse({element:this.element,screenElement:this.screenElement,document:this._document,handleTouchScroll:n=>this._viewport?.handleTouchScroll(n)},n=>this._register(n),()=>this.focus());}_createRenderer(){return this._instantiationService.createInstance(jt,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}refresh(e,t,i=false){this._renderService?.refreshRows(e,t,i);}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select");}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=true,this.refresh(this.buffer.y,this.buffer.y));}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1);}scrollPages(e){this.scrollLines(e*(this.rows-1));}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp);}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,true):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t);}paste(e){us(e,this.textarea,this.coreService,this.optionsService);}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e;}attachCustomWheelEventHandler(e){this.mouseStateService.setCustomWheelEventHandler(e);}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1);}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:false}select(e,t,i){this._selectionService.setSelection(e,t,i);}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return {start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection();}selectAll(){this._selectionService?.selectAll();}selectLines(e,t){this._selectionService?.selectLines(e,t);}_keyDown(e){if(this._keyDownHandled=false,this._keyDownSeen=true,this._customKeyEventHandler&&this._customKeyEventHandler(e)===false)return  false;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(true),false;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=true);let i=this._keyboardService.evaluateKeyDown(e);if(this.updateCursorStyle(e),i.type===3||i.type===2){let r=this.rows-1;return this.scrollLines(i.type===2?-r:r),e.preventDefault(),e.stopPropagation(),false}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&(e.preventDefault(),e.stopPropagation()),!i.key)||!this._keyboardService.useKitty&&!this._keyboardService.useWin32InputMode&&e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return  true;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=false,true;(i.key===""||i.key==="\r")&&(this.textarea.value="");let s=this._keyboardService.useWin32InputMode&&Ft(e);if(this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!s),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return e.preventDefault(),e.stopPropagation(),false;this._keyDownHandled=true;}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){if(this._keyDownSeen=false,this._customKeyEventHandler&&this._customKeyEventHandler(e)===false)return;Ft(e)||this.focus();let t=this._keyboardService.evaluateKeyUp(e);if(t?.key){let i=this._keyboardService.useWin32InputMode&&Ft(e);this.coreService.triggerDataEvent(t.key,!i);}this.updateCursorStyle(e),this._keyPressHandled=false;}_keyPress(e){let t;if(this._keyPressHandled=false,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===false)return  false;if(e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return  false;return !t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?false:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,true),this._keyPressHandled=true,this._unprocessedDeadKey=false,true)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return  false;this._unprocessedDeadKey=false;let t=e.data;return this.coreService.triggerDataEvent(t,true),true}return  false}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t);}_afterResize(e,t){this._charSizeService?.measure();}clear(){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(N));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1);}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._mouseService?.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1,true);}clearTextureAtlas(){this._renderService?.clearTextureAtlas();}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent("\x1B[I"):this.coreService.triggerDataEvent("\x1B[O");}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`\x1B[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`\x1B[6;${r};${s}t`);break}}};function Ft(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18||e.keyCode===91||e.keyCode===92||e.keyCode===93||e.keyCode===224||e.key==="Meta"}var gn=class{constructor(){this._addons=[];}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose();}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:false};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e);}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=true,e.dispose.apply(e.instance),this._addons.splice(t,1);}},pn=class{constructor(e){this._line=e;}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new oe)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},ds=class{constructor(e,t){this._buffer=e,this.type=t;}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new pn(t)}getNullCell(){return new oe}},vn=class extends C{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new m),this.onBufferChange=this._onBufferChange.event,this._normal=new ds(this._core.buffers.normal,"normal"),this._alternate=new ds(this._core.buffers.alt,"alternate"),this._register(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)}},mn=class{constructor(e){this._core=e;}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}registerApcHandler(e,t){return this._core.registerApcHandler(e,t)}},Sn=class{constructor(e){this._core=e;}register(e){this._core.unicodeService.register(e);}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e;}},wn=["cols","rows"],he=0,Mn=class extends C{constructor(e){super(),this._core=this._register(new fn(e)),this._addonManager=this._register(new gn),this._publicOptions=w({},this._core.options);let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r;};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r);}}_checkReadonlyOptions(e){if(wn.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get onDimensionsChange(){return this._core.onDimensionsChange}get element(){return this._core.element}get screenElement(){return this._core.screenElement}get parser(){return this._parser??=new mn(this._core)}get unicode(){return this._checkProposedApi(),new Sn(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer??=this._register(new vn(this._core))}get markers(){return this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.mouseStateService.activeProtocol){case "X10":t="x10";break;case "VT200":t="vt200";break;case "DRAG":t="drag";break;case "ANY":t="any";break}return {applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,showCursor:!this._core.coreService.isCursorHidden,synchronizedOutputMode:e.synchronizedOutput,win32InputMode:e.win32InputMode,wraparoundMode:e.wraparound}}get dimensions(){return this._core.dimensions}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t];}blur(){this._core.blur();}focus(){this._core.focus();}input(e,t=true){this._core.input(e,t);}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t);}open(e){this._core.open(e);}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e);}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e);}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._core.deregisterCharacterJoiner(e);}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i);}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection();}selectAll(){this._core.selectAll();}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t);}dispose(){super.dispose();}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e);}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e);}scrollToTop(){this._core.scrollToTop();}scrollToBottom(){this._core.scrollToBottom();}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e);}clear(){this._core.clear();}write(e,t){this._core.write(e,t);}writeln(e,t){this._core.write(e),this._core.write(`\r
`,t);}paste(e){this._core.paste(e);}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t);}reset(){this._core.reset();}clearTextureAtlas(){this._core.clearTextureAtlas();}loadAddon(e){this._addonManager.loadAddon(this,e);}static get strings(){return {get promptLabel(){return Wt.get()},set promptLabel(e){Wt.set(e);},get tooMuchOutput(){return dt.get()},set tooMuchOutput(e){dt.set(e);}}}_verifyIntegers(...e){for(he of e)if(he===1/0||isNaN(he)||he%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(he of e)if(he&&(he===1/0||isNaN(he)||he%1!==0||he<0))throw new Error("This API only accepts positive integers")}};export{Mn as M,bn as b,kn as k};