From a1da841c45617b9ad5d38f06f665e23810b64b6f Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Wed, 28 Jan 2026 00:08:02 +0000 Subject: [PATCH] Bump version to 0.3.26 and fix terminal resize issues --- pyproject.toml | 2 +- src/textual_webterm/static/js/terminal.js | 2 +- src/textual_webterm/static/js/terminal.ts | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4ece21e..bdad5c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "textual-webterm" -version = "0.3.25" +version = "0.3.26" description = "Serve terminal sessions over the web" authors = ["Will McGugan "] license = "MIT" diff --git a/src/textual_webterm/static/js/terminal.js b/src/textual_webterm/static/js/terminal.js index 1af7159..65976e4 100644 --- a/src/textual_webterm/static/js/terminal.js +++ b/src/textual_webterm/static/js/terminal.js @@ -90,4 +90,4 @@ ${D.join(` `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(q){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),s5&&q&&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(q){let G=this._getMouseBufferCoords(q),Y=this._model.finalSelectionStart,J=this._model.finalSelectionEnd;return!Y||!J||!G?!1:this._areCoordsInSelection(G,Y,J)}isCellInSelection(q,G){let Y=this._model.finalSelectionStart,J=this._model.finalSelectionEnd;return!Y||!J?!1:this._areCoordsInSelection([q,G],Y,J)}_areCoordsInSelection(q,G,Y){return q[1]>G[1]&&q[1]=G[0]&&q[0]=G[0]}_selectWordAtCursor(q,G){let Y=this._linkifier.currentLink?.link?.range;if(Y)return this._model.selectionStart=[Y.start.x-1,Y.start.y-1],this._model.selectionStartLength=f6(Y,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let J=this._getMouseBufferCoords(q);return J?(this._selectWordAt(J,G),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(q,G){this._model.clearSelection(),q=Math.max(q,0),G=Math.min(G,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,q],this._model.selectionEnd=[this._bufferService.cols,G],this.refresh(),this._onSelectionChange.fire()}_handleTrim(q){this._model.handleTrim(q)&&this.refresh()}_getMouseBufferCoords(q){let G=this._mouseService.getCoords(q,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(G)return G[0]--,G[1]--,G[1]+=this._bufferService.buffer.ydisp,G}_getMouseEventScrollAmount(q){let G=n5(this._coreBrowserService.window,q,this._screenElement)[1],Y=this._renderService.dimensions.css.canvas.height;return G>=0&&G<=Y?0:(G>Y&&(G-=Y),G=Math.min(Math.max(G,-Z5),Z5),G/=Z5,G/Math.abs(G)+Math.round(G*(H2-1)))}shouldForceSelection(q){return w4?q.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:q.shiftKey}handleMouseDown(q){if(this._mouseDownTimeStamp=q.timeStamp,!(q.button===2&&this.hasSelection)&&q.button===0){if(!this._enabled){if(!this.shouldForceSelection(q))return;q.stopPropagation()}q.preventDefault(),this._dragScrollAmount=0,this._enabled&&q.shiftKey?this._handleIncrementalClick(q):q.detail===1?this._handleSingleClick(q):q.detail===2?this._handleDoubleClick(q):q.detail===3&&this._handleTripleClick(q),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),D2)}_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(q){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(q))}_handleSingleClick(q){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(q)?3:0,this._model.selectionStart=this._getMouseBufferCoords(q),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let G=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);G&&G.length!==this._model.selectionStart[0]&&G.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(q){this._selectWordAtCursor(q,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(q){let G=this._getMouseBufferCoords(q);G&&(this._activeSelectionMode=2,this._selectLineAt(G[1]))}shouldColumnSelect(q){return q.altKey&&!(w4&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(q){if(q.stopImmediatePropagation(),!this._model.selectionStart)return;let G=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(q),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let Y=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(q.ydisp+this._bufferService.rows,q.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=q.ydisp),this.refresh()}}_handleMouseUp(q){let G=q.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&Gthis._handleTrim(G))}_convertViewportColToCharacterIndex(q,G){let Y=G;for(let J=0;G>=J;J++){let X=q.loadCell(J,this._workCell).getChars().length;this._workCell.getWidth()===0?Y--:X>1&&G!==J&&(Y+=X-1)}return Y}setSelection(q,G,Y){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[q,G],this._model.selectionStartLength=Y,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(q){this._isClickInSelection(q)||(this._selectWordAtCursor(q,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(q,G,Y=!0,J=!0){if(q[0]>=this._bufferService.cols)return;let X=this._bufferService.buffer,Z=X.lines.get(q[1]);if(!Z)return;let V=X.translateBufferLineToString(q[1],!1),j=this._convertViewportColToCharacterIndex(Z,q[0]),z=j,K=q[0]-j,D=0,C=0,R=0,H=0;if(V.charAt(j)===" "){for(;j>0&&V.charAt(j-1)===" ";)j--;for(;z1&&(H+=L-1,z+=L-1);W>0&&j>0&&!this._isCharWordSeparator(Z.loadCell(W-1,this._workCell));){Z.loadCell(W-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(D++,W--):k>1&&(R+=k-1,j-=k-1),j--,W--}for(;B1&&(H+=k-1,z+=k-1),z++,B++}}z++;let M=j+K-D+R,A=Math.min(this._bufferService.cols,z-j+D+C-R-H);if(!(!G&&V.slice(j,z).trim()==="")){if(Y&&M===0&&Z.getCodePoint(0)!==32){let W=X.lines.get(q[1]-1);if(W&&Z.isWrapped&&W.getCodePoint(this._bufferService.cols-1)!==32){let B=this._getWordAt([this._bufferService.cols-1,q[1]-1],!1,!0,!1);if(B){let L=this._bufferService.cols-B.start;M-=L,A+=L}}}if(J&&M+A===this._bufferService.cols&&Z.getCodePoint(this._bufferService.cols-1)!==32){let W=X.lines.get(q[1]+1);if(W?.isWrapped&&W.getCodePoint(0)!==32){let B=this._getWordAt([0,q[1]+1],!1,!1,!0);B&&(A+=B.length)}}return{start:M,length:A}}}_selectWordAt(q,G){let Y=this._getWordAt(q,G);if(Y){for(;Y.start<0;)Y.start+=this._bufferService.cols,q[1]--;this._model.selectionStart=[Y.start,q[1]],this._model.selectionStartLength=Y.length}}_selectToWordAt(q){let G=this._getWordAt(q,!0);if(G){let Y=q[1];for(;G.start<0;)G.start+=this._bufferService.cols,Y--;if(!this._model.areSelectionValuesReversed())for(;G.start+G.length>this._bufferService.cols;)G.length-=this._bufferService.cols,Y++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?G.start:G.start+G.length,Y]}}_isCharWordSeparator(q){return q.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(q.getChars())>=0}_selectLineAt(q){let G=this._bufferService.buffer.getWrappedRangeForLine(q),Y={start:{x:0,y:G.first},end:{x:this._bufferService.cols-1,y:G.last}};this._model.selectionStart=[0,G.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=f6(Y,this._bufferService.cols)}};T5=F0([p(3,v0),p(4,U3),p(5,u5),p(6,m0),p(7,z3),p(8,K3)],T5);var p6=class{constructor(){this._data={}}set(q,G,Y){this._data[q]||(this._data[q]={}),this._data[q][G]=Y}get(q,G){return this._data[q]?this._data[q][G]:void 0}clear(){this._data={}}},g6=class{constructor(){this._color=new p6,this._css=new p6}setCss(q,G,Y){this._css.set(q,G,Y)}getCss(q,G){return this._css.get(q,G)}setColor(q,G,Y){this._color.set(q,G,Y)}getColor(q,G){return this._color.get(q,G)}clear(){this._color.clear(),this._css.clear()}},N0=Object.freeze((()=>{let q=[C0.toColor("#2e3436"),C0.toColor("#cc0000"),C0.toColor("#4e9a06"),C0.toColor("#c4a000"),C0.toColor("#3465a4"),C0.toColor("#75507b"),C0.toColor("#06989a"),C0.toColor("#d3d7cf"),C0.toColor("#555753"),C0.toColor("#ef2929"),C0.toColor("#8ae234"),C0.toColor("#fce94f"),C0.toColor("#729fcf"),C0.toColor("#ad7fa8"),C0.toColor("#34e2e2"),C0.toColor("#eeeeec")],G=[0,95,135,175,215,255];for(let Y=0;Y<216;Y++){let J=G[Y/36%6|0],X=G[Y/6%6|0],Z=G[Y%6];q.push({css:k0.toCss(J,X,Z),rgba:k0.toRgba(J,X,Z)})}for(let Y=0;Y<24;Y++){let J=8+Y*10;q.push({css:k0.toCss(J,J,J),rgba:k0.toRgba(J,J,J)})}return q})()),k3=C0.toColor("#ffffff"),n3=C0.toColor("#000000"),u6=C0.toColor("#ffffff"),d6=n3,d3={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},R2=k3,x5=class extends t{constructor(q){super();this._optionsService=q,this._contrastCache=new g6,this._halfContrastCache=new g6,this._onChangeColors=this._register(new _),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:k3,background:n3,cursor:u6,cursorAccent:d6,selectionForeground:void 0,selectionBackgroundTransparent:d3,selectionBackgroundOpaque:z0.blend(n3,d3),selectionInactiveBackgroundTransparent:d3,selectionInactiveBackgroundOpaque:z0.blend(n3,d3),scrollbarSliderBackground:z0.opacity(k3,0.2),scrollbarSliderHoverBackground:z0.opacity(k3,0.4),scrollbarSliderActiveBackground:z0.opacity(k3,0.5),overviewRulerBorder:k3,ansi:N0.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(q={}){let G=this._colors;if(G.foreground=X0(q.foreground,k3),G.background=X0(q.background,n3),G.cursor=z0.blend(G.background,X0(q.cursor,u6)),G.cursorAccent=z0.blend(G.background,X0(q.cursorAccent,d6)),G.selectionBackgroundTransparent=X0(q.selectionBackground,d3),G.selectionBackgroundOpaque=z0.blend(G.background,G.selectionBackgroundTransparent),G.selectionInactiveBackgroundTransparent=X0(q.selectionInactiveBackground,G.selectionBackgroundTransparent),G.selectionInactiveBackgroundOpaque=z0.blend(G.background,G.selectionInactiveBackgroundTransparent),G.selectionForeground=q.selectionForeground?X0(q.selectionForeground,v6):void 0,G.selectionForeground===v6&&(G.selectionForeground=void 0),z0.isOpaque(G.selectionBackgroundTransparent)&&(G.selectionBackgroundTransparent=z0.opacity(G.selectionBackgroundTransparent,0.3)),z0.isOpaque(G.selectionInactiveBackgroundTransparent)&&(G.selectionInactiveBackgroundTransparent=z0.opacity(G.selectionInactiveBackgroundTransparent,0.3)),G.scrollbarSliderBackground=X0(q.scrollbarSliderBackground,z0.opacity(G.foreground,0.2)),G.scrollbarSliderHoverBackground=X0(q.scrollbarSliderHoverBackground,z0.opacity(G.foreground,0.4)),G.scrollbarSliderActiveBackground=X0(q.scrollbarSliderActiveBackground,z0.opacity(G.foreground,0.5)),G.overviewRulerBorder=X0(q.overviewRulerBorder,R2),G.ansi=N0.slice(),G.ansi[0]=X0(q.black,N0[0]),G.ansi[1]=X0(q.red,N0[1]),G.ansi[2]=X0(q.green,N0[2]),G.ansi[3]=X0(q.yellow,N0[3]),G.ansi[4]=X0(q.blue,N0[4]),G.ansi[5]=X0(q.magenta,N0[5]),G.ansi[6]=X0(q.cyan,N0[6]),G.ansi[7]=X0(q.white,N0[7]),G.ansi[8]=X0(q.brightBlack,N0[8]),G.ansi[9]=X0(q.brightRed,N0[9]),G.ansi[10]=X0(q.brightGreen,N0[10]),G.ansi[11]=X0(q.brightYellow,N0[11]),G.ansi[12]=X0(q.brightBlue,N0[12]),G.ansi[13]=X0(q.brightMagenta,N0[13]),G.ansi[14]=X0(q.brightCyan,N0[14]),G.ansi[15]=X0(q.brightWhite,N0[15]),q.extendedAnsi){let Y=Math.min(G.ansi.length-16,q.extendedAnsi.length);for(let J=0;JZ.index-V.index),J=[];for(let Z of Y){let V=this._services.get(Z.id);if(!V)throw Error(`[createInstance] ${q.name} depends on UNKNOWN service ${Z.id._id}.`);J.push(V)}let X=Y.length>0?Y[0].index:G.length;if(G.length!==X)throw Error(`[createInstance] First service dependency of ${q.name} at position ${X+1} conflicts with ${G.length} static arguments`);return new q(...G,...J)}},k2={trace:0,debug:1,info:2,warn:3,error:4,off:5},B2="xterm.js: ",E5=class extends t{constructor(q){super();this._optionsService=q,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),N2=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=k2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(q){for(let G=0;Gthis._length)for(let G=this._length;G=q;J--)this._array[this._getCyclicIndex(J+Y.length)]=this._array[this._getCyclicIndex(J)];for(let J=0;Jthis._maxLength){let J=this._length+Y.length-this._maxLength;this._startIndex+=J,this._length=this._maxLength,this.onTrimEmitter.fire(J)}else this._length+=Y.length}trimStart(q){q>this._length&&(q=this._length),this._startIndex+=q,this._length-=q,this.onTrimEmitter.fire(q)}shiftElements(q,G,Y){if(!(G<=0)){if(q<0||q>=this._length)throw Error("start argument out of range");if(q+Y<0)throw Error("Cannot shift elements in list beyond index 0");if(Y>0){for(let X=G-1;X>=0;X--)this.set(q+X+Y,this.get(q+X));let J=q+G+Y-this._length;if(J>0)for(this._length+=J;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let J=0;J>22,Y&2097152?this._combined[G].charCodeAt(this._combined[G].length-1):J]}set(G,Y){this._data[G*q0+1]=Y[0],Y[1].length>1?(this._combined[G]=Y[1],this._data[G*q0+0]=G|2097152|Y[2]<<22):this._data[G*q0+0]=Y[1].charCodeAt(0)|Y[2]<<22}getWidth(G){return this._data[G*q0+0]>>22}hasWidth(G){return this._data[G*q0+0]&12582912}getFg(G){return this._data[G*q0+1]}getBg(G){return this._data[G*q0+2]}hasContent(G){return this._data[G*q0+0]&4194303}getCodePoint(G){let Y=this._data[G*q0+0];return Y&2097152?this._combined[G].charCodeAt(this._combined[G].length-1):Y&2097151}isCombined(G){return this._data[G*q0+0]&2097152}getString(G){let Y=this._data[G*q0+0];return Y&2097152?this._combined[G]:Y&2097151?C3(Y&2097151):""}isProtected(G){return this._data[G*q0+2]&536870912}loadCell(G,Y){return $4=G*q0,Y.content=this._data[$4+0],Y.fg=this._data[$4+1],Y.bg=this._data[$4+2],Y.content&2097152&&(Y.combinedData=this._combined[G]),Y.bg&268435456&&(Y.extended=this._extendedAttrs[G]),Y}setCell(G,Y){Y.content&2097152&&(this._combined[G]=Y.combinedData),Y.bg&268435456&&(this._extendedAttrs[G]=Y.extended),this._data[G*q0+0]=Y.content,this._data[G*q0+1]=Y.fg,this._data[G*q0+2]=Y.bg}setCellFromCodepoint(G,Y,J,X){X.bg&268435456&&(this._extendedAttrs[G]=X.extended),this._data[G*q0+0]=Y|J<<22,this._data[G*q0+1]=X.fg,this._data[G*q0+2]=X.bg}addCodepointToCell(G,Y,J){let X=this._data[G*q0+0];X&2097152?this._combined[G]+=C3(Y):X&2097151?(this._combined[G]=C3(X&2097151)+C3(Y),X&=-2097152,X|=2097152):X=Y|4194304,J&&(X&=-12582913,X|=J<<22),this._data[G*q0+0]=X}insertCells(G,Y,J){if(G%=this.length,G&&this.getWidth(G-1)===2&&this.setCellFromCodepoint(G-1,0,1,J),Y=0;--Z)this.setCell(G+Y+Z,this.loadCell(G+Z,X));for(let Z=0;Zthis.length){if(this._data.buffer.byteLength>=J*4)this._data=new Uint32Array(this._data.buffer,0,J);else{let X=new Uint32Array(J);X.set(this._data),this._data=X}for(let X=this.length;X=G&&delete this._combined[j]}let Z=Object.keys(this._extendedAttrs);for(let V=0;V=G&&delete this._extendedAttrs[j]}}return this.length=G,J*4*J5=0;--G)if(this._data[G*q0+0]&4194303)return G+(this._data[G*q0+0]>>22);return 0}getNoBgTrimmedLength(){for(let G=this.length-1;G>=0;--G)if(this._data[G*q0+0]&4194303||this._data[G*q0+2]&50331648)return G+(this._data[G*q0+0]>>22);return 0}copyCellsFrom(G,Y,J,X,Z){let V=G._data;if(Z)for(let z=X-1;z>=0;z--){for(let K=0;K=Y&&(this._combined[K-Y+J]=G._combined[K])}}translateToString(G,Y,J,X){Y=Y??0,J=J??this.length,G&&(J=Math.min(J,this.getTrimmedLength())),X&&(X.length=0);let Z="";for(;Y>22||1}return X&&X.push(Y),Z}};function Q2(q,G,Y,J,X,Z){let V=[];for(let j=0;j=j&&J0&&(W>C||D[W].getTrimmedLength()===0);W--)A++;A>0&&(V.push(j+D.length-A),V.push(A)),j+=D.length-1}return V}function W2(q,G){let Y=[],J=0,X=G[J],Z=0;for(let V=0;VZ4(q,K,G)).reduce((z,K)=>z+K),Z=0,V=0,j=0;for(;jz&&(Z-=z,V++);let K=q[V].getWidth(Z-1)===2;K&&Z--;let D=K?Y-1:Y;J.push(D),j+=D}return J}function Z4(q,G,Y){if(G===q.length-1)return q[G].getTrimmedLength();let J=!q[G].hasContent(Y-1)&&q[G].getWidth(Y-1)===1,X=q[G+1].getWidth(0)===2;return J&&X?Y-1:Y}var a7=class q{constructor(G){this.line=G,this.isDisposed=!1,this._disposables=[],this._id=q._nextId++,this._onDispose=this.register(new _),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),W3(this._disposables),this._disposables.length=0)}register(G){return this._disposables.push(G),G}};a7._nextId=1;var O2=a7,W0={},B3=W0.B;W0[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};W0.A={"#":"£"};W0.B=void 0;W0[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};W0.C=W0[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};W0.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};W0.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};W0.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};W0.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};W0.E=W0[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};W0.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};W0.H=W0[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};W0["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var c6=4294967295,a6=class{constructor(q,G,Y){this._hasScrollback=q,this._optionsService=G,this._bufferService=Y,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=P0.clone(),this.savedCharset=B3,this.markers=[],this._nullCell=c0.fromCharData([0,C7,1,0]),this._whitespaceCell=c0.fromCharData([0,$3,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new I4,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new h6(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(q){return q?(this._nullCell.fg=q.fg,this._nullCell.bg=q.bg,this._nullCell.extended=q.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new W4),this._nullCell}getWhitespaceCell(q){return q?(this._whitespaceCell.fg=q.fg,this._whitespaceCell.bg=q.bg,this._whitespaceCell.extended=q.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new W4),this._whitespaceCell}getBlankLine(q,G){return new s3(this._bufferService.cols,this.getNullCell(q),G)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let q=this.ybase+this.y-this.ydisp;return q>=0&&qc6?c6:G}fillViewportRows(q){if(this.lines.length===0){q===void 0&&(q=P0);let G=this._rows;for(;G--;)this.lines.push(this.getBlankLine(q))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new h6(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(q,G){let Y=this.getNullCell(P0),J=0,X=this._getCorrectBufferLength(G);if(X>this.lines.maxLength&&(this.lines.maxLength=X),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+Z+1?(this.ybase--,Z++,this.ydisp>0&&this.ydisp--):this.lines.push(new s3(q,Y)));else for(let V=this._rows;V>G;V--)this.lines.length>G+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(X0&&(this.lines.trimStart(V),this.ybase=Math.max(this.ybase-V,0),this.ydisp=Math.max(this.ydisp-V,0),this.savedY=Math.max(this.savedY-V,0)),this.lines.maxLength=X}this.x=Math.min(this.x,q-1),this.y=Math.min(this.y,G-1),Z&&(this.y+=Z),this.savedX=Math.min(this.savedX,q-1),this.scrollTop=0}if(this.scrollBottom=G-1,this._isReflowEnabled&&(this._reflow(q,G),this._cols>q))for(let Z=0;Z0.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let q=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,q=!1);let G=0;for(;this._memoryCleanupPosition100)return!0;return q}get _isReflowEnabled(){let q=this._optionsService.rawOptions.windowsPty;return q&&q.buildNumber?this._hasScrollback&&q.backend==="conpty"&&q.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(q,G){this._cols!==q&&(q>this._cols?this._reflowLarger(q,G):this._reflowSmaller(q,G))}_reflowLarger(q,G){let Y=this._optionsService.rawOptions.reflowCursorLine,J=Q2(this.lines,this._cols,q,this.ybase+this.y,this.getNullCell(P0),Y);if(J.length>0){let X=W2(this.lines,J);L2(this.lines,X.layout),this._reflowLargerAdjustViewport(q,G,X.countRemoved)}}_reflowLargerAdjustViewport(q,G,Y){let J=this.getNullCell(P0),X=Y;for(;X-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;V--){let j=this.lines.get(V);if(!j||!j.isWrapped&&j.getTrimmedLength()<=q)continue;let z=[j];for(;j.isWrapped&&V>0;)j=this.lines.get(--V),z.unshift(j);if(!Y){let k=this.ybase+this.y;if(k>=V&&k0&&(X.push({start:V+z.length+Z,newLines:H}),Z+=H.length),z.push(...H);let M=D.length-1,A=D[M];A===0&&(M--,A=D[M]);let W=z.length-C-1,B=K;for(;W>=0;){let k=Math.min(B,A);if(z[M]===void 0)break;if(z[M].copyCellsFrom(z[W],B-k,A-k,k,!0),A-=k,A===0&&(M--,A=D[M]),B-=k,B===0){W--;let P=Math.max(W,0);B=Z4(z,P,this._cols)}}for(let k=0;k0;)this.ybase===0?this.y0){let V=[],j=[];for(let A=0;A=0;A--)if(C&&C.start>K+R){for(let W=C.newLines.length-1;W>=0;W--)this.lines.set(A--,C.newLines[W]);A++,V.push({index:K+1,amount:C.newLines.length}),R+=C.newLines.length,C=X[++D]}else this.lines.set(A,j[K--]);let H=0;for(let A=V.length-1;A>=0;A--)V[A].index+=H,this.lines.onInsertEmitter.fire(V[A]),H+=V[A].amount;let M=Math.max(0,z+Z-this.lines.maxLength);M>0&&this.lines.onTrimEmitter.fire(M)}}translateBufferLineToString(q,G,Y=0,J){let X=this.lines.get(q);return X?X.translateToString(G,Y,J):""}getWrappedRangeForLine(q){let G=q,Y=q;for(;G>0&&this.lines.get(G).isWrapped;)G--;for(;Y+10;);return q>=this._cols?this._cols-1:q<0?0:q}nextStop(q){for(q==null&&(q=this.x);!this.tabs[++q]&&q=this._cols?this._cols-1:q<0?0:q}clearMarkers(q){this._isClearing=!0;for(let G=0;G{G.line-=Y,G.line<0&&G.dispose()})),G.register(this.lines.onInsert((Y)=>{G.line>=Y.index&&(G.line+=Y.amount)})),G.register(this.lines.onDelete((Y)=>{G.line>=Y.index&&G.lineY.index&&(G.line-=Y.amount)})),G.register(G.onDispose(()=>this._removeMarker(G))),G}_removeMarker(q){this._isClearing||this.markers.splice(this.markers.indexOf(q),1)}},S2=class extends t{constructor(q,G){super();this._optionsService=q,this._bufferService=G,this._onBufferActivate=this._register(new _),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 a6(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new a6(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(q){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(q),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(q,G){this._normal.resize(q,G),this._alt.resize(q,G),this.setupTabStops(q)}setupTabStops(q){this._normal.setupTabStops(q),this._alt.setupTabStops(q)}},l7=2,o7=1,b5=class extends t{constructor(q){super();this.isUserScrolling=!1,this._onResize=this._register(new _),this.onResize=this._onResize.event,this._onScroll=this._register(new _),this.onScroll=this._onScroll.event,this.cols=Math.max(q.rawOptions.cols||0,l7),this.rows=Math.max(q.rawOptions.rows||0,o7),this.buffers=this._register(new S2(q,this)),this._register(this.buffers.onBufferActivate((G)=>{this._onScroll.fire(G.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(q,G){let Y=this.cols!==q,J=this.rows!==G;this.cols=q,this.rows=G,this.buffers.resize(q,G),this._onResize.fire({cols:q,rows:G,colsChanged:Y,rowsChanged:J})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(q,G=!1){let Y=this.buffer,J;J=this._cachedBlankLine,(!J||J.length!==this.cols||J.getFg(0)!==q.fg||J.getBg(0)!==q.bg)&&(J=Y.getBlankLine(q,G),this._cachedBlankLine=J),J.isWrapped=G;let X=Y.ybase+Y.scrollTop,Z=Y.ybase+Y.scrollBottom;if(Y.scrollTop===0){let V=Y.lines.isFull;Z===Y.lines.length-1?V?Y.lines.recycle().copyFrom(J):Y.lines.push(J.clone()):Y.lines.splice(Z+1,0,J.clone()),V?this.isUserScrolling&&(Y.ydisp=Math.max(Y.ydisp-1,0)):(Y.ybase++,this.isUserScrolling||Y.ydisp++)}else{let V=Z-X+1;Y.lines.shiftElements(X+1,V-1,-1),Y.lines.set(Z,J.clone())}this.isUserScrolling||(Y.ydisp=Y.ybase),this._onScroll.fire(Y.ydisp)}scrollLines(q,G){let Y=this.buffer;if(q<0){if(Y.ydisp===0)return;this.isUserScrolling=!0}else q+Y.ydisp>=Y.ybase&&(this.isUserScrolling=!1);let J=Y.ydisp;Y.ydisp=Math.max(Math.min(Y.ydisp+q,Y.ybase),0),J!==Y.ydisp&&(G||this._onScroll.fire(Y.ydisp))}};b5=F0([p(0,m0)],b5);var O3={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1000,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:w4,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},y2=["normal","bold","100","200","300","400","500","600","700","800","900"],w2=class extends t{constructor(q){super();this._onOptionChange=this._register(new _),this.onOptionChange=this._onOptionChange.event;let G={...O3};for(let Y in q)if(Y in G)try{let J=q[Y];G[Y]=this._sanitizeAndValidateOption(Y,J)}catch(J){console.error(J)}this.rawOptions=G,this.options={...G},this._setupOptions(),this._register(j0(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(q,G){return this.onOptionChange((Y)=>{Y===q&&G(this.rawOptions[q])})}onMultipleOptionChange(q,G){return this.onOptionChange((Y)=>{q.indexOf(Y)!==-1&&G()})}_setupOptions(){let q=(Y)=>{if(!(Y in O3))throw Error(`No option with key "${Y}"`);return this.rawOptions[Y]},G=(Y,J)=>{if(!(Y in O3))throw Error(`No option with key "${Y}"`);J=this._sanitizeAndValidateOption(Y,J),this.rawOptions[Y]!==J&&(this.rawOptions[Y]=J,this._onOptionChange.fire(Y))};for(let Y in this.rawOptions){let J={get:q.bind(this,Y),set:G.bind(this,Y)};Object.defineProperty(this.options,Y,J)}}_sanitizeAndValidateOption(q,G){switch(q){case"cursorStyle":if(G||(G=O3[q]),!I2(G))throw Error(`"${G}" is not a valid value for ${q}`);break;case"wordSeparator":G||(G=O3[q]);break;case"fontWeight":case"fontWeightBold":if(typeof G=="number"&&1<=G&&G<=1000)break;G=y2.includes(G)?G:O3[q];break;case"cursorWidth":G=Math.floor(G);case"lineHeight":case"tabStopWidth":if(G<1)throw Error(`${q} cannot be less than 1, value: ${G}`);break;case"minimumContrastRatio":G=Math.max(1,Math.min(21,Math.round(G*10)/10));break;case"scrollback":if(G=Math.min(G,4294967295),G<0)throw Error(`${q} cannot be less than 0, value: ${G}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(G<=0)throw Error(`${q} cannot be less than or equal to 0, value: ${G}`);break;case"rows":case"cols":if(!G&&G!==0)throw Error(`${q} must be numeric, value: ${G}`);break;case"windowsPty":G=G??{};break}return G}};function I2(q){return q==="block"||q==="underline"||q==="bar"}function r3(q,G=5){if(typeof q!="object")return q;let Y=Array.isArray(q)?[]:{};for(let J in q)Y[J]=G<=1?q[J]:q[J]&&r3(q[J],G-1);return Y}var l6=Object.freeze({insertMode:!1}),o6=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),v5=class extends t{constructor(q,G,Y){super();this._bufferService=q,this._logService=G,this._optionsService=Y,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new _),this.onData=this._onData.event,this._onUserInput=this._register(new _),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new _),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new _),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=r3(l6),this.decPrivateModes=r3(o6)}reset(){this.modes=r3(l6),this.decPrivateModes=r3(o6)}triggerDataEvent(q,G=!1){if(this._optionsService.rawOptions.disableStdin)return;let Y=this._bufferService.buffer;G&&this._optionsService.rawOptions.scrollOnUserInput&&Y.ybase!==Y.ydisp&&this._onRequestScrollToBottom.fire(),G&&this._onUserInput.fire(),this._logService.debug(`sending data "${q}"`),this._logService.trace("sending data (codes)",()=>q.split("").map((J)=>J.charCodeAt(0))),this._onData.fire(q)}triggerBinaryEvent(q){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${q}"`),this._logService.trace("sending binary (codes)",()=>q.split("").map((G)=>G.charCodeAt(0))),this._onBinary.fire(q))}};v5=F0([p(0,v0),p(1,F7),p(2,m0)],v5);var n6={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:(q)=>q.button===4||q.action!==1?!1:(q.ctrl=!1,q.alt=!1,q.shift=!1,!0)},VT200:{events:19,restrict:(q)=>q.action!==32},DRAG:{events:23,restrict:(q)=>!(q.action===32&&q.button===3)},ANY:{events:31,restrict:(q)=>!0}};function X5(q,G){let Y=(q.ctrl?16:0)|(q.shift?4:0)|(q.alt?8:0);return q.button===4?(Y|=64,Y|=q.action):(Y|=q.button&3,q.button&4&&(Y|=64),q.button&8&&(Y|=128),q.action===32?Y|=32:q.action===0&&!G&&(Y|=3)),Y}var V5=String.fromCharCode,s6={DEFAULT:(q)=>{let G=[X5(q,!1)+32,q.col+32,q.row+32];return G[0]>255||G[1]>255||G[2]>255?"":`\x1B[M${V5(G[0])}${V5(G[1])}${V5(G[2])}`},SGR:(q)=>{let G=q.action===0&&q.button!==4?"m":"M";return`\x1B[<${X5(q,!0)};${q.col};${q.row}${G}`},SGR_PIXELS:(q)=>{let G=q.action===0&&q.button!==4?"m":"M";return`\x1B[<${X5(q,!0)};${q.x};${q.y}${G}`}},m5=class extends t{constructor(q,G,Y){super();this._bufferService=q,this._coreService=G,this._optionsService=Y,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new _),this.onProtocolChange=this._onProtocolChange.event;for(let J of Object.keys(n6))this.addProtocol(J,n6[J]);for(let J of Object.keys(s6))this.addEncoding(J,s6[J]);this.reset()}addProtocol(q,G){this._protocols[q]=G}addEncoding(q,G){this._encodings[q]=G}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(q){if(!this._protocols[q])throw Error(`unknown protocol "${q}"`);this._activeProtocol=q,this._onProtocolChange.fire(this._protocols[q].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(q){if(!this._encodings[q])throw Error(`unknown encoding "${q}"`);this._activeEncoding=q}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(q,G,Y){if(q.deltaY===0||q.shiftKey||G===void 0||Y===void 0)return 0;let J=G/Y,X=this._applyScrollModifier(q.deltaY,q);return q.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(X/=J+0,Math.abs(q.deltaY)<50&&(X*=0.3),this._wheelPartialScroll+=X,X=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):q.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(X*=this._bufferService.rows),X}_applyScrollModifier(q,G){return G.altKey||G.ctrlKey||G.shiftKey?q*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:q*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(q){if(q.col<0||q.col>=this._bufferService.cols||q.row<0||q.row>=this._bufferService.rows||q.button===4&&q.action===32||q.button===3&&q.action!==32||q.button!==4&&(q.action===2||q.action===3)||(q.col++,q.row++,q.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,q,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(q))return!1;let G=this._encodings[this._activeEncoding](q);return G&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(G):this._coreService.triggerDataEvent(G,!0)),this._lastEvent=q,!0}explainEvents(q){return{down:!!(q&1),up:!!(q&2),drag:!!(q&4),move:!!(q&8),wheel:!!(q&16)}}_equalEvents(q,G,Y){if(Y){if(q.x!==G.x||q.y!==G.y)return!1}else if(q.col!==G.col||q.row!==G.row)return!1;return!(q.button!==G.button||q.action!==G.action||q.ctrl!==G.ctrl||q.alt!==G.alt||q.shift!==G.shift)}};m5=F0([p(0,v0),p(1,U3),p(2,m0)],m5);var K5=[[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]],T2=[[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]],Q0;function x2(q,G){let Y=0,J=G.length-1,X;if(qG[J][1])return!1;for(;J>=Y;)if(X=Y+J>>1,q>G[X][1])Y=X+1;else if(q=131072&&q<=196605||q>=196608&&q<=262141?2:1}charProperties(q,G){let Y=this.wcwidth(q),J=Y===0&&G!==0;if(J){let X=N3.extractWidth(G);X===0?J=!1:X>Y&&(Y=X)}return N3.createPropertyValue(0,Y,J)}},N3=class q{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new _,this.onChange=this._onChange.event;let G=new E2;this.register(G),this._active=G.version,this._activeProvider=G}static extractShouldJoin(G){return(G&1)!==0}static extractWidth(G){return G>>1&3}static extractCharKind(G){return G>>3}static createPropertyValue(G,Y,J=!1){return(G&16777215)<<3|(Y&3)<<1|(J?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(G){if(!this._providers[G])throw Error(`unknown Unicode version "${G}"`);this._active=G,this._activeProvider=this._providers[G],this._onChange.fire(G)}register(G){this._providers[G.version]=G}wcwidth(G){return this._activeProvider.wcwidth(G)}getStringCellWidth(G){let Y=0,J=0,X=G.length;for(let Z=0;Z=X)return Y+this.wcwidth(V);let K=G.charCodeAt(Z);56320<=K&&K<=57343?V=(V-55296)*1024+K-56320+65536:Y+=this.wcwidth(K)}let j=this.charProperties(V,J),z=q.extractWidth(j);q.extractShouldJoin(j)&&(z-=q.extractWidth(J)),Y+=z,J=j}return Y}charProperties(G,Y){return this._activeProvider.charProperties(G,Y)}},b2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(q){this.glevel=q,this.charset=this._charsets[q]}setgCharset(q,G){this._charsets[q]=G,this.glevel===q&&(this.charset=G)}};function r6(q){let G=q.buffer.lines.get(q.buffer.ybase+q.buffer.y-1)?.get(q.cols-1),Y=q.buffer.lines.get(q.buffer.ybase+q.buffer.y);Y&&G&&(Y.isWrapped=G[3]!==0&&G[3]!==32)}var h3=2147483647,v2=256,n7=class q{constructor(G=32,Y=32){if(this.maxLength=G,this.maxSubParamsLength=Y,Y>v2)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(G),this.length=0,this._subParams=new Int32Array(Y),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(G),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(G){let Y=new q;if(!G.length)return Y;for(let J=Array.isArray(G[0])?1:0;J>8,X=this._subParamsIdx[Y]&255;X-J>0&&G.push(Array.prototype.slice.call(this._subParams,J,X))}return G}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(G){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(G<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=G>h3?h3:G}addSubParam(G){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(G<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=G>h3?h3:G,this._subParamsIdx[this.length-1]++}}hasSubParams(G){return(this._subParamsIdx[G]&255)-(this._subParamsIdx[G]>>8)>0}getSubParams(G){let Y=this._subParamsIdx[G]>>8,J=this._subParamsIdx[G]&255;return J-Y>0?this._subParams.subarray(Y,J):null}getSubParamsAll(){let G={};for(let Y=0;Y>8,X=this._subParamsIdx[Y]&255;X-J>0&&(G[Y]=this._subParams.slice(J,X))}return G}addDigit(G){let Y;if(this._rejectDigits||!(Y=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let J=this._digitIsSub?this._subParams:this.params,X=J[Y-1];J[Y-1]=~X?Math.min(X*10+G,h3):G}},c3=[],m2=class{constructor(){this._state=0,this._active=c3,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(q,G){this._handlers[q]===void 0&&(this._handlers[q]=[]);let Y=this._handlers[q];return Y.push(G),{dispose:()=>{let J=Y.indexOf(G);J!==-1&&Y.splice(J,1)}}}clearHandler(q){this._handlers[q]&&delete this._handlers[q]}setHandlerFallback(q){this._handlerFb=q}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c3}reset(){if(this._state===2)for(let q=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;q>=0;--q)this._active[q].end(!1);this._stack.paused=!1,this._active=c3,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c3,!this._active.length)this._handlerFb(this._id,"START");else for(let q=this._active.length-1;q>=0;q--)this._active[q].start()}_put(q,G,Y){if(!this._active.length)this._handlerFb(this._id,"PUT",x4(q,G,Y));else for(let J=this._active.length-1;J>=0;J--)this._active[J].put(q,G,Y)}start(){this.reset(),this._state=1}put(q,G,Y){if(this._state!==3){if(this._state===1)for(;G0&&this._put(q,G,Y)}}end(q,G=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",q);else{let Y=!1,J=this._active.length-1,X=!1;if(this._stack.paused&&(J=this._stack.loopPosition-1,Y=G,X=this._stack.fallThrough,this._stack.paused=!1),!X&&Y===!1){for(;J>=0&&(Y=this._active[J].end(q),Y!==!0);J--)if(Y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=J,this._stack.fallThrough=!1,Y;J--}for(;J>=0;J--)if(Y=this._active[J].end(!1),Y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=J,this._stack.fallThrough=!0,Y}this._active=c3,this._id=-1,this._state=0}}},p0=class{constructor(q){this._handler=q,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(q,G,Y){this._hitLimit||(this._data+=x4(q,G,Y),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(q){let G=!1;if(this._hitLimit)G=!1;else if(q&&(G=this._handler(this._data),G instanceof Promise))return G.then((Y)=>(this._data="",this._hitLimit=!1,Y));return this._data="",this._hitLimit=!1,G}},a3=[],_2=class{constructor(){this._handlers=Object.create(null),this._active=a3,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=a3}registerHandler(q,G){this._handlers[q]===void 0&&(this._handlers[q]=[]);let Y=this._handlers[q];return Y.push(G),{dispose:()=>{let J=Y.indexOf(G);J!==-1&&Y.splice(J,1)}}}clearHandler(q){this._handlers[q]&&delete this._handlers[q]}setHandlerFallback(q){this._handlerFb=q}reset(){if(this._active.length)for(let q=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;q>=0;--q)this._active[q].unhook(!1);this._stack.paused=!1,this._active=a3,this._ident=0}hook(q,G){if(this.reset(),this._ident=q,this._active=this._handlers[q]||a3,!this._active.length)this._handlerFb(this._ident,"HOOK",G);else for(let Y=this._active.length-1;Y>=0;Y--)this._active[Y].hook(G)}put(q,G,Y){if(!this._active.length)this._handlerFb(this._ident,"PUT",x4(q,G,Y));else for(let J=this._active.length-1;J>=0;J--)this._active[J].put(q,G,Y)}unhook(q,G=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",q);else{let Y=!1,J=this._active.length-1,X=!1;if(this._stack.paused&&(J=this._stack.loopPosition-1,Y=G,X=this._stack.fallThrough,this._stack.paused=!1),!X&&Y===!1){for(;J>=0&&(Y=this._active[J].unhook(q),Y!==!0);J--)if(Y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=J,this._stack.fallThrough=!1,Y;J--}for(;J>=0;J--)if(Y=this._active[J].unhook(!1),Y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=J,this._stack.fallThrough=!0,Y}this._active=a3,this._ident=0}},i3=new n7;i3.addParam(0);var i6=class{constructor(q){this._handler=q,this._data="",this._params=i3,this._hitLimit=!1}hook(q){this._params=q.length>1||q.params[0]?q.clone():i3,this._data="",this._hitLimit=!1}put(q,G,Y){this._hitLimit||(this._data+=x4(q,G,Y),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(q){let G=!1;if(this._hitLimit)G=!1;else if(q&&(G=this._handler(this._data,this._params),G instanceof Promise))return G.then((Y)=>(this._params=i3,this._data="",this._hitLimit=!1,Y));return this._params=i3,this._data="",this._hitLimit=!1,G}},f2=class{constructor(q){this.table=new Uint8Array(q)}setDefault(q,G){this.table.fill(q<<4|G)}add(q,G,Y,J){this.table[G<<8|q]=Y<<4|J}addMany(q,G,Y,J){for(let X=0;Xz),Y=(j,z)=>G.slice(j,z),J=Y(32,127),X=Y(0,24);X.push(25),X.push.apply(X,Y(28,32));let Z=Y(0,14),V;q.setDefault(1,0),q.addMany(J,0,2,0);for(V in Z)q.addMany([24,26,153,154],V,3,0),q.addMany(Y(128,144),V,3,0),q.addMany(Y(144,152),V,3,0),q.add(156,V,0,0),q.add(27,V,11,1),q.add(157,V,4,8),q.addMany([152,158,159],V,0,7),q.add(155,V,11,3),q.add(144,V,11,9);return q.addMany(X,0,3,0),q.addMany(X,1,3,1),q.add(127,1,0,1),q.addMany(X,8,0,8),q.addMany(X,3,3,3),q.add(127,3,0,3),q.addMany(X,4,3,4),q.add(127,4,0,4),q.addMany(X,6,3,6),q.addMany(X,5,3,5),q.add(127,5,0,5),q.addMany(X,2,3,2),q.add(127,2,0,2),q.add(93,1,4,8),q.addMany(J,8,5,8),q.add(127,8,5,8),q.addMany([156,27,24,26,7],8,6,0),q.addMany(Y(28,32),8,0,8),q.addMany([88,94,95],1,0,7),q.addMany(J,7,0,7),q.addMany(X,7,0,7),q.add(156,7,0,0),q.add(127,7,0,7),q.add(91,1,11,3),q.addMany(Y(64,127),3,7,0),q.addMany(Y(48,60),3,8,4),q.addMany([60,61,62,63],3,9,4),q.addMany(Y(48,60),4,8,4),q.addMany(Y(64,127),4,7,0),q.addMany([60,61,62,63],4,0,6),q.addMany(Y(32,64),6,0,6),q.add(127,6,0,6),q.addMany(Y(64,127),6,0,0),q.addMany(Y(32,48),3,9,5),q.addMany(Y(32,48),5,9,5),q.addMany(Y(48,64),5,0,6),q.addMany(Y(64,127),5,7,0),q.addMany(Y(32,48),4,9,5),q.addMany(Y(32,48),1,9,2),q.addMany(Y(32,48),2,9,2),q.addMany(Y(48,127),2,10,0),q.addMany(Y(48,80),1,10,0),q.addMany(Y(81,88),1,10,0),q.addMany([89,90,92],1,10,0),q.addMany(Y(96,127),1,10,0),q.add(80,1,11,9),q.addMany(X,9,0,9),q.add(127,9,0,9),q.addMany(Y(28,32),9,0,9),q.addMany(Y(32,48),9,9,12),q.addMany(Y(48,60),9,8,10),q.addMany([60,61,62,63],9,9,10),q.addMany(X,11,0,11),q.addMany(Y(32,128),11,0,11),q.addMany(Y(28,32),11,0,11),q.addMany(X,10,0,10),q.add(127,10,0,10),q.addMany(Y(28,32),10,0,10),q.addMany(Y(48,60),10,8,10),q.addMany([60,61,62,63],10,0,11),q.addMany(Y(32,48),10,9,12),q.addMany(X,12,0,12),q.add(127,12,0,12),q.addMany(Y(28,32),12,0,12),q.addMany(Y(32,48),12,9,12),q.addMany(Y(48,64),12,0,11),q.addMany(Y(64,127),12,12,13),q.addMany(Y(64,127),10,12,13),q.addMany(Y(64,127),9,12,13),q.addMany(X,13,13,13),q.addMany(J,13,13,13),q.add(127,13,0,13),q.addMany([27,156,24,26],13,14,0),q.add(h0,0,2,0),q.add(h0,8,5,8),q.add(h0,6,0,6),q.add(h0,11,0,11),q.add(h0,13,13,13),q}(),g2=class extends t{constructor(q=p2){super();this._transitions=q,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new n7,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(G,Y,J)=>{},this._executeHandlerFb=(G)=>{},this._csiHandlerFb=(G,Y)=>{},this._escHandlerFb=(G)=>{},this._errorHandlerFb=(G)=>G,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(j0(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new m2),this._dcsParser=this._register(new _2),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(q,G=[64,126]){let Y=0;if(q.prefix){if(q.prefix.length>1)throw Error("only one byte as prefix supported");if(Y=q.prefix.charCodeAt(0),Y&&60>Y||Y>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(q.intermediates){if(q.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let X=0;XZ||Z>47)throw Error("intermediate must be in range 0x20 .. 0x2f");Y<<=8,Y|=Z}}if(q.final.length!==1)throw Error("final must be a single byte");let J=q.final.charCodeAt(0);if(G[0]>J||J>G[1])throw Error(`final must be in range ${G[0]} .. ${G[1]}`);return Y<<=8,Y|=J,Y}identToString(q){let G=[];for(;q;)G.push(String.fromCharCode(q&255)),q>>=8;return G.reverse().join("")}setPrintHandler(q){this._printHandler=q}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(q,G){let Y=this._identifier(q,[48,126]);this._escHandlers[Y]===void 0&&(this._escHandlers[Y]=[]);let J=this._escHandlers[Y];return J.push(G),{dispose:()=>{let X=J.indexOf(G);X!==-1&&J.splice(X,1)}}}clearEscHandler(q){this._escHandlers[this._identifier(q,[48,126])]&&delete this._escHandlers[this._identifier(q,[48,126])]}setEscHandlerFallback(q){this._escHandlerFb=q}setExecuteHandler(q,G){this._executeHandlers[q.charCodeAt(0)]=G}clearExecuteHandler(q){this._executeHandlers[q.charCodeAt(0)]&&delete this._executeHandlers[q.charCodeAt(0)]}setExecuteHandlerFallback(q){this._executeHandlerFb=q}registerCsiHandler(q,G){let Y=this._identifier(q);this._csiHandlers[Y]===void 0&&(this._csiHandlers[Y]=[]);let J=this._csiHandlers[Y];return J.push(G),{dispose:()=>{let X=J.indexOf(G);X!==-1&&J.splice(X,1)}}}clearCsiHandler(q){this._csiHandlers[this._identifier(q)]&&delete this._csiHandlers[this._identifier(q)]}setCsiHandlerFallback(q){this._csiHandlerFb=q}registerDcsHandler(q,G){return this._dcsParser.registerHandler(this._identifier(q),G)}clearDcsHandler(q){this._dcsParser.clearHandler(this._identifier(q))}setDcsHandlerFallback(q){this._dcsParser.setHandlerFallback(q)}registerOscHandler(q,G){return this._oscParser.registerHandler(q,G)}clearOscHandler(q){this._oscParser.clearHandler(q)}setOscHandlerFallback(q){this._oscParser.setHandlerFallback(q)}setErrorHandler(q){this._errorHandler=q}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(q,G,Y,J,X){this._parseStack.state=q,this._parseStack.handlers=G,this._parseStack.handlerPos=Y,this._parseStack.transition=J,this._parseStack.chunkPos=X}parse(q,G,Y){let J=0,X=0,Z=0,V;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,Z=this._parseStack.chunkPos+1;else{if(Y===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let j=this._parseStack.handlers,z=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(Y===!1&&z>-1){for(;z>=0&&(V=j[z](this._params),V!==!0);z--)if(V instanceof Promise)return this._parseStack.handlerPos=z,V}this._parseStack.handlers=[];break;case 4:if(Y===!1&&z>-1){for(;z>=0&&(V=j[z](),V!==!0);z--)if(V instanceof Promise)return this._parseStack.handlerPos=z,V}this._parseStack.handlers=[];break;case 6:if(J=q[this._parseStack.chunkPos],V=this._dcsParser.unhook(J!==24&&J!==26,Y),V)return V;J===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(J=q[this._parseStack.chunkPos],V=this._oscParser.end(J!==24&&J!==26,Y),V)return V;J===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,Z=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let j=Z;j>4){case 2:for(let R=j+1;;++R){if(R>=G||(J=q[R])<32||J>126&&J=G||(J=q[R])<32||J>126&&J=G||(J=q[R])<32||J>126&&J=G||(J=q[R])<32||J>126&&J=0&&(V=z[K](this._params),V!==!0);K--)if(V instanceof Promise)return this._preserveStack(3,z,K,X,j),V;K<0&&this._csiHandlerFb(this._collect<<8|J,this._params),this.precedingJoinState=0;break;case 8:do switch(J){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(J-48)}while(++j47&&J<60);j--;break;case 9:this._collect<<=8,this._collect|=J;break;case 10:let D=this._escHandlers[this._collect<<8|J],C=D?D.length-1:-1;for(;C>=0&&(V=D[C](),V!==!0);C--)if(V instanceof Promise)return this._preserveStack(4,D,C,X,j),V;C<0&&this._escHandlerFb(this._collect<<8|J),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|J,this._params);break;case 13:for(let R=j+1;;++R)if(R>=G||(J=q[R])===24||J===26||J===27||J>127&&J=G||(J=q[R])<32||J>127&&J>4:Z>>8}return J}}function z5(q,G){let Y=q.toString(16),J=Y.length<2?"0"+Y:Y;switch(G){case 4:return Y[0];case 8:return J;case 12:return(J+J).slice(0,3);default:return J+J}}function h2(q,G=16){let[Y,J,X]=q;return`rgb:${z5(Y,G)}/${z5(J,G)}/${z5(X,G)}`}var c2={"(":0,")":1,"*":2,"+":3,"-":1,".":2},D3=131072,e6=10;function q7(q,G){if(q>24)return G.setWinLines||!1;switch(q){case 1:return!!G.restoreWin;case 2:return!!G.minimizeWin;case 3:return!!G.setWinPosition;case 4:return!!G.setWinSizePixels;case 5:return!!G.raiseWin;case 6:return!!G.lowerWin;case 7:return!!G.refreshWin;case 8:return!!G.setWinSizeChars;case 9:return!!G.maximizeWin;case 10:return!!G.fullscreenWin;case 11:return!!G.getWinState;case 13:return!!G.getWinPosition;case 14:return!!G.getWinSizePixels;case 15:return!!G.getScreenSizePixels;case 16:return!!G.getCellSizePixels;case 18:return!!G.getWinSizeChars;case 19:return!!G.getScreenSizeChars;case 20:return!!G.getIconTitle;case 21:return!!G.getWinTitle;case 22:return!!G.pushTitle;case 23:return!!G.popTitle;case 24:return!!G.setWinLines}return!1}var G7=5000,Y7=0,a2=class extends t{constructor(q,G,Y,J,X,Z,V,j,z=new g2){super();this._bufferService=q,this._charsetService=G,this._coreService=Y,this._logService=J,this._optionsService=X,this._oscLinkService=Z,this._coreMouseService=V,this._unicodeService=j,this._parser=z,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new m8,this._utf8Decoder=new _8,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=P0.clone(),this._eraseAttrDataInternal=P0.clone(),this._onRequestBell=this._register(new _),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new _),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new _),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new _),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new _),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new _),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new _),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new _),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new _),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new _),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new _),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new _),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new _),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new _5(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate((K)=>this._activeBuffer=K.activeBuffer)),this._parser.setCsiHandlerFallback((K,D)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(K),params:D.toArray()})}),this._parser.setEscHandlerFallback((K)=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(K)})}),this._parser.setExecuteHandlerFallback((K)=>{this._logService.debug("Unknown EXECUTE code: ",{code:K})}),this._parser.setOscHandlerFallback((K,D,C)=>{this._logService.debug("Unknown OSC code: ",{identifier:K,action:D,data:C})}),this._parser.setDcsHandlerFallback((K,D,C)=>{D==="HOOK"&&(C=C.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(K),action:D,payload:C})}),this._parser.setPrintHandler((K,D,C)=>this.print(K,D,C)),this._parser.registerCsiHandler({final:"@"},(K)=>this.insertChars(K)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(K)=>this.scrollLeft(K)),this._parser.registerCsiHandler({final:"A"},(K)=>this.cursorUp(K)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(K)=>this.scrollRight(K)),this._parser.registerCsiHandler({final:"B"},(K)=>this.cursorDown(K)),this._parser.registerCsiHandler({final:"C"},(K)=>this.cursorForward(K)),this._parser.registerCsiHandler({final:"D"},(K)=>this.cursorBackward(K)),this._parser.registerCsiHandler({final:"E"},(K)=>this.cursorNextLine(K)),this._parser.registerCsiHandler({final:"F"},(K)=>this.cursorPrecedingLine(K)),this._parser.registerCsiHandler({final:"G"},(K)=>this.cursorCharAbsolute(K)),this._parser.registerCsiHandler({final:"H"},(K)=>this.cursorPosition(K)),this._parser.registerCsiHandler({final:"I"},(K)=>this.cursorForwardTab(K)),this._parser.registerCsiHandler({final:"J"},(K)=>this.eraseInDisplay(K,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},(K)=>this.eraseInDisplay(K,!0)),this._parser.registerCsiHandler({final:"K"},(K)=>this.eraseInLine(K,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},(K)=>this.eraseInLine(K,!0)),this._parser.registerCsiHandler({final:"L"},(K)=>this.insertLines(K)),this._parser.registerCsiHandler({final:"M"},(K)=>this.deleteLines(K)),this._parser.registerCsiHandler({final:"P"},(K)=>this.deleteChars(K)),this._parser.registerCsiHandler({final:"S"},(K)=>this.scrollUp(K)),this._parser.registerCsiHandler({final:"T"},(K)=>this.scrollDown(K)),this._parser.registerCsiHandler({final:"X"},(K)=>this.eraseChars(K)),this._parser.registerCsiHandler({final:"Z"},(K)=>this.cursorBackwardTab(K)),this._parser.registerCsiHandler({final:"`"},(K)=>this.charPosAbsolute(K)),this._parser.registerCsiHandler({final:"a"},(K)=>this.hPositionRelative(K)),this._parser.registerCsiHandler({final:"b"},(K)=>this.repeatPrecedingCharacter(K)),this._parser.registerCsiHandler({final:"c"},(K)=>this.sendDeviceAttributesPrimary(K)),this._parser.registerCsiHandler({prefix:">",final:"c"},(K)=>this.sendDeviceAttributesSecondary(K)),this._parser.registerCsiHandler({final:"d"},(K)=>this.linePosAbsolute(K)),this._parser.registerCsiHandler({final:"e"},(K)=>this.vPositionRelative(K)),this._parser.registerCsiHandler({final:"f"},(K)=>this.hVPosition(K)),this._parser.registerCsiHandler({final:"g"},(K)=>this.tabClear(K)),this._parser.registerCsiHandler({final:"h"},(K)=>this.setMode(K)),this._parser.registerCsiHandler({prefix:"?",final:"h"},(K)=>this.setModePrivate(K)),this._parser.registerCsiHandler({final:"l"},(K)=>this.resetMode(K)),this._parser.registerCsiHandler({prefix:"?",final:"l"},(K)=>this.resetModePrivate(K)),this._parser.registerCsiHandler({final:"m"},(K)=>this.charAttributes(K)),this._parser.registerCsiHandler({final:"n"},(K)=>this.deviceStatus(K)),this._parser.registerCsiHandler({prefix:"?",final:"n"},(K)=>this.deviceStatusPrivate(K)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(K)=>this.softReset(K)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(K)=>this.setCursorStyle(K)),this._parser.registerCsiHandler({final:"r"},(K)=>this.setScrollRegion(K)),this._parser.registerCsiHandler({final:"s"},(K)=>this.saveCursor(K)),this._parser.registerCsiHandler({final:"t"},(K)=>this.windowOptions(K)),this._parser.registerCsiHandler({final:"u"},(K)=>this.restoreCursor(K)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(K)=>this.insertColumns(K)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(K)=>this.deleteColumns(K)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(K)=>this.selectProtected(K)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(K)=>this.requestMode(K,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(K)=>this.requestMode(K,!1)),this._parser.setExecuteHandler(v.BEL,()=>this.bell()),this._parser.setExecuteHandler(v.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(v.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(v.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(v.BS,()=>this.backspace()),this._parser.setExecuteHandler(v.HT,()=>this.tab()),this._parser.setExecuteHandler(v.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(v.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(N4.IND,()=>this.index()),this._parser.setExecuteHandler(N4.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(N4.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new p0((K)=>(this.setTitle(K),this.setIconName(K),!0))),this._parser.registerOscHandler(1,new p0((K)=>this.setIconName(K))),this._parser.registerOscHandler(2,new p0((K)=>this.setTitle(K))),this._parser.registerOscHandler(4,new p0((K)=>this.setOrReportIndexedColor(K))),this._parser.registerOscHandler(8,new p0((K)=>this.setHyperlink(K))),this._parser.registerOscHandler(10,new p0((K)=>this.setOrReportFgColor(K))),this._parser.registerOscHandler(11,new p0((K)=>this.setOrReportBgColor(K))),this._parser.registerOscHandler(12,new p0((K)=>this.setOrReportCursorColor(K))),this._parser.registerOscHandler(104,new p0((K)=>this.restoreIndexedColor(K))),this._parser.registerOscHandler(110,new p0((K)=>this.restoreFgColor(K))),this._parser.registerOscHandler(111,new p0((K)=>this.restoreBgColor(K))),this._parser.registerOscHandler(112,new p0((K)=>this.restoreCursorColor(K))),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 K in W0)this._parser.registerEscHandler({intermediates:"(",final:K},()=>this.selectCharset("("+K)),this._parser.registerEscHandler({intermediates:")",final:K},()=>this.selectCharset(")"+K)),this._parser.registerEscHandler({intermediates:"*",final:K},()=>this.selectCharset("*"+K)),this._parser.registerEscHandler({intermediates:"+",final:K},()=>this.selectCharset("+"+K)),this._parser.registerEscHandler({intermediates:"-",final:K},()=>this.selectCharset("-"+K)),this._parser.registerEscHandler({intermediates:".",final:K},()=>this.selectCharset("."+K)),this._parser.registerEscHandler({intermediates:"/",final:K},()=>this.selectCharset("/"+K));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler((K)=>(this._logService.error("Parsing error: ",K),K)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new i6((K,D)=>this.requestStatusString(K,D)))}getAttrData(){return this._curAttrData}_preserveStack(q,G,Y,J){this._parseStack.paused=!0,this._parseStack.cursorStartX=q,this._parseStack.cursorStartY=G,this._parseStack.decodedLength=Y,this._parseStack.position=J}_logSlowResolvingAsync(q){this._logService.logLevel<=3&&Promise.race([q,new Promise((G,Y)=>setTimeout(()=>Y("#SLOW_TIMEOUT"),G7))]).catch((G)=>{if(G!=="#SLOW_TIMEOUT")throw G;console.warn(`async parser handler taking longer than ${G7} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(q,G){let Y,J=this._activeBuffer.x,X=this._activeBuffer.y,Z=0,V=this._parseStack.paused;if(V){if(Y=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,G))return this._logSlowResolvingAsync(Y),Y;J=this._parseStack.cursorStartX,X=this._parseStack.cursorStartY,this._parseStack.paused=!1,q.length>D3&&(Z=this._parseStack.position+D3)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof q=="string"?` "${q}"`:` "${Array.prototype.map.call(q,(K)=>String.fromCharCode(K)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof q=="string"?q.split("").map((K)=>K.charCodeAt(0)):q),this._parseBuffer.lengthD3)for(let K=Z;K0&&C.getWidth(this._activeBuffer.x-1)===2&&C.setCellFromCodepoint(this._activeBuffer.x-1,0,1,D);let R=this._parser.precedingJoinState;for(let H=G;Hj){if(z){let B=C,L=this._activeBuffer.x-W;for(this._activeBuffer.x=W,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),C=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),W>0&&C instanceof s3&&C.copyCellsFrom(B,L,0,W,!1);L=0;)C.setCellFromCodepoint(this._activeBuffer.x++,0,0,D);continue}if(K&&(C.insertCells(this._activeBuffer.x,X-W,this._activeBuffer.getNullCell(D)),C.getWidth(j-1)===2&&C.setCellFromCodepoint(j-1,0,1,D)),C.setCellFromCodepoint(this._activeBuffer.x++,J,X,D),X>0)for(;--X;)C.setCellFromCodepoint(this._activeBuffer.x++,0,0,D)}this._parser.precedingJoinState=R,this._activeBuffer.x0&&C.getWidth(this._activeBuffer.x)===0&&!C.hasContent(this._activeBuffer.x)&&C.setCellFromCodepoint(this._activeBuffer.x,0,1,D),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(q,G){return q.final==="t"&&!q.prefix&&!q.intermediates?this._parser.registerCsiHandler(q,(Y)=>q7(Y.params[0],this._optionsService.rawOptions.windowOptions)?G(Y):!0):this._parser.registerCsiHandler(q,G)}registerDcsHandler(q,G){return this._parser.registerDcsHandler(q,new i6(G))}registerEscHandler(q,G){return this._parser.registerEscHandler(q,G)}registerOscHandler(q,G){return this._parser.registerOscHandler(q,new p0(G))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);q.hasWidth(this._activeBuffer.x)&&!q.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let q=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-q),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(q=this._bufferService.cols-1){this._activeBuffer.x=Math.min(q,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(q,G){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=q,this._activeBuffer.y=this._activeBuffer.scrollTop+G):(this._activeBuffer.x=q,this._activeBuffer.y=G),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(q,G){this._restrictCursor(),this._setCursor(this._activeBuffer.x+q,this._activeBuffer.y+G)}cursorUp(q){let G=this._activeBuffer.y-this._activeBuffer.scrollTop;return G>=0?this._moveCursor(0,-Math.min(G,q.params[0]||1)):this._moveCursor(0,-(q.params[0]||1)),!0}cursorDown(q){let G=this._activeBuffer.scrollBottom-this._activeBuffer.y;return G>=0?this._moveCursor(0,Math.min(G,q.params[0]||1)):this._moveCursor(0,q.params[0]||1),!0}cursorForward(q){return this._moveCursor(q.params[0]||1,0),!0}cursorBackward(q){return this._moveCursor(-(q.params[0]||1),0),!0}cursorNextLine(q){return this.cursorDown(q),this._activeBuffer.x=0,!0}cursorPrecedingLine(q){return this.cursorUp(q),this._activeBuffer.x=0,!0}cursorCharAbsolute(q){return this._setCursor((q.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(q){return this._setCursor(q.length>=2?(q.params[1]||1)-1:0,(q.params[0]||1)-1),!0}charPosAbsolute(q){return this._setCursor((q.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(q){return this._moveCursor(q.params[0]||1,0),!0}linePosAbsolute(q){return this._setCursor(this._activeBuffer.x,(q.params[0]||1)-1),!0}vPositionRelative(q){return this._moveCursor(0,q.params[0]||1),!0}hVPosition(q){return this.cursorPosition(q),!0}tabClear(q){let G=q.params[0];return G===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:G===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(q){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let G=q.params[0]||1;for(;G--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(q){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let G=q.params[0]||1;for(;G--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(q){let G=q.params[0];return G===1&&(this._curAttrData.bg|=536870912),(G===2||G===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(q,G,Y,J=!1,X=!1){let Z=this._activeBuffer.lines.get(this._activeBuffer.ybase+q);Z.replaceCells(G,Y,this._activeBuffer.getNullCell(this._eraseAttrData()),X),J&&(Z.isWrapped=!1)}_resetBufferLine(q,G=!1){let Y=this._activeBuffer.lines.get(this._activeBuffer.ybase+q);Y&&(Y.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),G),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+q),Y.isWrapped=!1)}eraseInDisplay(q,G=!1){this._restrictCursor(this._bufferService.cols);let Y;switch(q.params[0]){case 0:for(Y=this._activeBuffer.y,this._dirtyRowTracker.markDirty(Y),this._eraseInBufferLine(Y++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,G);Y=this._bufferService.cols&&(this._activeBuffer.lines.get(Y+1).isWrapped=!1);Y--;)this._resetBufferLine(Y,G);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(Y=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,Y-1);Y--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+Y)?.getTrimmedLength(););for(;Y>=0;Y--)this._bufferService.scroll(this._eraseAttrData())}else{for(Y=this._bufferService.rows,this._dirtyRowTracker.markDirty(Y-1);Y--;)this._resetBufferLine(Y,G);this._dirtyRowTracker.markDirty(0)}break;case 3:let J=this._activeBuffer.lines.length-this._bufferService.rows;J>0&&(this._activeBuffer.lines.trimStart(J),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-J,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-J,0),this._onScroll.fire(0));break}return!0}eraseInLine(q,G=!1){switch(this._restrictCursor(this._bufferService.cols),q.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,G);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,G);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,G);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(q){this._restrictCursor();let G=q.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let z=j;for(let K=1;K0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(v.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(v.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(q){return q.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(v.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(v.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(q.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(v.ESC+"[>83;40003;0c")),!0}_is(q){return(this._optionsService.rawOptions.termName+"").indexOf(q)===0}setMode(q){for(let G=0;G(A[A.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",A[A.SET=1]="SET",A[A.RESET=2]="RESET",A[A.PERMANENTLY_SET=3]="PERMANENTLY_SET",A[A.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(Y||={});let J=this._coreService.decPrivateModes,{activeProtocol:X,activeEncoding:Z}=this._coreMouseService,V=this._coreService,{buffers:j,cols:z}=this._bufferService,{active:K,alt:D}=j,C=this._optionsService.rawOptions,R=(A,W)=>(V.triggerDataEvent(`${v.ESC}[${G?"":"?"}${A};${W}$y`),!0),H=(A)=>A?1:2,M=q.params[0];return G?M===2?R(M,4):M===4?R(M,H(V.modes.insertMode)):M===12?R(M,3):M===20?R(M,H(C.convertEol)):R(M,0):M===1?R(M,H(J.applicationCursorKeys)):M===3?R(M,C.windowOptions.setWinLines?z===80?2:z===132?1:0:0):M===6?R(M,H(J.origin)):M===7?R(M,H(J.wraparound)):M===8?R(M,3):M===9?R(M,H(X==="X10")):M===12?R(M,H(C.cursorBlink)):M===25?R(M,H(!V.isCursorHidden)):M===45?R(M,H(J.reverseWraparound)):M===66?R(M,H(J.applicationKeypad)):M===67?R(M,4):M===1000?R(M,H(X==="VT200")):M===1002?R(M,H(X==="DRAG")):M===1003?R(M,H(X==="ANY")):M===1004?R(M,H(J.sendFocus)):M===1005?R(M,4):M===1006?R(M,H(Z==="SGR")):M===1015?R(M,4):M===1016?R(M,H(Z==="SGR_PIXELS")):M===1048?R(M,1):M===47||M===1047||M===1049?R(M,H(K===D)):M===2004?R(M,H(J.bracketedPasteMode)):M===2026?R(M,H(J.synchronizedOutput)):R(M,0)}_updateAttrColor(q,G,Y,J,X){return G===2?(q|=50331648,q&=-16777216,q|=J4.fromColorRGB([Y,J,X])):G===5&&(q&=-50331904,q|=33554432|Y&255),q}_extractColor(q,G,Y){let J=[0,0,-1,0,0,0],X=0,Z=0;do{if(J[Z+X]=q.params[G+Z],q.hasSubParams(G+Z)){let V=q.getSubParams(G+Z),j=0;do J[1]===5&&(X=1),J[Z+j+1+X]=V[j];while(++j=2||J[1]===2&&Z+X>=5)break;J[1]&&(X=1)}while(++Z+G5)&&(q=1),G.extended.underlineStyle=q,G.fg|=268435456,q===0&&(G.fg&=-268435457),G.updateExtended()}_processSGR0(q){q.fg=P0.fg,q.bg=P0.bg,q.extended=q.extended.clone(),q.extended.underlineStyle=0,q.extended.underlineColor&=-67108864,q.updateExtended()}charAttributes(q){if(q.length===1&&q.params[0]===0)return this._processSGR0(this._curAttrData),!0;let G=q.length,Y,J=this._curAttrData;for(let X=0;X=30&&Y<=37?(J.fg&=-50331904,J.fg|=16777216|Y-30):Y>=40&&Y<=47?(J.bg&=-50331904,J.bg|=16777216|Y-40):Y>=90&&Y<=97?(J.fg&=-50331904,J.fg|=16777216|Y-90|8):Y>=100&&Y<=107?(J.bg&=-50331904,J.bg|=16777216|Y-100|8):Y===0?this._processSGR0(J):Y===1?J.fg|=134217728:Y===3?J.bg|=67108864:Y===4?(J.fg|=268435456,this._processUnderline(q.hasSubParams(X)?q.getSubParams(X)[0]:1,J)):Y===5?J.fg|=536870912:Y===7?J.fg|=67108864:Y===8?J.fg|=1073741824:Y===9?J.fg|=2147483648:Y===2?J.bg|=134217728:Y===21?this._processUnderline(2,J):Y===22?(J.fg&=-134217729,J.bg&=-134217729):Y===23?J.bg&=-67108865:Y===24?(J.fg&=-268435457,this._processUnderline(0,J)):Y===25?J.fg&=-536870913:Y===27?J.fg&=-67108865:Y===28?J.fg&=-1073741825:Y===29?J.fg&=2147483647:Y===39?(J.fg&=-67108864,J.fg|=P0.fg&16777215):Y===49?(J.bg&=-67108864,J.bg|=P0.bg&16777215):Y===38||Y===48||Y===58?X+=this._extractColor(q,X,J):Y===53?J.bg|=1073741824:Y===55?J.bg&=-1073741825:Y===59?(J.extended=J.extended.clone(),J.extended.underlineColor=-1,J.updateExtended()):Y===100?(J.fg&=-67108864,J.fg|=P0.fg&16777215,J.bg&=-67108864,J.bg|=P0.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",Y);return!0}deviceStatus(q){switch(q.params[0]){case 5:this._coreService.triggerDataEvent(`${v.ESC}[0n`);break;case 6:let G=this._activeBuffer.y+1,Y=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[${G};${Y}R`);break}return!0}deviceStatusPrivate(q){switch(q.params[0]){case 6:let G=this._activeBuffer.y+1,Y=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${v.ESC}[?${G};${Y}R`);break;case 15:break;case 25:break;case 26:break;case 53:break}return!0}softReset(q){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=P0.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(q){let G=q.length===0?1:q.params[0];if(G===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(G){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 Y=G%2===1;this._coreService.decPrivateModes.cursorBlink=Y}return!0}setScrollRegion(q){let G=q.params[0]||1,Y;return(q.length<2||(Y=q.params[1])>this._bufferService.rows||Y===0)&&(Y=this._bufferService.rows),Y>G&&(this._activeBuffer.scrollTop=G-1,this._activeBuffer.scrollBottom=Y-1,this._setCursor(0,0)),!0}windowOptions(q){if(!q7(q.params[0],this._optionsService.rawOptions.windowOptions))return!0;let G=q.length>1?q.params[1]:0;switch(q.params[0]){case 14:G!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${v.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(G===0||G===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>e6&&this._windowTitleStack.shift()),(G===0||G===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>e6&&this._iconNameStack.shift());break;case 23:(G===0||G===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(G===0||G===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(q){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(q){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(q){return this._windowTitle=q,this._onTitleChange.fire(q),!0}setIconName(q){return this._iconName=q,!0}setOrReportIndexedColor(q){let G=[],Y=q.split(";");for(;Y.length>1;){let J=Y.shift(),X=Y.shift();if(/^\d+$/.exec(J)){let Z=parseInt(J);if(Z7(Z))if(X==="?")G.push({type:0,index:Z});else{let V=t6(X);V&&G.push({type:1,index:Z,color:V})}}}return G.length&&this._onColor.fire(G),!0}setHyperlink(q){let G=q.indexOf(";");if(G===-1)return!0;let Y=q.slice(0,G).trim(),J=q.slice(G+1);return J?this._createHyperlink(Y,J):Y.trim()?!1:this._finishHyperlink()}_createHyperlink(q,G){this._getCurrentLinkId()&&this._finishHyperlink();let Y=q.split(":"),J,X=Y.findIndex((Z)=>Z.startsWith("id="));return X!==-1&&(J=Y[X].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:J,uri:G}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(q,G){let Y=q.split(";");for(let J=0;J=this._specialColors.length);++J,++G)if(Y[J]==="?")this._onColor.fire([{type:0,index:this._specialColors[G]}]);else{let X=t6(Y[J]);X&&this._onColor.fire([{type:1,index:this._specialColors[G],color:X}])}return!0}setOrReportFgColor(q){return this._setOrReportSpecialColor(q,0)}setOrReportBgColor(q){return this._setOrReportSpecialColor(q,1)}setOrReportCursorColor(q){return this._setOrReportSpecialColor(q,2)}restoreIndexedColor(q){if(!q)return this._onColor.fire([{type:2}]),!0;let G=[],Y=q.split(";");for(let J=0;J=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let q=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,q,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=P0.clone(),this._eraseAttrDataInternal=P0.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(q){return this._charsetService.setgLevel(q),!0}screenAlignmentPattern(){let q=new c0;q.content=4194373,q.fg=this._curAttrData.fg,q.bg=this._curAttrData.bg,this._setCursor(0,0);for(let G=0;G(this._coreService.triggerDataEvent(`${v.ESC}${V}${v.ESC}\\`),!0),J=this._bufferService.buffer,X=this._optionsService.rawOptions;return Y(q==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:q==='"p'?'P1$r61;1"p':q==="r"?`P1$r${J.scrollTop+1};${J.scrollBottom+1}r`:q==="m"?"P1$r0m":q===" q"?`P1$r${{block:2,underline:4,bar:6}[X.cursorStyle]-(X.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(q,G){this._dirtyRowTracker.markRangeDirty(q,G)}},_5=class{constructor(q){this._bufferService=q,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(q){qthis.end&&(this.end=q)}markRangeDirty(q,G){q>G&&(Y7=q,q=G,G=Y7),qthis.end&&(this.end=G)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};_5=F0([p(0,v0)],_5);function Z7(q){return 0<=q&&q<256}var l2=50000000,J7=12,o2=50,n2=class extends t{constructor(q){super();this._action=q,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new _),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(q,G){if(G!==void 0&&this._syncCalls>G){this._syncCalls=0;return}if(this._pendingData+=q.length,this._writeBuffer.push(q),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let Y;for(;Y=this._writeBuffer.shift();){this._action(Y);let J=this._callbacks.shift();J&&J()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(q,G){if(this._pendingData>l2)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=q.length,this._writeBuffer.push(q),this._callbacks.push(G),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=q.length,this._writeBuffer.push(q),this._callbacks.push(G)}_innerWrite(q=0,G=!0){let Y=q||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let J=this._writeBuffer[this._bufferOffset],X=this._action(J,G);if(X){let V=(j)=>performance.now()-Y>=J7?setTimeout(()=>this._innerWrite(0,j)):this._innerWrite(Y,j);X.catch((j)=>(queueMicrotask(()=>{throw j}),Promise.resolve(!1))).then(V);return}let Z=this._callbacks[this._bufferOffset];if(Z&&Z(),this._bufferOffset++,this._pendingData-=J.length,performance.now()-Y>=J7)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>o2&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},f5=class{constructor(q){this._bufferService=q,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(q){let G=this._bufferService.buffer;if(q.id===void 0){let j=G.addMarker(G.ybase+G.y),z={data:q,id:this._nextId++,lines:[j]};return j.onDispose(()=>this._removeMarkerFromLink(z,j)),this._dataByLinkId.set(z.id,z),z.id}let Y=q,J=this._getEntryIdKey(Y),X=this._entriesWithId.get(J);if(X)return this.addLineToLink(X.id,G.ybase+G.y),X.id;let Z=G.addMarker(G.ybase+G.y),V={id:this._nextId++,key:this._getEntryIdKey(Y),data:Y,lines:[Z]};return Z.onDispose(()=>this._removeMarkerFromLink(V,Z)),this._entriesWithId.set(V.key,V),this._dataByLinkId.set(V.id,V),V.id}addLineToLink(q,G){let Y=this._dataByLinkId.get(q);if(Y&&Y.lines.every((J)=>J.line!==G)){let J=this._bufferService.buffer.addMarker(G);Y.lines.push(J),J.onDispose(()=>this._removeMarkerFromLink(Y,J))}}getLinkData(q){return this._dataByLinkId.get(q)?.data}_getEntryIdKey(q){return`${q.id};;${q.uri}`}_removeMarkerFromLink(q,G){let Y=q.lines.indexOf(G);Y!==-1&&(q.lines.splice(Y,1),q.lines.length===0&&(q.data.id!==void 0&&this._entriesWithId.delete(q.key),this._dataByLinkId.delete(q.id)))}};f5=F0([p(0,v0)],f5);var X7=!1,s2=class extends t{constructor(q){super();this._windowsWrappingHeuristics=this._register(new y3),this._onBinary=this._register(new _),this.onBinary=this._onBinary.event,this._onData=this._register(new _),this.onData=this._onData.event,this._onLineFeed=this._register(new _),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new _),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new _),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new _),this._instantiationService=new P2,this.optionsService=this._register(new w2(q)),this._instantiationService.setService(m0,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(b5)),this._instantiationService.setService(v0,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(E5)),this._instantiationService.setService(F7,this._logService),this.coreService=this._register(this._instantiationService.createInstance(v5)),this._instantiationService.setService(U3,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(m5)),this._instantiationService.setService($7,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(N3)),this._instantiationService.setService(u8,this.unicodeService),this._charsetService=this._instantiationService.createInstance(b2),this._instantiationService.setService(g8,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(f5),this._instantiationService.setService(R7,this._oscLinkService),this._inputHandler=this._register(new a2(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(I0.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(I0.forward(this._bufferService.onResize,this._onResize)),this._register(I0.forward(this.coreService.onData,this._onData)),this._register(I0.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new n2((G,Y)=>this._inputHandler.parse(G,Y))),this._register(I0.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new _),this._onScroll.event((q)=>{this._onScrollApi?.fire(q.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(q){for(let G in q)this.optionsService.options[G]=q[G]}write(q,G){this._writeBuffer.write(q,G)}writeSync(q,G){this._logService.logLevel<=3&&!X7&&(this._logService.warn("writeSync is unreliable and will be removed soon."),X7=!0),this._writeBuffer.writeSync(q,G)}input(q,G=!0){this.coreService.triggerDataEvent(q,G)}resize(q,G){isNaN(q)||isNaN(G)||(q=Math.max(q,l7),G=Math.max(G,o7),this._bufferService.resize(q,G))}scroll(q,G=!1){this._bufferService.scroll(q,G)}scrollLines(q,G){this._bufferService.scrollLines(q,G)}scrollPages(q){this.scrollLines(q*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(q){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(q){let G=q-this._bufferService.buffer.ydisp;G!==0&&this.scrollLines(G)}registerEscHandler(q,G){return this._inputHandler.registerEscHandler(q,G)}registerDcsHandler(q,G){return this._inputHandler.registerDcsHandler(q,G)}registerCsiHandler(q,G){return this._inputHandler.registerCsiHandler(q,G)}registerOscHandler(q,G){return this._inputHandler.registerOscHandler(q,G)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let q=!1,G=this.optionsService.rawOptions.windowsPty;G&&G.buildNumber!==void 0&&G.buildNumber!==void 0?q=G.backend==="conpty"&&G.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(q=!0),q?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let q=[];q.push(this.onLineFeed(r6.bind(null,this._bufferService))),q.push(this.registerCsiHandler({final:"H"},()=>(r6(this._bufferService),!1))),this._windowsWrappingHeuristics.value=j0(()=>{for(let G of q)G.dispose()})}}},r2={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 i2(q,G,Y,J){let X={type:0,cancel:!1,key:void 0},Z=(q.shiftKey?1:0)|(q.altKey?2:0)|(q.ctrlKey?4:0)|(q.metaKey?8:0);switch(q.keyCode){case 0:q.key==="UIKeyInputUpArrow"?G?X.key=v.ESC+"OA":X.key=v.ESC+"[A":q.key==="UIKeyInputLeftArrow"?G?X.key=v.ESC+"OD":X.key=v.ESC+"[D":q.key==="UIKeyInputRightArrow"?G?X.key=v.ESC+"OC":X.key=v.ESC+"[C":q.key==="UIKeyInputDownArrow"&&(G?X.key=v.ESC+"OB":X.key=v.ESC+"[B");break;case 8:X.key=q.ctrlKey?"\b":v.DEL,q.altKey&&(X.key=v.ESC+X.key);break;case 9:if(q.shiftKey){X.key=v.ESC+"[Z";break}X.key=v.HT,X.cancel=!0;break;case 13:X.key=q.altKey?v.ESC+v.CR:v.CR,X.cancel=!0;break;case 27:X.key=v.ESC,q.altKey&&(X.key=v.ESC+v.ESC),X.cancel=!0;break;case 37:if(q.metaKey)break;Z?X.key=v.ESC+"[1;"+(Z+1)+"D":G?X.key=v.ESC+"OD":X.key=v.ESC+"[D";break;case 39:if(q.metaKey)break;Z?X.key=v.ESC+"[1;"+(Z+1)+"C":G?X.key=v.ESC+"OC":X.key=v.ESC+"[C";break;case 38:if(q.metaKey)break;Z?X.key=v.ESC+"[1;"+(Z+1)+"A":G?X.key=v.ESC+"OA":X.key=v.ESC+"[A";break;case 40:if(q.metaKey)break;Z?X.key=v.ESC+"[1;"+(Z+1)+"B":G?X.key=v.ESC+"OB":X.key=v.ESC+"[B";break;case 45:!q.shiftKey&&!q.ctrlKey&&(X.key=v.ESC+"[2~");break;case 46:Z?X.key=v.ESC+"[3;"+(Z+1)+"~":X.key=v.ESC+"[3~";break;case 36:Z?X.key=v.ESC+"[1;"+(Z+1)+"H":G?X.key=v.ESC+"OH":X.key=v.ESC+"[H";break;case 35:Z?X.key=v.ESC+"[1;"+(Z+1)+"F":G?X.key=v.ESC+"OF":X.key=v.ESC+"[F";break;case 33:q.shiftKey?X.type=2:q.ctrlKey?X.key=v.ESC+"[5;"+(Z+1)+"~":X.key=v.ESC+"[5~";break;case 34:q.shiftKey?X.type=3:q.ctrlKey?X.key=v.ESC+"[6;"+(Z+1)+"~":X.key=v.ESC+"[6~";break;case 112:Z?X.key=v.ESC+"[1;"+(Z+1)+"P":X.key=v.ESC+"OP";break;case 113:Z?X.key=v.ESC+"[1;"+(Z+1)+"Q":X.key=v.ESC+"OQ";break;case 114:Z?X.key=v.ESC+"[1;"+(Z+1)+"R":X.key=v.ESC+"OR";break;case 115:Z?X.key=v.ESC+"[1;"+(Z+1)+"S":X.key=v.ESC+"OS";break;case 116:Z?X.key=v.ESC+"[15;"+(Z+1)+"~":X.key=v.ESC+"[15~";break;case 117:Z?X.key=v.ESC+"[17;"+(Z+1)+"~":X.key=v.ESC+"[17~";break;case 118:Z?X.key=v.ESC+"[18;"+(Z+1)+"~":X.key=v.ESC+"[18~";break;case 119:Z?X.key=v.ESC+"[19;"+(Z+1)+"~":X.key=v.ESC+"[19~";break;case 120:Z?X.key=v.ESC+"[20;"+(Z+1)+"~":X.key=v.ESC+"[20~";break;case 121:Z?X.key=v.ESC+"[21;"+(Z+1)+"~":X.key=v.ESC+"[21~";break;case 122:Z?X.key=v.ESC+"[23;"+(Z+1)+"~":X.key=v.ESC+"[23~";break;case 123:Z?X.key=v.ESC+"[24;"+(Z+1)+"~":X.key=v.ESC+"[24~";break;default:if(q.ctrlKey&&!q.shiftKey&&!q.altKey&&!q.metaKey)q.keyCode>=65&&q.keyCode<=90?X.key=String.fromCharCode(q.keyCode-64):q.keyCode===32?X.key=v.NUL:q.keyCode>=51&&q.keyCode<=55?X.key=String.fromCharCode(q.keyCode-51+27):q.keyCode===56?X.key=v.DEL:q.keyCode===219?X.key=v.ESC:q.keyCode===220?X.key=v.FS:q.keyCode===221&&(X.key=v.GS);else if((!Y||J)&&q.altKey&&!q.metaKey){let V=r2[q.keyCode]?.[q.shiftKey?1:0];if(V)X.key=v.ESC+V;else if(q.keyCode>=65&&q.keyCode<=90){let j=q.ctrlKey?q.keyCode-64:q.keyCode+32,z=String.fromCharCode(j);q.shiftKey&&(z=z.toUpperCase()),X.key=v.ESC+z}else if(q.keyCode===32)X.key=v.ESC+(q.ctrlKey?v.NUL:" ");else if(q.key==="Dead"&&q.code.startsWith("Key")){let j=q.code.slice(3,4);q.shiftKey||(j=j.toLowerCase()),X.key=v.ESC+j,X.cancel=!0}}else Y&&!q.altKey&&!q.ctrlKey&&!q.shiftKey&&q.metaKey?q.keyCode===65&&(X.type=1):q.key&&!q.ctrlKey&&!q.altKey&&!q.metaKey&&q.keyCode>=48&&q.key.length===1?X.key=q.key:q.key&&q.ctrlKey&&(q.key==="_"&&(X.key=v.US),q.key==="@"&&(X.key=v.NUL));break}return X}var A0=0,t2=class{constructor(q){this._getKey=q,this._array=[],this._insertedValues=[],this._flushInsertedTask=new I4,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new I4,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(q){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(q)}_flushInserted(){let q=this._insertedValues.sort((X,Z)=>this._getKey(X)-this._getKey(Z)),G=0,Y=0,J=Array(this._array.length+this._insertedValues.length);for(let X=0;X=this._array.length||this._getKey(q[G])<=this._getKey(this._array[Y])?(J[X]=q[G],G++):J[X]=this._array[Y++];this._array=J,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(q){if(this._flushCleanupInserted(),this._array.length===0)return!1;let G=this._getKey(q);if(G===void 0||(A0=this._search(G),A0===-1)||this._getKey(this._array[A0])!==G)return!1;do if(this._array[A0]===q)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(A0),!0;while(++A0X-Z),G=0,Y=Array(this._array.length-q.length),J=0;for(let X=0;X0&&this._flushDeletedTask.flush()}*getKeyIterator(q){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(A0=this._search(q),!(A0<0||A0>=this._array.length)&&this._getKey(this._array[A0])===q))do yield this._array[A0];while(++A0=this._array.length)&&this._getKey(this._array[A0])===q))do G(this._array[A0]);while(++A0=G;){let J=G+Y>>1,X=this._getKey(this._array[J]);if(X>q)Y=J-1;else if(X0&&this._getKey(this._array[J-1])===q;)J--;return J}}return G}},j5=0,V7=0,e2=class extends t{constructor(){super();this._decorations=new t2((q)=>q?.marker.line),this._onDecorationRegistered=this._register(new _),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new _),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(j0(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(q){if(q.marker.isDisposed)return;let G=new qq(q);if(G){let Y=G.marker.onDispose(()=>G.dispose()),J=G.onDispose(()=>{J.dispose(),G&&(this._decorations.delete(G)&&this._onDecorationRemoved.fire(G),Y.dispose())});this._decorations.insert(G),this._onDecorationRegistered.fire(G)}return G}reset(){for(let q of this._decorations.values())q.dispose();this._decorations.clear()}*getDecorationsAtCell(q,G,Y){let J=0,X=0;for(let Z of this._decorations.getKeyIterator(G))J=Z.options.x??0,X=J+(Z.options.width??1),q>=J&&q{j5=X.options.x??0,V7=j5+(X.options.width??1),q>=j5&&q=this._debounceThresholdMS)this._lastRefreshMs=J,this._innerRefresh();else if(!this._additionalRefreshRequested){let X=J-this._lastRefreshMs,Z=this._debounceThresholdMS-X;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},Z)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let q=Math.max(this._rowStart,0),G=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(q,G)}},K7=20,z7=!1,T4=class extends t{constructor(q,G,Y,J){super();this._terminal=q,this._coreBrowserService=Y,this._renderService=J,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let X=this._coreBrowserService.mainDocument;this._accessibilityContainer=X.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=X.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let Z=0;Zthis._handleBoundaryFocus(Z,0),this._bottomBoundaryFocusListener=(Z)=>this._handleBoundaryFocus(Z,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=X.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Yq(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");z7?(this._accessibilityContainer.classList.add("debug"),this._rowContainer.classList.add("debug"),this._debugRootContainer=X.createElement("div"),this._debugRootContainer.classList.add("xterm"),this._debugRootContainer.appendChild(X.createTextNode("------start a11y------")),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(X.createTextNode("------end a11y------")),this._terminal.element.insertAdjacentElement("afterend",this._debugRootContainer)):this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize((Z)=>this._handleResize(Z.rows))),this._register(this._terminal.onRender((Z)=>this._refreshRows(Z.start,Z.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar((Z)=>this._handleChar(Z))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` `))),this._register(this._terminal.onA11yTab((Z)=>this._handleTab(Z))),this._register(this._terminal.onKey((Z)=>this._handleKey(Z.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(s(X,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(j0(()=>{z7?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(q){for(let G=0;G0?this._charsToConsume.shift()!==q&&(this._charsToAnnounce+=q):this._charsToAnnounce+=q,q===` `&&(this._liveRegionLineCount++,this._liveRegionLineCount===K7+1&&(this._liveRegion.textContent+=H5.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(q){this._clearLiveRegion(),/\p{Control}/u.test(q)||this._charsToConsume.push(q)}_refreshRows(q,G){this._liveRegionDebouncer.refresh(q,G,this._terminal.rows)}_renderRows(q,G){let Y=this._terminal.buffer,J=Y.lines.length.toString();for(let X=q;X<=G;X++){let Z=Y.lines.get(Y.ydisp+X),V=[],j=Z?.translateToString(!0,void 0,void 0,V)||"",z=(Y.ydisp+X+1).toString(),K=this._rowElements[X];K&&(j.length===0?(K.textContent=" ",this._rowColumns.set(K,[0,1])):(K.textContent=j,this._rowColumns.set(K,V)),K.setAttribute("aria-posinset",z),K.setAttribute("aria-setsize",J),this._alignRowWidth(K))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(q,G){let Y=q.target,J=this._rowElements[G===0?1:this._rowElements.length-2],X=Y.getAttribute("aria-posinset"),Z=G===0?"1":`${this._terminal.buffer.lines.length}`;if(X===Z||q.relatedTarget!==J)return;let V,j;if(G===0?(V=Y,j=this._rowElements.pop(),this._rowContainer.removeChild(j)):(V=this._rowElements.shift(),j=Y,this._rowContainer.removeChild(V)),V.removeEventListener("focus",this._topBoundaryFocusListener),j.removeEventListener("focus",this._bottomBoundaryFocusListener),G===0){let z=this._createAccessibilityTreeNode();this._rowElements.unshift(z),this._rowContainer.insertAdjacentElement("afterbegin",z)}else{let z=this._createAccessibilityTreeNode();this._rowElements.push(z),this._rowContainer.appendChild(z)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(G===0?-1:1),this._rowElements[G===0?1:this._rowElements.length-2].focus(),q.preventDefault(),q.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let q=this._coreBrowserService.mainDocument.getSelection();if(!q)return;if(q.isCollapsed){this._rowContainer.contains(q.anchorNode)&&this._terminal.clearSelection();return}if(!q.anchorNode||!q.focusNode){console.error("anchorNode and/or focusNode are null");return}let G={node:q.anchorNode,offset:q.anchorOffset},Y={node:q.focusNode,offset:q.focusOffset};if((G.node.compareDocumentPosition(Y.node)&Node.DOCUMENT_POSITION_PRECEDING||G.node===Y.node&&G.offset>Y.offset)&&([G,Y]=[Y,G]),G.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(G={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(G.node))return;let J=this._rowElements.slice(-1)[0];if(Y.node.compareDocumentPosition(J)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(Y={node:J,offset:J.textContent?.length??0}),!this._rowContainer.contains(Y.node))return;let X=({node:j,offset:z})=>{let K=j instanceof Text?j.parentNode:j,D=parseInt(K?.getAttribute("aria-posinset"),10)-1;if(isNaN(D))return console.warn("row is invalid. Race condition?"),null;let C=this._rowColumns.get(K);if(!C)return console.warn("columns is null. Race condition?"),null;let R=z=this._terminal.cols&&(++D,R=0),{row:D,column:R}},Z=X(G),V=X(Y);if(!(!Z||!V)){if(Z.row>V.row||Z.row===V.row&&Z.column>=V.column)throw Error("invalid range");this._terminal.select(Z.column,Z.row,(V.row-Z.row)*this._terminal.cols-Z.column+V.column)}}_handleResize(q){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let G=this._rowContainer.children.length;Gq;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let q=this._coreBrowserService.mainDocument.createElement("div");return q.setAttribute("role","listitem"),q.tabIndex=-1,this._refreshRowDimensions(q),q}_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 q=0;q{W3(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(s(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(s(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(s(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(s(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(q){this._lastMouseEvent=q;let G=this._positionFromMouseEvent(q,this._element,this._mouseService);if(!G)return;this._isMouseOut=!1;let Y=q.composedPath();for(let J=0;J{J?.forEach((X)=>{X.link.dispose&&X.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=q.y);let Y=!1;for(let[J,X]of this._linkProviderService.linkProviders.entries())G?this._activeProviderReplies?.get(J)&&(Y=this._checkLinkProviderResult(J,q,Y)):X.provideLinks(q.y,(Z)=>{if(this._isMouseOut)return;let V=Z?.map((j)=>({link:j}));this._activeProviderReplies?.set(J,V),Y=this._checkLinkProviderResult(J,q,Y),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(q.y,this._activeProviderReplies)})}_removeIntersectingLinks(q,G){let Y=new Set;for(let J=0;Jq?this._bufferService.cols:V.link.range.end.x;for(let K=j;K<=z;K++){if(Y.has(K)){X.splice(Z--,1);break}Y.add(K)}}}}_checkLinkProviderResult(q,G,Y){if(!this._activeProviderReplies)return Y;let J=this._activeProviderReplies.get(q),X=!1;for(let Z=0;Zthis._linkAtPosition(V.link,G));Z&&(Y=!0,this._handleNewLink(Z))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!Y)for(let Z=0;Zthis._linkAtPosition(j.link,G));if(V){Y=!0,this._handleNewLink(V);break}}return Y}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(q){if(!this._currentLink)return;let G=this._positionFromMouseEvent(q,this._element,this._mouseService);G&&this._mouseDownLink&&Zq(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,G)&&this._currentLink.link.activate(q,this._currentLink.link.text)}_clearCurrentLink(q,G){!this._currentLink||!this._lastMouseEvent||(!q||!G||this._currentLink.link.range.start.y>=q&&this._currentLink.link.range.end.y<=G)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,W3(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(q){if(!this._lastMouseEvent)return;let G=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);G&&this._linkAtPosition(q.link,G)&&(this._currentLink=q,this._currentLink.state={decorations:{underline:q.link.decorations===void 0?!0:q.link.decorations.underline,pointerCursor:q.link.decorations===void 0?!0:q.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,q.link,this._lastMouseEvent),q.link.decorations={},Object.defineProperties(q.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:(Y)=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==Y&&(this._currentLink.state.decorations.pointerCursor=Y,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",Y))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:(Y)=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==Y&&(this._currentLink.state.decorations.underline=Y,this._currentLink.state.isHovered&&this._fireUnderlineEvent(q.link,Y))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((Y)=>{if(!this._currentLink)return;let J=Y.start===0?0:Y.start+1+this._bufferService.buffer.ydisp,X=this._bufferService.buffer.ydisp+1+Y.end;if(this._currentLink.link.range.start.y>=J&&this._currentLink.link.range.end.y<=X&&(this._clearCurrentLink(J,X),this._lastMouseEvent)){let Z=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);Z&&this._askForLink(Z,!1)}})))}_linkHover(q,G,Y){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(G,!0),this._currentLink.state.decorations.pointerCursor&&q.classList.add("xterm-cursor-pointer")),G.hover&&G.hover(Y,G.text)}_fireUnderlineEvent(q,G){let Y=q.range,J=this._bufferService.buffer.ydisp,X=this._createLinkUnderlineEvent(Y.start.x-1,Y.start.y-J-1,Y.end.x,Y.end.y-J-1,void 0);(G?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(X)}_linkLeave(q,G,Y){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(G,!1),this._currentLink.state.decorations.pointerCursor&&q.classList.remove("xterm-cursor-pointer")),G.leave&&G.leave(Y,G.text)}_linkAtPosition(q,G){let Y=q.range.start.y*this._bufferService.cols+q.range.start.x,J=q.range.end.y*this._bufferService.cols+q.range.end.x,X=G.y*this._bufferService.cols+G.x;return Y<=X&&X<=J}_positionFromMouseEvent(q,G,Y){let J=Y.getCoords(q,G,this._bufferService.cols,this._bufferService.rows);if(J)return{x:J[0],y:J[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(q,G,Y,J,X){return{x1:q,y1:G,x2:Y,y2:J,cols:this._bufferService.cols,fg:X}}};p5=F0([p(1,u5),p(2,z3),p(3,v0),p(4,P7)],p5);function Zq(q,G){return q.text===G.text&&q.range.start.x===G.range.start.x&&q.range.start.y===G.range.start.y&&q.range.end.x===G.range.end.x&&q.range.end.y===G.range.end.y}var Jq=class extends s2{constructor(q={}){super(q);this._linkifier=this._register(new y3),this.browser=_7,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new y3),this._onCursorMove=this._register(new _),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new _),this.onKey=this._onKey.event,this._onRender=this._register(new _),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new _),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new _),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new _),this.onBell=this._onBell.event,this._onFocus=this._register(new _),this._onBlur=this._register(new _),this._onA11yCharEmitter=this._register(new _),this._onA11yTabEmitter=this._register(new _),this._onWillOpen=this._register(new _),this._setup(),this._decorationService=this._instantiationService.createInstance(e2),this._instantiationService.setService(X4,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(l1),this._instantiationService.setService(P7,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(C5)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows((G)=>this.refresh(G?.start??0,G?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport((G)=>this._reportWindowsOptions(G))),this._register(this._inputHandler.onColor((G)=>this._handleColorEvent(G))),this._register(I0.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(I0.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(I0.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(I0.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize((G)=>this._afterResize(G.cols,G.rows))),this._register(j0(()=>{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}_handleColorEvent(q){if(this._themeService)for(let G of q){let Y,J="";switch(G.index){case 256:Y="foreground",J="10";break;case 257:Y="background",J="11";break;case 258:Y="cursor",J="12";break;default:Y="ansi",J="4;"+G.index}switch(G.type){case 0:let X=z0.toColorRGB(Y==="ansi"?this._themeService.colors.ansi[G.index]:this._themeService.colors[Y]);this.coreService.triggerDataEvent(`${v.ESC}]${J};${h2(X)}${v7.ST}`);break;case 1:if(Y==="ansi")this._themeService.modifyColors((Z)=>Z.ansi[G.index]=k0.toColor(...G.color));else{let Z=Y;this._themeService.modifyColors((V)=>V[Z]=k0.toColor(...G.color))}break;case 2:this._themeService.restoreColor(G.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(q){q?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(T4,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(q){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(v.ESC+"[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(v.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let q=this.buffer.ybase+this.buffer.y,G=this.buffer.lines.get(q);if(!G)return;let Y=Math.min(this.buffer.x,this.cols-1),J=this._renderService.dimensions.css.cell.height,X=G.getWidth(Y),Z=this._renderService.dimensions.css.cell.width*X,V=this.buffer.y*this._renderService.dimensions.css.cell.height,j=Y*this._renderService.dimensions.css.cell.width;this.textarea.style.left=j+"px",this.textarea.style.top=V+"px",this.textarea.style.width=Z+"px",this.textarea.style.height=J+"px",this.textarea.style.lineHeight=J+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(s(this.element,"copy",(G)=>{this.hasSelection()&&b8(G,this._selectionService)}));let q=(G)=>v8(G,this.textarea,this.coreService,this.optionsService);this._register(s(this.textarea,"paste",q)),this._register(s(this.element,"paste",q)),f7?this._register(s(this.element,"mousedown",(G)=>{G.button===2&&j6(G,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(s(this.element,"contextmenu",(G)=>{j6(G,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),s5&&this._register(s(this.element,"auxclick",(G)=>{G.button===1&&D7(G,this.textarea,this.screenElement)}))}_bindKeys(){this._register(s(this.textarea,"keyup",(q)=>this._keyUp(q),!0)),this._register(s(this.textarea,"keydown",(q)=>this._keyDown(q),!0)),this._register(s(this.textarea,"keypress",(q)=>this._keyPress(q),!0)),this._register(s(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(s(this.textarea,"compositionupdate",(q)=>this._compositionHelper.compositionupdate(q))),this._register(s(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(s(this.textarea,"input",(q)=>this._inputEvent(q),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(q){if(!q)throw Error("Terminal requires a parent element.");if(q.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=q.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"),q.appendChild(this.element);let G=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),G.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(s(this.screenElement,"mousemove",(X)=>this.updateCursorStyle(X))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),G.appendChild(this.screenElement);let Y=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",M5.get()),u7||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",()=>Y.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(c1,this.textarea,q.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(K3,this._coreBrowserService),this._register(s(this.textarea,"focus",(X)=>this._handleTextAreaFocus(X))),this._register(s(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(y5,this._document,this._helperContainer),this._instantiationService.setService(E4,this._charSizeService),this._themeService=this._instantiationService.createInstance(x5),this._instantiationService.setService(w3,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(y4),this._instantiationService.setService(A7,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(I5,this.rows,this.screenElement)),this._instantiationService.setService(z3,this._renderService),this._register(this._renderService.onRenderedViewportChange((X)=>this._onRender.fire(X))),this.onResize((X)=>this._renderService.resize(X.cols,X.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(U5,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(w5),this._instantiationService.setService(u5,this._mouseService);let J=this._linkifier.value=this._register(this._instantiationService.createInstance(p5,this.screenElement));this.element.appendChild(G);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(W5,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines((X)=>{super.scrollLines(X,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(T5,this.element,this.screenElement,J)),this._instantiationService.setService(h8,this._selectionService),this._register(this._selectionService.onRequestScrollLines((X)=>this.scrollLines(X.amount,X.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw((X)=>this._renderService.handleSelectionChanged(X.start,X.end,X.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection((X)=>{this.textarea.value=X,this.textarea.focus(),this.textarea.select()})),this._register(I0.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(L5,this.screenElement)),this._register(s(this.element,"mousedown",(X)=>this._selectionService.handleMouseDown(X))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(T4,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",(X)=>this._handleScreenReaderModeOptionChange(X))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(S4,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",(X)=>{!this._overviewRulerRenderer&&X&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(S4,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(S5,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let q=this,G=this.element;function Y(Z){let V=q._mouseService.getMouseReportCoords(Z,q.screenElement);if(!V)return!1;let j,z;switch(Z.overrideType||Z.type){case"mousemove":z=32,Z.buttons===void 0?(j=3,Z.button!==void 0&&(j=Z.button<3?Z.button:3)):j=Z.buttons&1?0:Z.buttons&4?1:Z.buttons&2?2:3;break;case"mouseup":z=0,j=Z.button<3?Z.button:3;break;case"mousedown":z=1,j=Z.button<3?Z.button:3;break;case"wheel":if(q._customWheelEventHandler&&q._customWheelEventHandler(Z)===!1)return!1;let K=Z.deltaY;if(K===0||q.coreMouseService.consumeWheelEvent(Z,q._renderService?.dimensions?.device?.cell?.height,q._coreBrowserService?.dpr)===0)return!1;z=K<0?0:1,j=4;break;default:return!1}return z===void 0||j===void 0||j>4?!1:q.coreMouseService.triggerMouseEvent({col:V.col,row:V.row,x:V.x,y:V.y,button:j,action:z,ctrl:Z.ctrlKey,alt:Z.altKey,shift:Z.shiftKey})}let J={mouseup:null,wheel:null,mousedrag:null,mousemove:null},X={mouseup:(Z)=>(Y(Z),Z.buttons||(this._document.removeEventListener("mouseup",J.mouseup),J.mousedrag&&this._document.removeEventListener("mousemove",J.mousedrag)),this.cancel(Z)),wheel:(Z)=>(Y(Z),this.cancel(Z,!0)),mousedrag:(Z)=>{Z.buttons&&Y(Z)},mousemove:(Z)=>{Z.buttons||Y(Z)}};this._register(this.coreMouseService.onProtocolChange((Z)=>{Z?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(Z)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),Z&8?J.mousemove||(G.addEventListener("mousemove",X.mousemove),J.mousemove=X.mousemove):(G.removeEventListener("mousemove",J.mousemove),J.mousemove=null),Z&16?J.wheel||(G.addEventListener("wheel",X.wheel,{passive:!1}),J.wheel=X.wheel):(G.removeEventListener("wheel",J.wheel),J.wheel=null),Z&2?J.mouseup||(J.mouseup=X.mouseup):(this._document.removeEventListener("mouseup",J.mouseup),J.mouseup=null),Z&4?J.mousedrag||(J.mousedrag=X.mousedrag):(this._document.removeEventListener("mousemove",J.mousedrag),J.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(s(G,"mousedown",(Z)=>{if(Z.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(Z)))return Y(Z),J.mouseup&&this._document.addEventListener("mouseup",J.mouseup),J.mousedrag&&this._document.addEventListener("mousemove",J.mousedrag),this.cancel(Z)})),this._register(s(G,"wheel",(Z)=>{if(!J.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(Z)===!1)return!1;if(!this.buffer.hasScrollback){if(Z.deltaY===0)return!1;if(q.coreMouseService.consumeWheelEvent(Z,q._renderService?.dimensions?.device?.cell?.height,q._coreBrowserService?.dpr)===0)return this.cancel(Z,!0);let V=v.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(Z.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(V,!0),this.cancel(Z,!0)}}},{passive:!1}))}refresh(q,G){this._renderService?.refreshRows(q,G)}updateCursorStyle(q){this._selectionService?.shouldColumnSelect(q)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(q,G){this._viewport?this._viewport.scrollLines(q):super.scrollLines(q,G),this.refresh(0,this.rows-1)}scrollPages(q){this.scrollLines(q*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(q){q&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(q){let G=q-this._bufferService.buffer.ydisp;G!==0&&this.scrollLines(G)}paste(q){H7(q,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(q){this._customKeyEventHandler=q}attachCustomWheelEventHandler(q){this._customWheelEventHandler=q}registerLinkProvider(q){return this._linkProviderService.registerLinkProvider(q)}registerCharacterJoiner(q){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let G=this._characterJoinerService.register(q);return this.refresh(0,this.rows-1),G}deregisterCharacterJoiner(q){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(q)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(q){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+q)}registerDecoration(q){return this._decorationService.registerDecoration(q)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(q,G,Y){this._selectionService.setSelection(q,G,Y)}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(q,G){this._selectionService?.selectLines(q,G)}_keyDown(q){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(q)===!1)return!1;let G=this.browser.isMac&&this.options.macOptionIsMeta&&q.altKey;if(!G&&!this._compositionHelper.keydown(q))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!G&&(q.key==="Dead"||q.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let Y=i2(q,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(q),Y.type===3||Y.type===2){let J=this.rows-1;return this.scrollLines(Y.type===2?-J:J),this.cancel(q,!0)}if(Y.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,q)||(Y.cancel&&this.cancel(q,!0),!Y.key)||q.key&&!q.ctrlKey&&!q.altKey&&!q.metaKey&&q.key.length===1&&q.key.charCodeAt(0)>=65&&q.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((Y.key===v.ETX||Y.key===v.CR)&&(this.textarea.value=""),this._onKey.fire({key:Y.key,domEvent:q}),this._showCursor(),this.coreService.triggerDataEvent(Y.key,!0),!this.optionsService.rawOptions.screenReaderMode||q.altKey||q.ctrlKey)return this.cancel(q,!0);this._keyDownHandled=!0}_isThirdLevelShift(q,G){let Y=q.isMac&&!this.options.macOptionIsMeta&&G.altKey&&!G.ctrlKey&&!G.metaKey||q.isWindows&&G.altKey&&G.ctrlKey&&!G.metaKey||q.isWindows&&G.getModifierState("AltGraph");return G.type==="keypress"?Y:Y&&(!G.keyCode||G.keyCode>47)}_keyUp(q){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(q)===!1)&&(Xq(q)||this.focus(),this.updateCursorStyle(q),this._keyPressHandled=!1)}_keyPress(q){let G;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(q)===!1)return!1;if(this.cancel(q),q.charCode)G=q.charCode;else if(q.which===null||q.which===void 0)G=q.keyCode;else if(q.which!==0&&q.charCode!==0)G=q.which;else return!1;return!G||(q.altKey||q.ctrlKey||q.metaKey)&&!this._isThirdLevelShift(this.browser,q)?!1:(G=String.fromCharCode(G),this._onKey.fire({key:G,domEvent:q}),this._showCursor(),this.coreService.triggerDataEvent(G,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(q){if(q.data&&q.inputType==="insertText"&&(!q.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let G=q.data;return this.coreService.triggerDataEvent(G,!0),this.cancel(q),!0}return!1}resize(q,G){if(q===this.cols&&G===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(q,G)}_afterResize(q,G){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let q=1;q=0;q--)this._addons[q].instance.dispose()}loadAddon(q,G){let Y={instance:G,dispose:G.dispose,isDisposed:!1};this._addons.push(Y),G.dispose=()=>this._wrappedAddonDispose(Y),G.activate(q)}_wrappedAddonDispose(q){if(q.isDisposed)return;let G=-1;for(let Y=0;Y=this._line.length))return G?(this._line.loadCell(q,G),G):this._line.loadCell(q,new c0)}translateToString(q,G,Y){return this._line.translateToString(q,G,Y)}},j7=class{constructor(q,G){this._buffer=q,this.type=G}init(q){return this._buffer=q,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(q){let G=this._buffer.lines.get(q);if(G)return new Kq(G)}getNullCell(){return new c0}},zq=class extends t{constructor(q){super();this._core=q,this._onBufferChange=this._register(new _),this.onBufferChange=this._onBufferChange.event,this._normal=new j7(this._core.buffers.normal,"normal"),this._alternate=new j7(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw 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)}},jq=class{constructor(q){this._core=q}registerCsiHandler(q,G){return this._core.registerCsiHandler(q,(Y)=>G(Y.toArray()))}addCsiHandler(q,G){return this.registerCsiHandler(q,G)}registerDcsHandler(q,G){return this._core.registerDcsHandler(q,(Y,J)=>G(Y,J.toArray()))}addDcsHandler(q,G){return this.registerDcsHandler(q,G)}registerEscHandler(q,G){return this._core.registerEscHandler(q,G)}addEscHandler(q,G){return this.registerEscHandler(q,G)}registerOscHandler(q,G){return this._core.registerOscHandler(q,G)}addOscHandler(q,G){return this.registerOscHandler(q,G)}},Mq=class{constructor(q){this._core=q}register(q){this._core.unicodeService.register(q)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(q){this._core.unicodeService.activeVersion=q}},Hq=["cols","rows"],s0=0,s7=class extends t{constructor(q){super(),this._core=this._register(new Jq(q)),this._addonManager=this._register(new Vq),this._publicOptions={...this._core.options};let G=(J)=>this._core.options[J],Y=(J,X)=>{this._checkReadonlyOptions(J),this._core.options[J]=X};for(let J in this._core.options){let X={get:G.bind(this,J),set:Y.bind(this,J)};Object.defineProperty(this._publicOptions,J,X)}}_checkReadonlyOptions(q){if(Hq.includes(q))throw Error(`Option "${q}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new jq(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Mq(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new zq(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let q=this._core.coreService.decPrivateModes,G="none";switch(this._core.coreMouseService.activeProtocol){case"X10":G="x10";break;case"VT200":G="vt200";break;case"DRAG":G="drag";break;case"ANY":G="any";break}return{applicationCursorKeysMode:q.applicationCursorKeys,applicationKeypadMode:q.applicationKeypad,bracketedPasteMode:q.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:G,originMode:q.origin,reverseWraparoundMode:q.reverseWraparound,sendFocusMode:q.sendFocus,synchronizedOutputMode:q.synchronizedOutput,wraparoundMode:q.wraparound}}get options(){return this._publicOptions}set options(q){for(let G in q)this._publicOptions[G]=q[G]}blur(){this._core.blur()}focus(){this._core.focus()}input(q,G=!0){this._core.input(q,G)}resize(q,G){this._verifyIntegers(q,G),this._core.resize(q,G)}open(q){this._core.open(q)}attachCustomKeyEventHandler(q){this._core.attachCustomKeyEventHandler(q)}attachCustomWheelEventHandler(q){this._core.attachCustomWheelEventHandler(q)}registerLinkProvider(q){return this._core.registerLinkProvider(q)}registerCharacterJoiner(q){return this._checkProposedApi(),this._core.registerCharacterJoiner(q)}deregisterCharacterJoiner(q){this._checkProposedApi(),this._core.deregisterCharacterJoiner(q)}registerMarker(q=0){return this._verifyIntegers(q),this._core.registerMarker(q)}registerDecoration(q){return this._checkProposedApi(),this._verifyPositiveIntegers(q.x??0,q.width??0,q.height??0),this._core.registerDecoration(q)}hasSelection(){return this._core.hasSelection()}select(q,G,Y){this._verifyIntegers(q,G,Y),this._core.select(q,G,Y)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(q,G){this._verifyIntegers(q,G),this._core.selectLines(q,G)}dispose(){super.dispose()}scrollLines(q){this._verifyIntegers(q),this._core.scrollLines(q)}scrollPages(q){this._verifyIntegers(q),this._core.scrollPages(q)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(q){this._verifyIntegers(q),this._core.scrollToLine(q)}clear(){this._core.clear()}write(q,G){this._core.write(q,G)}writeln(q,G){this._core.write(q),this._core.write(`\r -`,G)}paste(q){this._core.paste(q)}refresh(q,G){this._verifyIntegers(q,G),this._core.refresh(q,G)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(q){this._addonManager.loadAddon(this,q)}static get strings(){return{get promptLabel(){return M5.get()},set promptLabel(q){M5.set(q)},get tooMuchOutput(){return H5.get()},set tooMuchOutput(q){H5.set(q)}}}_verifyIntegers(...q){for(s0 of q)if(s0===1/0||isNaN(s0)||s0%1!==0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...q){for(s0 of q)if(s0&&(s0===1/0||isNaN(s0)||s0%1!==0||s0<0))throw Error("This API only accepts positive integers")}};var N8=_3(r7(),1),Q8=_3(i7(),1),X6=_3(t7(),1),W8=_3(e7(),1),L8=_3(q8(),1);var V8="3.7.8",Dq=V8,x3=typeof Buffer=="function",G8=typeof TextDecoder=="function"?new TextDecoder:void 0,Y8=typeof TextEncoder=="function"?new TextEncoder:void 0,Cq="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",j4=Array.prototype.slice.call(Cq),d4=((q)=>{let G={};return q.forEach((Y,J)=>G[Y]=J),G})(j4),$q=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,T0=String.fromCharCode.bind(String),Z8=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):(q)=>new Uint8Array(Array.prototype.slice.call(q,0)),K8=(q)=>q.replace(/=/g,"").replace(/[+\/]/g,(G)=>G=="+"?"-":"_"),z8=(q)=>q.replace(/[^A-Za-z0-9\+\/]/g,""),j8=(q)=>{let G,Y,J,X,Z="",V=q.length%3;for(let j=0;j255||(J=q.charCodeAt(j++))>255||(X=q.charCodeAt(j++))>255)throw TypeError("invalid character found");G=Y<<16|J<<8|X,Z+=j4[G>>18&63]+j4[G>>12&63]+j4[G>>6&63]+j4[G&63]}return V?Z.slice(0,V-3)+"===".substring(V):Z},Z6=typeof btoa=="function"?(q)=>btoa(q):x3?(q)=>Buffer.from(q,"binary").toString("base64"):j8,G6=x3?(q)=>Buffer.from(q).toString("base64"):(q)=>{let G=[];for(let Y=0,J=q.length;YG?K8(G6(q)):G6(q),Fq=(q)=>{if(q.length<2){var G=q.charCodeAt(0);return G<128?q:G<2048?T0(192|G>>>6)+T0(128|G&63):T0(224|G>>>12&15)+T0(128|G>>>6&63)+T0(128|G&63)}else{var G=65536+(q.charCodeAt(0)-55296)*1024+(q.charCodeAt(1)-56320);return T0(240|G>>>18&7)+T0(128|G>>>12&63)+T0(128|G>>>6&63)+T0(128|G&63)}},Rq=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,M8=(q)=>q.replace(Rq,Fq),J8=x3?(q)=>Buffer.from(q,"utf8").toString("base64"):Y8?(q)=>G6(Y8.encode(q)):(q)=>Z6(M8(q)),T3=(q,G=!1)=>G?K8(J8(q)):J8(q),X8=(q)=>T3(q,!0),Aq=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Pq=(q)=>{switch(q.length){case 4:var G=(7&q.charCodeAt(0))<<18|(63&q.charCodeAt(1))<<12|(63&q.charCodeAt(2))<<6|63&q.charCodeAt(3),Y=G-65536;return T0((Y>>>10)+55296)+T0((Y&1023)+56320);case 3:return T0((15&q.charCodeAt(0))<<12|(63&q.charCodeAt(1))<<6|63&q.charCodeAt(2));default:return T0((31&q.charCodeAt(0))<<6|63&q.charCodeAt(1))}},H8=(q)=>q.replace(Aq,Pq),D8=(q)=>{if(q=q.replace(/\s+/g,""),!$q.test(q))throw TypeError("malformed base64.");q+="==".slice(2-(q.length&3));let G,Y,J,X=[];for(let Z=0;Z>16&255)):J===64?X.push(T0(G>>16&255,G>>8&255)):X.push(T0(G>>16&255,G>>8&255,G&255));return X.join("")},J6=typeof atob=="function"?(q)=>atob(z8(q)):x3?(q)=>Buffer.from(q,"base64").toString("binary"):D8,C8=x3?(q)=>Z8(Buffer.from(q,"base64")):(q)=>Z8(J6(q).split("").map((G)=>G.charCodeAt(0))),$8=(q)=>C8(F8(q)),kq=x3?(q)=>Buffer.from(q,"base64").toString("utf8"):G8?(q)=>G8.decode(C8(q)):(q)=>H8(J6(q)),F8=(q)=>z8(q.replace(/[-_]/g,(G)=>G=="-"?"+":"/")),Y6=(q)=>kq(F8(q)),Bq=(q)=>{if(typeof q!="string")return!1;let G=q.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(G)||!/[^\s0-9a-zA-Z\-_]/.test(G)},R8=(q)=>({value:q,enumerable:!1,writable:!0,configurable:!0}),A8=function(){let q=(G,Y)=>Object.defineProperty(String.prototype,G,R8(Y));q("fromBase64",function(){return Y6(this)}),q("toBase64",function(G){return T3(this,G)}),q("toBase64URI",function(){return T3(this,!0)}),q("toBase64URL",function(){return T3(this,!0)}),q("toUint8Array",function(){return $8(this)})},P8=function(){let q=(G,Y)=>Object.defineProperty(Uint8Array.prototype,G,R8(Y));q("toBase64",function(G){return c4(this,G)}),q("toBase64URI",function(){return c4(this,!0)}),q("toBase64URL",function(){return c4(this,!0)})},Nq=()=>{A8(),P8()},h4={version:V8,VERSION:Dq,atob:J6,atobPolyfill:D8,btoa:Z6,btoaPolyfill:j8,fromBase64:Y6,toBase64:T3,encode:T3,encodeURI:X8,encodeURL:X8,utob:M8,btou:H8,decode:Y6,isValid:Bq,fromUint8Array:c4,toUint8Array:$8,extendString:A8,extendUint8Array:P8,extendBuiltins:Nq},k8=class{constructor(q=new Wq,G=new Qq){this._base64=q,this._provider=G}activate(q){this._terminal=q,this._disposable=q.parser.registerOscHandler(52,(G)=>this._setOrReportClipboard(G))}dispose(){return this._disposable?.dispose()}_readText(q,G){let Y=this._base64.encodeText(G);this._terminal?.input(`\x1B]52;${q};${Y}\x07`,!1)}_setOrReportClipboard(q){let G=q.split(";");if(G.length<2)return!0;let Y=G[0],J=G[1];if(J==="?"){let V=this._provider.readText(Y);return V instanceof Promise?V.then((j)=>(this._readText(Y,j),!0)):(this._readText(Y,V),!0)}let X="";try{X=this._base64.decodeText(J)}catch{}let Z=this._provider.writeText(Y,X);return Z instanceof Promise?Z.then(()=>!0):!0}},Qq=class{async readText(q){return q!=="c"?Promise.resolve(""):navigator.clipboard.readText()}async writeText(q,G){return q!=="c"?Promise.resolve():navigator.clipboard.writeText(G)}},Wq=class{encodeText(q){return h4.encode(q)}decodeText(q){let G=h4.decode(q);return!h4.isValid(q)||h4.encode(G)!==q?"":G}};var Lq='ui-monospace, "SFMono-Regular", "FiraCode Nerd Font", "FiraMono Nerd Font", "Fira Code", "Roboto Mono", Menlo, Monaco, Consolas, "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace';function Uq(q){let G={};if(q.dataset.fontFamily)G.fontFamily=q.dataset.fontFamily;if(q.dataset.fontSize)G.fontSize=parseInt(q.dataset.fontSize,10);if(q.dataset.scrollback)G.scrollback=parseInt(q.dataset.scrollback,10);return G}class U8{terminal;socket=null;fitAddon;element;wsUrl;resizeObserver=null;resizeRaf=0;reconnectAttempts=0;maxReconnectAttempts=5;reconnectDelay=1000;resizeEventsEnabled=!1;constructor(q,G,Y={}){this.element=q,this.wsUrl=G;let J={allowProposedApi:!0,fontFamily:Y.fontFamily??Lq,fontSize:Y.fontSize??16,scrollback:Y.scrollback??1000,cursorBlink:!0,cursorStyle:"block",theme:Y.theme};this.terminal=new s7(J),this.fitAddon=new N8.FitAddon,this.terminal.loadAddon(this.fitAddon);try{let Z=new Q8.WebglAddon;Z.onContextLoss(()=>{Z.dispose(),this.terminal.loadAddon(new X6.CanvasAddon)}),this.terminal.loadAddon(Z)}catch{this.terminal.loadAddon(new X6.CanvasAddon)}let X=new W8.Unicode11Addon;if(this.terminal.loadAddon(X),this.terminal.unicode.activeVersion="11",this.terminal.loadAddon(new L8.WebLinksAddon),this.terminal.loadAddon(new k8),this.terminal.open(q),this.terminal.onData((Z)=>{this.send(["stdin",Z])}),this.terminal.onResize(({cols:Z,rows:V})=>{if(!this.resizeEventsEnabled)return;this.send(["resize",{width:Z,height:V}])}),this.ensureInitialFit(),this.scheduleFit(),window.addEventListener("resize",()=>this.scheduleFit()),window.ResizeObserver)this.resizeObserver=new ResizeObserver(()=>this.scheduleFit()),this.resizeObserver.observe(q);this.connect()}ensureInitialFit(){if(!("fonts"in document))return;document.fonts.ready.then(()=>this.scheduleFit()).catch(()=>{})}fit(){try{this.fitAddon.fit()}catch{}}scheduleFit(){if(this.resizeRaf)return;this.resizeRaf=window.requestAnimationFrame(()=>{this.resizeRaf=0,this.fit()})}connect(){if(this.socket?.readyState===WebSocket.OPEN)return;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer",this.socket.addEventListener("open",()=>{this.reconnectAttempts=0,this.element.classList.add("-connected"),this.element.classList.remove("-disconnected"),this.resizeEventsEnabled=!1;let q=()=>{let G={cols:132,rows:45},Y=120,J=(X)=>{let Z=(()=>{try{return this.fitAddon.proposeDimensions()}catch{return}})();if(!Z){if(X<120){window.requestAnimationFrame(()=>J(X+1));return}this.terminal.resize(G.cols,G.rows),this.resizeEventsEnabled=!0,this.send(["resize",{width:G.cols,height:G.rows}]);return}this.terminal.resize(Z.cols,Z.rows),this.resizeEventsEnabled=!0,this.send(["resize",{width:Z.cols,height:Z.rows}])};window.requestAnimationFrame(()=>J(0))};if("fonts"in document)document.fonts.ready.then(q).catch(q);else q();this.terminal.focus()}),this.socket.addEventListener("close",()=>{this.element.classList.remove("-connected"),this.element.classList.add("-disconnected"),this.scheduleReconnect()}),this.socket.addEventListener("error",()=>{}),this.socket.addEventListener("message",(q)=>{this.handleMessage(q.data)})}handleMessage(q){if(q instanceof ArrayBuffer){let G=new TextDecoder().decode(q);this.terminal.write(G);return}try{let G=JSON.parse(q),[Y,J]=G;switch(Y){case"stdout":this.terminal.write(J);break;case"pong":break;default:console.debug("Unknown message type:",Y)}}catch{this.terminal.write(q)}}send(q){if(this.socket?.readyState===WebSocket.OPEN)this.socket.send(JSON.stringify(q))}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){console.error("Max reconnection attempts reached");return}this.reconnectAttempts++;let q=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);setTimeout(()=>{console.log(`Reconnecting (attempt ${this.reconnectAttempts})...`),this.connect()},q)}dispose(){if(this.resizeObserver)this.resizeObserver.disconnect(),this.resizeObserver=null;if(this.resizeRaf)window.cancelAnimationFrame(this.resizeRaf),this.resizeRaf=0;this.socket?.close(),this.terminal.dispose()}}var Oq=new Map;function B8(){document.querySelectorAll(".textual-terminal").forEach((q)=>{let G=q.dataset.sessionWebsocketUrl;if(!G){console.error("Missing data-session-websocket-url on terminal container");return}let Y=Uq(q),J=new U8(q,G,Y);Oq.set(q,J)})}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",B8);else B8();export{Oq as instances,B8 as initTerminals,U8 as WebTerminal}; +`,G)}paste(q){this._core.paste(q)}refresh(q,G){this._verifyIntegers(q,G),this._core.refresh(q,G)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(q){this._addonManager.loadAddon(this,q)}static get strings(){return{get promptLabel(){return M5.get()},set promptLabel(q){M5.set(q)},get tooMuchOutput(){return H5.get()},set tooMuchOutput(q){H5.set(q)}}}_verifyIntegers(...q){for(s0 of q)if(s0===1/0||isNaN(s0)||s0%1!==0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...q){for(s0 of q)if(s0&&(s0===1/0||isNaN(s0)||s0%1!==0||s0<0))throw Error("This API only accepts positive integers")}};var N8=_3(r7(),1),Q8=_3(i7(),1),X6=_3(t7(),1),W8=_3(e7(),1),L8=_3(q8(),1);var V8="3.7.8",Dq=V8,x3=typeof Buffer=="function",G8=typeof TextDecoder=="function"?new TextDecoder:void 0,Y8=typeof TextEncoder=="function"?new TextEncoder:void 0,Cq="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",j4=Array.prototype.slice.call(Cq),d4=((q)=>{let G={};return q.forEach((Y,J)=>G[Y]=J),G})(j4),$q=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,T0=String.fromCharCode.bind(String),Z8=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):(q)=>new Uint8Array(Array.prototype.slice.call(q,0)),K8=(q)=>q.replace(/=/g,"").replace(/[+\/]/g,(G)=>G=="+"?"-":"_"),z8=(q)=>q.replace(/[^A-Za-z0-9\+\/]/g,""),j8=(q)=>{let G,Y,J,X,Z="",V=q.length%3;for(let j=0;j255||(J=q.charCodeAt(j++))>255||(X=q.charCodeAt(j++))>255)throw TypeError("invalid character found");G=Y<<16|J<<8|X,Z+=j4[G>>18&63]+j4[G>>12&63]+j4[G>>6&63]+j4[G&63]}return V?Z.slice(0,V-3)+"===".substring(V):Z},Z6=typeof btoa=="function"?(q)=>btoa(q):x3?(q)=>Buffer.from(q,"binary").toString("base64"):j8,G6=x3?(q)=>Buffer.from(q).toString("base64"):(q)=>{let G=[];for(let Y=0,J=q.length;YG?K8(G6(q)):G6(q),Fq=(q)=>{if(q.length<2){var G=q.charCodeAt(0);return G<128?q:G<2048?T0(192|G>>>6)+T0(128|G&63):T0(224|G>>>12&15)+T0(128|G>>>6&63)+T0(128|G&63)}else{var G=65536+(q.charCodeAt(0)-55296)*1024+(q.charCodeAt(1)-56320);return T0(240|G>>>18&7)+T0(128|G>>>12&63)+T0(128|G>>>6&63)+T0(128|G&63)}},Rq=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,M8=(q)=>q.replace(Rq,Fq),J8=x3?(q)=>Buffer.from(q,"utf8").toString("base64"):Y8?(q)=>G6(Y8.encode(q)):(q)=>Z6(M8(q)),T3=(q,G=!1)=>G?K8(J8(q)):J8(q),X8=(q)=>T3(q,!0),Aq=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Pq=(q)=>{switch(q.length){case 4:var G=(7&q.charCodeAt(0))<<18|(63&q.charCodeAt(1))<<12|(63&q.charCodeAt(2))<<6|63&q.charCodeAt(3),Y=G-65536;return T0((Y>>>10)+55296)+T0((Y&1023)+56320);case 3:return T0((15&q.charCodeAt(0))<<12|(63&q.charCodeAt(1))<<6|63&q.charCodeAt(2));default:return T0((31&q.charCodeAt(0))<<6|63&q.charCodeAt(1))}},H8=(q)=>q.replace(Aq,Pq),D8=(q)=>{if(q=q.replace(/\s+/g,""),!$q.test(q))throw TypeError("malformed base64.");q+="==".slice(2-(q.length&3));let G,Y,J,X=[];for(let Z=0;Z>16&255)):J===64?X.push(T0(G>>16&255,G>>8&255)):X.push(T0(G>>16&255,G>>8&255,G&255));return X.join("")},J6=typeof atob=="function"?(q)=>atob(z8(q)):x3?(q)=>Buffer.from(q,"base64").toString("binary"):D8,C8=x3?(q)=>Z8(Buffer.from(q,"base64")):(q)=>Z8(J6(q).split("").map((G)=>G.charCodeAt(0))),$8=(q)=>C8(F8(q)),kq=x3?(q)=>Buffer.from(q,"base64").toString("utf8"):G8?(q)=>G8.decode(C8(q)):(q)=>H8(J6(q)),F8=(q)=>z8(q.replace(/[-_]/g,(G)=>G=="-"?"+":"/")),Y6=(q)=>kq(F8(q)),Bq=(q)=>{if(typeof q!="string")return!1;let G=q.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(G)||!/[^\s0-9a-zA-Z\-_]/.test(G)},R8=(q)=>({value:q,enumerable:!1,writable:!0,configurable:!0}),A8=function(){let q=(G,Y)=>Object.defineProperty(String.prototype,G,R8(Y));q("fromBase64",function(){return Y6(this)}),q("toBase64",function(G){return T3(this,G)}),q("toBase64URI",function(){return T3(this,!0)}),q("toBase64URL",function(){return T3(this,!0)}),q("toUint8Array",function(){return $8(this)})},P8=function(){let q=(G,Y)=>Object.defineProperty(Uint8Array.prototype,G,R8(Y));q("toBase64",function(G){return c4(this,G)}),q("toBase64URI",function(){return c4(this,!0)}),q("toBase64URL",function(){return c4(this,!0)})},Nq=()=>{A8(),P8()},h4={version:V8,VERSION:Dq,atob:J6,atobPolyfill:D8,btoa:Z6,btoaPolyfill:j8,fromBase64:Y6,toBase64:T3,encode:T3,encodeURI:X8,encodeURL:X8,utob:M8,btou:H8,decode:Y6,isValid:Bq,fromUint8Array:c4,toUint8Array:$8,extendString:A8,extendUint8Array:P8,extendBuiltins:Nq},k8=class{constructor(q=new Wq,G=new Qq){this._base64=q,this._provider=G}activate(q){this._terminal=q,this._disposable=q.parser.registerOscHandler(52,(G)=>this._setOrReportClipboard(G))}dispose(){return this._disposable?.dispose()}_readText(q,G){let Y=this._base64.encodeText(G);this._terminal?.input(`\x1B]52;${q};${Y}\x07`,!1)}_setOrReportClipboard(q){let G=q.split(";");if(G.length<2)return!0;let Y=G[0],J=G[1];if(J==="?"){let V=this._provider.readText(Y);return V instanceof Promise?V.then((j)=>(this._readText(Y,j),!0)):(this._readText(Y,V),!0)}let X="";try{X=this._base64.decodeText(J)}catch{}let Z=this._provider.writeText(Y,X);return Z instanceof Promise?Z.then(()=>!0):!0}},Qq=class{async readText(q){return q!=="c"?Promise.resolve(""):navigator.clipboard.readText()}async writeText(q,G){return q!=="c"?Promise.resolve():navigator.clipboard.writeText(G)}},Wq=class{encodeText(q){return h4.encode(q)}decodeText(q){let G=h4.decode(q);return!h4.isValid(q)||h4.encode(G)!==q?"":G}};var Lq='ui-monospace, "SFMono-Regular", "FiraCode Nerd Font", "FiraMono Nerd Font", "Fira Code", "Roboto Mono", Menlo, Monaco, Consolas, "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace';function Uq(q){let G={};if(q.dataset.fontFamily)G.fontFamily=q.dataset.fontFamily;if(q.dataset.fontSize)G.fontSize=parseInt(q.dataset.fontSize,10);if(q.dataset.scrollback)G.scrollback=parseInt(q.dataset.scrollback,10);return G}class U8{terminal;socket=null;fitAddon;element;wsUrl;resizeObserver=null;resizeRaf=0;reconnectAttempts=0;maxReconnectAttempts=5;reconnectDelay=1000;constructor(q,G,Y={}){this.element=q,this.wsUrl=G;let J={allowProposedApi:!0,fontFamily:Y.fontFamily??Lq,fontSize:Y.fontSize??16,scrollback:Y.scrollback??1000,cursorBlink:!0,cursorStyle:"block",theme:Y.theme};this.terminal=new s7(J),this.fitAddon=new N8.FitAddon,this.terminal.loadAddon(this.fitAddon);try{let Z=new Q8.WebglAddon;Z.onContextLoss(()=>{Z.dispose(),this.terminal.loadAddon(new X6.CanvasAddon)}),this.terminal.loadAddon(Z)}catch{this.terminal.loadAddon(new X6.CanvasAddon)}let X=new W8.Unicode11Addon;if(this.terminal.loadAddon(X),this.terminal.unicode.activeVersion="11",this.terminal.loadAddon(new L8.WebLinksAddon),this.terminal.loadAddon(new k8),this.terminal.open(q),this.terminal.onData((Z)=>{this.send(["stdin",Z])}),this.terminal.onResize(({cols:Z,rows:V})=>{this.send(["resize",{width:Z,height:V}])}),this.ensureInitialFit(),this.scheduleFit(),window.addEventListener("resize",()=>this.scheduleFit()),window.ResizeObserver)this.resizeObserver=new ResizeObserver(()=>this.scheduleFit()),this.resizeObserver.observe(q);this.connect()}ensureInitialFit(){if(!("fonts"in document))return;document.fonts.ready.then(()=>this.scheduleFit()).catch(()=>{})}fit(){try{this.fitAddon.fit()}catch{}}scheduleFit(){if(this.resizeRaf)return;this.resizeRaf=window.requestAnimationFrame(()=>{this.resizeRaf=0,this.fit()})}connect(){if(this.socket?.readyState===WebSocket.OPEN)return;this.socket=new WebSocket(this.wsUrl),this.socket.binaryType="arraybuffer",this.socket.addEventListener("open",()=>{this.reconnectAttempts=0,this.element.classList.add("-connected"),this.element.classList.remove("-disconnected");let q=()=>{let G={cols:132,rows:45},Y=120,J=(X)=>{let Z=(()=>{try{return this.fitAddon.proposeDimensions()}catch{return}})();if(!Z){if(X<120){window.requestAnimationFrame(()=>J(X+1));return}this.terminal.resize(G.cols,G.rows),this.send(["resize",{width:G.cols,height:G.rows}]);return}this.terminal.resize(Z.cols,Z.rows),this.send(["resize",{width:Z.cols,height:Z.rows}])};window.requestAnimationFrame(()=>J(0))};if("fonts"in document)document.fonts.ready.then(q).catch(q);else q();this.terminal.focus()}),this.socket.addEventListener("close",()=>{this.element.classList.remove("-connected"),this.element.classList.add("-disconnected"),this.scheduleReconnect()}),this.socket.addEventListener("error",()=>{}),this.socket.addEventListener("message",(q)=>{this.handleMessage(q.data)})}handleMessage(q){if(q instanceof ArrayBuffer){let G=new TextDecoder().decode(q);this.terminal.write(G);return}try{let G=JSON.parse(q),[Y,J]=G;switch(Y){case"stdout":this.terminal.write(J);break;case"pong":break;default:console.debug("Unknown message type:",Y)}}catch{this.terminal.write(q)}}send(q){if(this.socket?.readyState===WebSocket.OPEN)this.socket.send(JSON.stringify(q))}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){console.error("Max reconnection attempts reached");return}this.reconnectAttempts++;let q=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);setTimeout(()=>{console.log(`Reconnecting (attempt ${this.reconnectAttempts})...`),this.connect()},q)}dispose(){if(this.resizeObserver)this.resizeObserver.disconnect(),this.resizeObserver=null;if(this.resizeRaf)window.cancelAnimationFrame(this.resizeRaf),this.resizeRaf=0;this.socket?.close(),this.terminal.dispose()}}var Oq=new Map;function B8(){document.querySelectorAll(".textual-terminal").forEach((q)=>{let G=q.dataset.sessionWebsocketUrl;if(!G){console.error("Missing data-session-websocket-url on terminal container");return}let Y=Uq(q),J=new U8(q,G,Y);Oq.set(q,J)})}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",B8);else B8();export{Oq as instances,B8 as initTerminals,U8 as WebTerminal}; diff --git a/src/textual_webterm/static/js/terminal.ts b/src/textual_webterm/static/js/terminal.ts index 813027b..3c180b1 100644 --- a/src/textual_webterm/static/js/terminal.ts +++ b/src/textual_webterm/static/js/terminal.ts @@ -59,7 +59,6 @@ class WebTerminal { private reconnectAttempts = 0; private maxReconnectAttempts = 5; private reconnectDelay = 1000; - private resizeEventsEnabled = false; constructor(container: HTMLElement, wsUrl: string, config: TerminalConfig = {}) { this.element = container; @@ -115,9 +114,6 @@ class WebTerminal { // Handle resize this.terminal.onResize(({ cols, rows }) => { - if (!this.resizeEventsEnabled) { - return; - } this.send(["resize", { width: cols, height: rows }]); }); @@ -183,7 +179,6 @@ class WebTerminal { // Important: the PTY hard-wraps output based on its initial cols/rows. // If we send a resize before fonts/layout settle, the initial cols can be // too small and the shell will wrap permanently. - this.resizeEventsEnabled = false; const init = () => { const fallback = { cols: 132, rows: 45 }; @@ -203,13 +198,11 @@ class WebTerminal { return; } this.terminal.resize(fallback.cols, fallback.rows); - this.resizeEventsEnabled = true; this.send(["resize", { width: fallback.cols, height: fallback.rows }]); return; } this.terminal.resize(dims.cols, dims.rows); - this.resizeEventsEnabled = true; this.send(["resize", { width: dims.cols, height: dims.rows }]); };