UNPKG

meshcentral

Version:

Web based remote computer management server

1 lines 267 kB
((e,t)=>{if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i,r=t();for(i in r)("object"==typeof exports?exports:e)[i]=r[i]}})(self,function(){var i={4567:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AccessibilityManager=void 0;let r=i(9042),s=i(6114),n=i(9924),o=i(3656),a=i(844),h=i(5596),l=i(9631);class c extends a.Disposable{constructor(e,t){super(),this._terminal=e,this._renderService=t,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityTreeRoot=document.createElement("div"),this._accessibilityTreeRoot.classList.add("xterm-accessibility"),this._accessibilityTreeRoot.tabIndex=0,this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._onBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._onBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityTreeRoot.appendChild(this._rowContainer),this._renderRowsDebouncer=new n.TimeBasedDebouncer(this._renderRows.bind(this)),this._refreshRows(),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityTreeRoot.appendChild(this._liveRegion),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityTreeRoot),this.register(this._renderRowsDebouncer),this.register(this._terminal.onResize(e=>this._onResize(e.rows))),this.register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(e=>this._onChar(e))),this.register(this._terminal.onLineFeed(()=>this._onChar("\n"))),this.register(this._terminal.onA11yTab(e=>this._onTab(e))),this.register(this._terminal.onKey(e=>this._onKey(e.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._screenDprMonitor=new h.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener(()=>this._refreshRowsDimensions()),this.register((0,o.addDisposableDomListener)(window,"resize",()=>this._refreshRowsDimensions()))}dispose(){super.dispose(),(0,l.removeElementFromParent)(this._accessibilityTreeRoot),this._rowElements.length=0}_onBoundaryFocus(i,r){var s=i.target,e=this._rowElements[0===r?1:this._rowElements.length-2];if(s.getAttribute("aria-posinset")!==(0===r?"1":""+this._terminal.buffer.lines.length)&&i.relatedTarget===e){let e,t;if(0===r?(e=s,t=this._rowElements.pop(),this._rowContainer.removeChild(t)):(e=this._rowElements.shift(),t=s,this._rowContainer.removeChild(e)),e.removeEventListener("focus",this._topBoundaryFocusListener),t.removeEventListener("focus",this._bottomBoundaryFocusListener),0===r){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===r?-1:1),this._rowElements[0===r?1:this._rowElements.length-2].focus(),i.preventDefault(),i.stopImmediatePropagation()}}_onResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){var e=document.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_onTab(t){for(let e=0;e<t;e++)this._onChar(" ")}_onChar(e){this._liveRegionLineCount<21&&(0<this._charsToConsume.length&&this._charsToConsume.shift()===e||(this._charsToAnnounce+=e),"\n"===e&&(this._liveRegionLineCount++,21===this._liveRegionLineCount)&&(this._liveRegion.textContent+=r.tooMuchOutput),s.isMac)&&this._liveRegion.textContent&&0<this._liveRegion.textContent.length&&!this._liveRegion.parentNode&&setTimeout(()=>{this._accessibilityTreeRoot.appendChild(this._liveRegion)},0)}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,s.isMac&&(0,l.removeElementFromParent)(this._liveRegion)}_onKey(e){this._clearLiveRegion(),this._charsToConsume.push(e)}_refreshRows(e,t){this._renderRowsDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){var s=this._terminal.buffer,n=s.lines.length.toString();for(let r=e;r<=t;r++){let e=s.translateBufferLineToString(s.ydisp+r,!0),t=(s.ydisp+r+1).toString(),i=this._rowElements[r];i&&(0===e.length?i.innerText=" ":i.textContent=e,i.setAttribute("aria-posinset",t),i.setAttribute("aria-setsize",n))}this._announceCharacters()}_refreshRowsDimensions(){if(this._renderService.dimensions.actualCellHeight){this._rowElements.length!==this._terminal.rows&&this._onResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=this._renderService.dimensions.actualCellHeight+"px"}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}}t.AccessibilityManager=c},3614:(e,t)=>{function r(e){return e.replace(/\r?\n/g,"\r")}function s(e,t){return t?"[200~"+e+"[201~":e}function n(e,t,i){e=s(e=r(e),i.decPrivateModes.bracketedPasteMode),i.triggerDataEvent(e,!0),t.value=""}function o(e,t,i){var i=i.getBoundingClientRect(),r=e.clientX-i.left-10,e=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=r+"px",t.style.top=e+"px",t.style.zIndex="1000",t.focus()}Object.defineProperty(t,"__esModule",{value:!0}),t.rightClickHandler=t.moveTextAreaUnderMouseCursor=t.paste=t.handlePasteEvent=t.copyHandler=t.bracketTextForPaste=t.prepareTextForTerminal=void 0,t.prepareTextForTerminal=r,t.bracketTextForPaste=s,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,i){e.stopPropagation(),e.clipboardData&&n(e.clipboardData.getData("text/plain"),t,i)},t.paste=n,t.moveTextAreaUnderMouseCursor=o,t.rightClickHandler=function(e,t,i,r,s){o(e,t,i),s&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}},7239:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorContrastCache=void 0;let r=i(1505);t.ColorContrastCache=class{constructor(){this._color=new r.TwoKeyMap,this._css=new r.TwoKeyMap}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}}},5680:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ColorManager=r.DEFAULT_ANSI_COLORS=void 0;let h=t(8055),i=t(7239),s=h.css.toColor("#ffffff"),n=h.css.toColor("#000000"),o=h.css.toColor("#ffffff"),a=h.css.toColor("#000000"),l={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};r.DEFAULT_ANSI_COLORS=Object.freeze((()=>{var t=[h.css.toColor("#2e3436"),h.css.toColor("#cc0000"),h.css.toColor("#4e9a06"),h.css.toColor("#c4a000"),h.css.toColor("#3465a4"),h.css.toColor("#75507b"),h.css.toColor("#06989a"),h.css.toColor("#d3d7cf"),h.css.toColor("#555753"),h.css.toColor("#ef2929"),h.css.toColor("#8ae234"),h.css.toColor("#fce94f"),h.css.toColor("#729fcf"),h.css.toColor("#ad7fa8"),h.css.toColor("#34e2e2"),h.css.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let e=0;e<216;e++){var r=i[e/36%6|0],s=i[e/6%6|0],n=i[e%6];t.push({css:h.channels.toCss(r,s,n),rgba:h.channels.toRgba(r,s,n)})}for(let e=0;e<24;e++){var o=8+10*e;t.push({css:h.channels.toCss(o,o,o),rgba:h.channels.toRgba(o,o,o)})}return t})()),r.ColorManager=class{constructor(e,t){this.allowTransparency=t;t=e.createElement("canvas"),t.width=1,t.height=1,e=t.getContext("2d");if(!e)throw new Error("Could not get rendering context");this._ctx=e,this._ctx.globalCompositeOperation="copy",this._litmusColor=this._ctx.createLinearGradient(0,0,1,1),this._contrastCache=new i.ColorContrastCache,this.colors={foreground:s,background:n,cursor:o,cursorAccent:a,selectionForeground:void 0,selectionBackgroundTransparent:l,selectionBackgroundOpaque:h.color.blend(n,l),selectionInactiveBackgroundTransparent:l,selectionInactiveBackgroundOpaque:h.color.blend(n,l),ansi:r.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache},this._updateRestoreColors()}onOptionsChange(e,t){switch(e){case"minimumContrastRatio":this._contrastCache.clear();break;case"allowTransparency":this.allowTransparency=t}}setTheme(i={}){this.colors.foreground=this._parseColor(i.foreground,s),this.colors.background=this._parseColor(i.background,n),this.colors.cursor=this._parseColor(i.cursor,o,!0),this.colors.cursorAccent=this._parseColor(i.cursorAccent,a,!0),this.colors.selectionBackgroundTransparent=this._parseColor(i.selectionBackground,l,!0),this.colors.selectionBackgroundOpaque=h.color.blend(this.colors.background,this.colors.selectionBackgroundTransparent),this.colors.selectionInactiveBackgroundTransparent=this._parseColor(i.selectionInactiveBackground,this.colors.selectionBackgroundTransparent,!0),this.colors.selectionInactiveBackgroundOpaque=h.color.blend(this.colors.background,this.colors.selectionInactiveBackgroundTransparent);let e={css:"",rgba:0};if(this.colors.selectionForeground=i.selectionForeground?this._parseColor(i.selectionForeground,e):void 0,this.colors.selectionForeground===e&&(this.colors.selectionForeground=void 0),h.color.isOpaque(this.colors.selectionBackgroundTransparent))this.colors.selectionBackgroundTransparent=h.color.opacity(this.colors.selectionBackgroundTransparent,.3);if(h.color.isOpaque(this.colors.selectionInactiveBackgroundTransparent))this.colors.selectionInactiveBackgroundTransparent=h.color.opacity(this.colors.selectionInactiveBackgroundTransparent,.3);if(this.colors.ansi=r.DEFAULT_ANSI_COLORS.slice(),this.colors.ansi[0]=this._parseColor(i.black,r.DEFAULT_ANSI_COLORS[0]),this.colors.ansi[1]=this._parseColor(i.red,r.DEFAULT_ANSI_COLORS[1]),this.colors.ansi[2]=this._parseColor(i.green,r.DEFAULT_ANSI_COLORS[2]),this.colors.ansi[3]=this._parseColor(i.yellow,r.DEFAULT_ANSI_COLORS[3]),this.colors.ansi[4]=this._parseColor(i.blue,r.DEFAULT_ANSI_COLORS[4]),this.colors.ansi[5]=this._parseColor(i.magenta,r.DEFAULT_ANSI_COLORS[5]),this.colors.ansi[6]=this._parseColor(i.cyan,r.DEFAULT_ANSI_COLORS[6]),this.colors.ansi[7]=this._parseColor(i.white,r.DEFAULT_ANSI_COLORS[7]),this.colors.ansi[8]=this._parseColor(i.brightBlack,r.DEFAULT_ANSI_COLORS[8]),this.colors.ansi[9]=this._parseColor(i.brightRed,r.DEFAULT_ANSI_COLORS[9]),this.colors.ansi[10]=this._parseColor(i.brightGreen,r.DEFAULT_ANSI_COLORS[10]),this.colors.ansi[11]=this._parseColor(i.brightYellow,r.DEFAULT_ANSI_COLORS[11]),this.colors.ansi[12]=this._parseColor(i.brightBlue,r.DEFAULT_ANSI_COLORS[12]),this.colors.ansi[13]=this._parseColor(i.brightMagenta,r.DEFAULT_ANSI_COLORS[13]),this.colors.ansi[14]=this._parseColor(i.brightCyan,r.DEFAULT_ANSI_COLORS[14]),this.colors.ansi[15]=this._parseColor(i.brightWhite,r.DEFAULT_ANSI_COLORS[15]),i.extendedAnsi){let t=Math.min(this.colors.ansi.length-16,i.extendedAnsi.length);for(let e=0;e<t;e++)this.colors.ansi[e+16]=this._parseColor(i.extendedAnsi[e],r.DEFAULT_ANSI_COLORS[e+16])}this._contrastCache.clear(),this._updateRestoreColors()}restoreColor(e){if(void 0!==e)switch(e){case 256:this.colors.foreground=this._restoreColors.foreground;break;case 257:this.colors.background=this._restoreColors.background;break;case 258:this.colors.cursor=this._restoreColors.cursor;break;default:this.colors.ansi[e]=this._restoreColors.ansi[e]}else for(let e=0;e<this._restoreColors.ansi.length;++e)this.colors.ansi[e]=this._restoreColors.ansi[e]}_updateRestoreColors(){this._restoreColors={foreground:this.colors.foreground,background:this.colors.background,cursor:this.colors.cursor,ansi:this.colors.ansi.slice()}}_parseColor(n,o,a=this.allowTransparency){if(void 0===n)return o;if(this._ctx.fillStyle=this._litmusColor,this._ctx.fillStyle=n,"string"!=typeof this._ctx.fillStyle)return console.warn(`Color: ${n} is invalid using fallback `+o.css),o;this._ctx.fillRect(0,0,1,1);let e=this._ctx.getImageData(0,0,1,1).data;if(255===e[3])return{css:this._ctx.fillStyle,rgba:h.channels.toRgba(e[0],e[1],e[2],e[3])};{if(!a)return console.warn(`Color: ${n} is using transparency, but allowTransparency is false. Using fallback ${o.css}.`),o;let[e,t,i,r]=this._ctx.fillStyle.substring(5,this._ctx.fillStyle.length-1).split(",").map(e=>Number(e)),s=Math.round(255*r);return{rgba:h.channels.toRgba(e,t,i,s),css:n}}}}},9631:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.removeElementFromParent=void 0,t.removeElementFromParent=function(...e){var t,i;for(i of e)null!=(t=null==i?void 0:i.parentElement)&&t.removeChild(i)}},3656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,i,r){e.addEventListener(t,i,r);let s=!1;return{dispose:()=>{s||(s=!0,e.removeEventListener(t,i,r))}}}},6465:function(e,t,i){var r=this&&this.__decorate||function(e,t,i,r){var s,n=arguments.length,o=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;0<=a;a--)(s=e[a])&&(o=(n<3?s(o):3<n?s(t,i,o):s(t,i))||o);return 3<n&&o&&Object.defineProperty(t,i,o),o},s=this&&this.__param||function(i,r){return function(e,t){r(e,t,i)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Linkifier2=void 0;let n=i(2585),o=i(8460),a=i(844),h=i(3656);i=class extends a.Disposable{constructor(e){super(),this._bufferService=e,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._activeLine=-1,this._onShowLinkUnderline=this.register(new o.EventEmitter),this._onHideLinkUnderline=this.register(new o.EventEmitter),this.register((0,a.getDisposeArrayDisposable)(this._linkCacheDisposables))}get currentLink(){return this._currentLink}get onShowLinkUnderline(){return this._onShowLinkUnderline.event}get onHideLinkUnderline(){return this._onHideLinkUnderline.event}dispose(){super.dispose(),this._lastMouseEvent=void 0}registerLinkProvider(t){return this._linkProviders.push(t),{dispose:()=>{var e=this._linkProviders.indexOf(t);-1!==e&&this._linkProviders.splice(e,1)}}}attachToDom(e,t,i){this._element=e,this._mouseService=t,this._renderService=i,this.register((0,h.addDisposableDomListener)(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this.register((0,h.addDisposableDomListener)(this._element,"mousemove",this._onMouseMove.bind(this))),this.register((0,h.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,h.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_onMouseMove(t){if(this._lastMouseEvent=t,this._element&&this._mouseService){let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(e){this._isMouseOut=!1;var i=t.composedPath();for(let t=0;t<i.length;t++){let e=i[t];if(e.classList.contains("xterm"))break;if(e.classList.contains("xterm-hover"))return}this._lastBufferCell&&e.x===this._lastBufferCell.x&&e.y===this._lastBufferCell.y||(this._onHover(e),this._lastBufferCell=e)}}}_onHover(e){this._activeLine!==e.y?(this._clearCurrentLink(),this._askForLink(e,!1)):this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(r,t){var e,s;this._activeProviderReplies&&t||(null!=(e=this._activeProviderReplies)&&e.forEach(e=>{null!=e&&e.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=r.y);let n=!1;for(let[i,e]of this._linkProviders.entries())t?null!=(s=this._activeProviderReplies)&&s.get(i)&&(n=this._checkLinkProviderResult(i,r,n)):e.provideLinks(r.y,e=>{var t;this._isMouseOut||(e=null==e?void 0:e.map(e=>({link:e})),null!=(t=this._activeProviderReplies)&&t.set(i,e),n=this._checkLinkProviderResult(i,r,n),(null==(t=this._activeProviderReplies)?void 0:t.size)===this._linkProviders.length&&this._removeIntersectingLinks(r.y,this._activeProviderReplies))})}_removeIntersectingLinks(i,t){var r=new Set;for(let e=0;e<t.size;e++){var s=t.get(e);if(s)for(let t=0;t<s.length;t++){var n=s[t],o=n.link.range.start.y<i?0:n.link.range.start.x,a=n.link.range.end.y>i?this._bufferService.cols:n.link.range.end.x;for(let e=o;e<=a;e++){if(r.has(e)){s.splice(t--,1);break}r.add(e)}}}}_checkLinkProviderResult(r,s,n){var o;if(this._activeProviderReplies){let t=this._activeProviderReplies.get(r),i=!1;for(let e=0;e<r;e++)this._activeProviderReplies.has(e)&&!this._activeProviderReplies.get(e)||(i=!0);if(!i&&t){let e=t.find(e=>this._linkAtPosition(e.link,s));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviders.length&&!n)for(let t=0;t<this._activeProviderReplies.size;t++){let e=null==(o=this._activeProviderReplies.get(t))?void 0:o.find(e=>this._linkAtPosition(e.link,s));if(e){n=!0,this._handleNewLink(e);break}}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var t;this._element&&this._mouseService&&this._currentLink&&(t=this._positionFromMouseEvent(e,this._element,this._mouseService))&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){this._element&&this._currentLink&&this._lastMouseEvent&&(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),(this._currentLink=void 0,a.disposeArray)(this._linkCacheDisposables))}_handleNewLink(i){var e;this._element&&this._lastMouseEvent&&this._mouseService&&(e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService))&&this._linkAtPosition(i.link,e)&&(this._currentLink=i,this._currentLink.state={decorations:{underline:void 0===i.link.decorations||i.link.decorations.underline,pointerCursor:void 0===i.link.decorations||i.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,i.link,this._lastMouseEvent),i.link.decorations={},Object.defineProperties(i.link.decorations,{pointerCursor:{get:()=>{var e;return null==(e=null==(e=this._currentLink)?void 0:e.state)?void 0:e.decorations.pointerCursor},set:e=>{var t;null!=(t=this._currentLink)&&t.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered)&&(null!=(t=this._element)&&t.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>{var e;return null==(e=null==(e=this._currentLink)?void 0:e.state)?void 0:e.decorations.underline},set:e=>{var t;null!=(t=this._currentLink)&&t.state&&(null==(t=null==(t=this._currentLink)?void 0:t.state)?void 0:t.decorations.underline)!==e&&(this._currentLink.state.decorations.underline=e,this._currentLink.state.isHovered)&&this._fireUnderlineEvent(i.link,e)}}}),this._renderService)&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{var t=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp;this._clearCurrentLink(t,e.end+1+this._bufferService.buffer.ydisp)}))}_linkHover(e,t,i){var r;null!=(r=this._currentLink)&&r.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor)&&e.classList.add("xterm-cursor-pointer"),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){var e=e.range,i=this._bufferService.buffer.ydisp,e=this._createLinkUnderlineEvent(e.start.x-1,e.start.y-i-1,e.end.x,e.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(e)}_linkLeave(e,t,i){var r;null!=(r=this._currentLink)&&r.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor)&&e.classList.remove("xterm-cursor-pointer"),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){var i=e.range.start.y===e.range.end.y,r=e.range.start.y<t.y,s=e.range.end.y>t.y;return(i&&e.range.start.x<=t.x&&e.range.end.x>=t.x||r&&e.range.end.x>=t.x||s&&e.range.start.x<=t.x||r&&s)&&e.range.start.y<=t.y&&e.range.end.y>=t.y}_positionFromMouseEvent(e,t,i){i=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,r,s){return{x1:e,y1:t,x2:i,y2:r,cols:this._bufferService.cols,fg:s}}},i=r([s(0,n.IBufferService)],i);t.Linkifier2=i},9042:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tooMuchOutput=t.promptLabel=void 0,t.promptLabel="Terminal input",t.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},2962:function(e,t,i){var r=this&&this.__decorate||function(e,t,i,r){var s,n=arguments.length,o=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;0<=a;a--)(s=e[a])&&(o=(n<3?s(o):3<n?s(t,i,o):s(t,i))||o);return 3<n&&o&&Object.defineProperty(t,i,o),o},s=this&&this.__param||function(i,r){return function(e,t){r(e,t,i)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkProvider=void 0;let d=i(511),n=i(2585);i=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(l,e){var c;let _=this._bufferService.buffer.lines.get(l-1);if(_){let i=[],s=this._optionsService.rawOptions.linkHandler,r=new d.CellData,n=_.getTrimmedLength(),o=-1,a=-1,h=!1;for(let t=0;t<n;t++)if(-1!==a||_.hasContent(t)){if(_.loadCell(t,r),r.hasExtendedAttrs()&&r.extended.urlId){if(-1===a){a=t,o=r.extended.urlId;continue}h=r.extended.urlId!==o}else-1!==a&&(h=!0);if(h||-1!==a&&t===n-1){let e=null==(c=this._oscLinkService.getLinkData(o))?void 0:c.uri;if(e){let r={start:{x:a+1,y:l},end:{x:t+(h||t!==n-1?0:1),y:l}};i.push({text:e,range:r,activate:(t,e)=>{if(s)return s.activate(t,e,r);t=e;if(confirm(`Do you want to navigate to ${t}?`)){let e=window.open();if(e){try{e.opener=null}catch(e){}e.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}},hover:(e,t)=>{var i;return null==(i=null==s?void 0:s.hover)?void 0:i.call(s,e,t,r)},leave:(e,t)=>{var i;return null==(i=null==s?void 0:s.leave)?void 0:i.call(s,e,t,r)}})}h=!1,o=r.hasExtendedAttrs()&&r.extended.urlId?(a=t,r.extended.urlId):a=-1}}e(i)}else e(void 0)}};i=r([s(0,n.IBufferService),s(1,n.IOptionsService),s(2,n.IOscLinkService)],i),t.OscLinkProvider=i},6193:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RenderDebouncer=void 0,t.RenderDebouncer=class{constructor(e,t){this._parentWindow=e,this._renderCallback=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=void 0!==e?e:0,t=void 0!==t?t:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,t):t,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){var e,t;(this._animationFrame=void 0)!==this._rowStart&&void 0!==this._rowEnd&&void 0!==this._rowCount&&(e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1),this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(var e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}}},5596:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ScreenDprMonitor=void 0;i=i(844);class r extends i.Disposable{constructor(e){super(),this._parentWindow=e,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio}setListener(e){this._listener&&this.clearListener(),this._listener=e,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}dispose(){super.dispose(),this.clearListener()}_updateDpr(){var e;this._outerListener&&(null!=(e=this._resolutionMediaMatchList)&&e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}t.ScreenDprMonitor=r},3236:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;let r=i(2950),s=i(1680),n=i(3614),o=i(2584),a=i(5435),h=i(9312),l=i(6114),c=i(3656),_=i(9042),d=i(4567),u=i(1296),f=i(7399),v=i(8460),g=i(8437),p=i(5680),S=i(3230),m=i(4725),C=i(428),b=i(8934),y=i(6465),w=i(5114),E=i(8969),L=i(8055),R=i(4269),k=i(5941),D=i(3107),A=i(5744),x=i(9074),B=i(2585),T=i(2962),M="undefined"!=typeof window?window.document:null;class O extends E.CoreTerminal{constructor(e={}){super(e),this.browser=l,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._onCursorMove=new v.EventEmitter,this._onKey=new v.EventEmitter,this._onRender=new v.EventEmitter,this._onSelectionChange=new v.EventEmitter,this._onTitleChange=new v.EventEmitter,this._onBell=new v.EventEmitter,this._onFocus=new v.EventEmitter,this._onBlur=new v.EventEmitter,this._onA11yCharEmitter=new v.EventEmitter,this._onA11yTabEmitter=new v.EventEmitter,this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(y.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(T.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(x.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this.register(this._inputHandler.onRequestRefreshRows((e,t)=>this.refresh(e,t))),this.register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this.register(this._inputHandler.onRequestReset(()=>this.reset())),this.register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this.register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this.register((0,v.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,v.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,v.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,v.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows)))}get onCursorMove(){return this._onCursorMove.event}get onKey(){return this._onKey.event}get onRender(){return this._onRender.event}get onSelectionChange(){return this._onSelectionChange.event}get onTitleChange(){return this._onTitleChange.event}get onBell(){return this._onBell.event}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}_handleColorEvent(e){var t;if(this._colorManager){for(let i of e){let e,t="";switch(i.index){case 256:e="foreground",t="10";break;case 257:e="background",t="11";break;case 258:e="cursor",t="12";break;default:e="ansi",t="4;"+i.index}switch(i.type){case 0:var r=L.color.toColorRGB("ansi"===e?this._colorManager.colors.ansi[i.index]:this._colorManager.colors[e]);this.coreService.triggerDataEvent(`${o.C0.ESC}]${t};`+(0,k.toRgbString)(r)+o.C1_ESCAPED.ST);break;case 1:"ansi"===e?this._colorManager.colors.ansi[i.index]=L.rgba.toColor(...i.color):this._colorManager.colors[e]=L.rgba.toColor(...i.color);break;case 2:this._colorManager.restoreColor(i.index)}}null!=(t=this._renderService)&&t.setColors(this._colorManager.colors),null!=(e=this.viewport)&&e.onThemeChange(this._colorManager.colors)}}dispose(){var e;this._isDisposed||(super.dispose(),null!=(e=this._renderService)&&e.dispose(),this._customKeyEventHandler=void 0,this.write=()=>{},null==(e=null==(e=this.element)?void 0:e.parentNode))||e.removeChild(this.element)}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_updateOptions(e){var t;switch(super._updateOptions(e),e){case"fontFamily":case"fontSize":null!=(t=this._renderService)&&t.clear(),null!=(t=this._charSizeService)&&t.measure();break;case"cursorBlink":case"cursorStyle":this.refresh(this.buffer.y,this.buffer.y);break;case"customGlyphs":case"drawBoldTextInBrightColors":case"letterSpacing":case"lineHeight":case"fontWeight":case"fontWeightBold":case"minimumContrastRatio":this._renderService&&(this._renderService.clear(),this._renderService.onResize(this.cols,this.rows),this.refresh(0,this.rows-1));break;case"scrollback":null!=(t=this.viewport)&&t.syncScrollArea();break;case"screenReaderMode":this.optionsService.rawOptions.screenReaderMode?!this._accessibilityManager&&this._renderService&&(this._accessibilityManager=new d.AccessibilityManager(this,this._renderService)):(null!=(t=this._accessibilityManager)&&t.dispose(),this._accessibilityManager=void 0);break;case"tabStopWidth":this.buffers.setupTabStops();break;case"theme":this._setTheme(this.optionsService.rawOptions.theme)}}_onTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(o.C0.ESC+"[I"),this.updateCursorStyle(e),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return null==(e=this.textarea)?void 0:e.blur()}_onTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(o.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){var e,t,i,r;this.textarea&&this.buffer.isCursorInViewport&&!this._compositionHelper.isComposing&&this._renderService&&(t=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(t))&&(r=Math.min(this.buffer.x,this.cols-1),e=this._renderService.dimensions.actualCellHeight,t=t.getWidth(r),t=this._renderService.dimensions.actualCellWidth*t,i=this.buffer.y*this._renderService.dimensions.actualCellHeight,r=r*this._renderService.dimensions.actualCellWidth,this.textarea.style.left=r+"px",this.textarea.style.top=i+"px",this.textarea.style.width=t+"px",this.textarea.style.height=e+"px",this.textarea.style.lineHeight=e+"px",this.textarea.style.zIndex="-5")}_initGlobal(){this._bindKeys(),this.register((0,c.addDisposableDomListener)(this.element,"copy",e=>{this.hasSelection()&&(0,n.copyHandler)(e,this._selectionService)}));var e=e=>(0,n.handlePasteEvent)(e,this.textarea,this.coreService);this.register((0,c.addDisposableDomListener)(this.textarea,"paste",e)),this.register((0,c.addDisposableDomListener)(this.element,"paste",e)),l.isFirefox?this.register((0,c.addDisposableDomListener)(this.element,"mousedown",e=>{2===e.button&&(0,n.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this.register((0,c.addDisposableDomListener)(this.element,"contextmenu",e=>{(0,n.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),l.isLinux&&this.register((0,c.addDisposableDomListener)(this.element,"auxclick",e=>{1===e.button&&(0,n.moveTextAreaUnderMouseCursor)(e,this.textarea,this.screenElement)}))}_bindKeys(){this.register((0,c.addDisposableDomListener)(this.textarea,"keyup",e=>this._keyUp(e),!0)),this.register((0,c.addDisposableDomListener)(this.textarea,"keydown",e=>this._keyDown(e),!0)),this.register((0,c.addDisposableDomListener)(this.textarea,"keypress",e=>this._keyPress(e),!0)),this.register((0,c.addDisposableDomListener)(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this.register((0,c.addDisposableDomListener)(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this.register((0,c.addDisposableDomListener)(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this.register((0,c.addDisposableDomListener)(this.textarea,"input",e=>this._inputEvent(e),!0)),this.register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=e.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),this.element.setAttribute("tabindex","0"),e.appendChild(this.element);var e=M.createDocumentFragment(),t=(this._viewportElement=M.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),e.appendChild(this._viewportElement),this._viewportScrollArea=M.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=M.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=M.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),e.appendChild(this.screenElement),this.textarea=M.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",_.promptLabel),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((0,c.addDisposableDomListener)(this.textarea,"focus",e=>this._onTextAreaFocus(e))),this.register((0,c.addDisposableDomListener)(this.textarea,"blur",()=>this._onTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._coreBrowserService=this._instantiationService.createInstance(w.CoreBrowserService,this.textarea,null!=(t=this._document.defaultView)?t:window),this._instantiationService.setService(m.ICoreBrowserService,this._coreBrowserService),this._charSizeService=this._instantiationService.createInstance(C.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(m.ICharSizeService,this._charSizeService),this._theme=this.options.theme||this._theme,this._colorManager=new p.ColorManager(M,this.options.allowTransparency),this.register(this.optionsService.onOptionChange(e=>this._colorManager.onOptionsChange(e,this.optionsService.rawOptions[e]))),this._colorManager.setTheme(this._theme),this._characterJoinerService=this._instantiationService.createInstance(R.CharacterJoinerService),this._instantiationService.setService(m.ICharacterJoinerService,this._characterJoinerService),this._createRenderer());this._renderService=this.register(this._instantiationService.createInstance(S.RenderService,t,this.rows,this.screenElement)),this._instantiationService.setService(m.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=M.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(r.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(e),this._mouseService=this._instantiationService.createInstance(b.MouseService),this._instantiationService.setService(m.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(s.Viewport,e=>this.scrollLines(e,!0,1),this._viewportElement,this._viewportScrollArea,this.element),this.viewport.onThemeChange(this._colorManager.colors),this.register(this._inputHandler.onRequestSyncScrollBar(()=>this.viewport.syncScrollArea())),this.register(this.viewport),this.register(this.onCursorMove(()=>{this._renderService.onCursorMove(),this._syncTextArea()})),this.register(this.onResize(()=>this._renderService.onResize(this.cols,this.rows))),this.register(this.onBlur(()=>this._renderService.onBlur())),this.register(this.onFocus(()=>this._renderService.onFocus())),this.register(this._renderService.onDimensionsChange(()=>this.viewport.syncScrollArea())),this._selectionService=this.register(this._instantiationService.createInstance(h.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(m.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this.register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this.register(this._selectionService.onRequestRedraw(e=>this._renderService.onSelectionChanged(e.start,e.end,e.columnSelectMode))),this.register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this.register(this._onScroll.event(e=>{this.viewport.syncScrollArea(),this._selectionService.refresh()})),this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",()=>this._selectionService.refresh())),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(D.BufferDecorationRenderer,this.screenElement)),this.register((0,c.addDisposableDomListener)(this.element,"mousedown",e=>this._selectionService.onMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager=new d.AccessibilityManager(this,this._renderService)),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(A.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onOptionChange(()=>{!this._overviewRulerRenderer&&this.options.overviewRulerWidth&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(A.OverviewRulerRenderer,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(u.DomRenderer,this._colorManager.colors,this.element,this.screenElement,this._viewportElement,this.linkifier2)}_setTheme(e){var t;this._theme=e,null!=(t=this._colorManager)&&t.setTheme(e),null!=(t=this._renderService)&&t.setColors(this._colorManager.colors),null!=(e=this.viewport)&&e.onThemeChange(this._colorManager.colors)}bindMouse(){let s=this,t=this.element;function i(i){var r=s._mouseService.getMouseReportCoords(i,s.screenElement);if(r){let e,t;switch(i.overrideType||i.type){case"mousemove":t=32,void 0===i.buttons?(e=3,void 0!==i.button&&(e=i.button<3?i.button:3)):e=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":t=0,e=i.button<3?i.button:3;break;case"mousedown":t=1,e=i.button<3?i.button:3;break;case"wheel":if(0===s.viewport.getLinesScrolled(i))return;t=i.deltaY<0?0:1,e=4;break;default:return}void 0===t||void 0===e||4<e||s.coreMouseService.triggerMouseEvent({col:r.col,row:r.row,x:r.x,y:r.y,button:e,action:t,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:e=>(i(e),e.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(e)),wheel:e=>(i(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&i(e)},mousemove:e=>{e.buttons||i(e)}};this.register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),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()),8&e?n.mousemove||(t.addEventListener("mousemove",r.mousemove),n.mousemove=r.mousemove):(t.removeEventListener("mousemove",n.mousemove),n.mousemove=null),16&e?n.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),n.wheel=r.wheel):(t.removeEventListener("wheel",n.wheel),n.wheel=null),2&e?n.mouseup||(n.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),4&e?n.mousedrag||(n.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,c.addDisposableDomListener)(t,"mousedown",e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return i(e),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(e)})),this.register((0,c.addDisposableDomListener)(t,"wheel",e=>{if(!n.wheel){if(this.buffer.hasScrollback)return this.viewport.onWheel(e)?this.cancel(e):void 0;{var i=this.viewport.getLinesScrolled(e);if(0===i)return;var r=o.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(e.deltaY<0?"A":"B");let t="";for(let e=0;e<Math.abs(i);e++)t+=r;return this.coreService.triggerDataEvent(t,!0),this.cancel(e,!0)}}},{passive:!1})),this.register((0,c.addDisposableDomListener)(t,"touchstart",e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.onTouchStart(e),this.cancel(e)},{passive:!0})),this.register((0,c.addDisposableDomListener)(t,"touchmove",e=>this.coreMouseService.areMouseEventsActive||this.viewport.onTouchMove(e)?void 0:this.cancel(e),{passive:!1}))}refresh(e,t){var i;null!=(i=this._renderService)&&i.refreshRows(e,t)}updateCursorStyle(e){var t;null!=(t=this._selectionService)&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t,i=0){super.scrollLines(e,t,i),this.refresh(0,this.rows-1)}paste(e){(0,n.paste)(e,this.textarea,this.coreService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}registerLinkProvider(e){return this.linkifier2.registerLinkProvider(e)}registerCharacterJoiner(e){if(this._characterJoinerService)return e=this._characterJoinerService.register(e),this.refresh(0,this.rows-1),e;throw new Error("Terminal must be opened first")}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}addMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;null!=(e=this._selectionService)&&e.clearSelection()}selectAll(){var e;null!=(e=this._selectionService)&&e.selectAll()}selectLines(e,t){var i;null!=(i=this._selectionService)&&i.selectLines(e,t)}_keyDown(t){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(t))return!1;let e=this.browser.isMac&&this.options.macOptionIsMeta&&t.altKey;if(!e&&!this._compositionHelper.keydown(t))return this.buffer.ybase!==this.buffer.ydisp&&this._bufferService.scrollToBottom(),!1;e||"Dead"!==t.key&&"AltGraph"!==t.key||(this._unprocessedDeadKey=!0);var i=(0,f.evaluateKeyboardEvent)(t,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(t),3!==i.type&&2!==i.type)return 1===i.type&&this.selectAll(),!!this._isThirdLevelShift(this.browser,t)||(i.cancel&&this.cancel(t,!0),!i.key)||!!(t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&1===t.key.length&&65<=t.key.charCodeAt(0)&&t.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?!(this._unprocessedDeadKey=!1):(i.key!==o.C0.ETX&&i.key!==o.C0.CR||(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:t}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),this.optionsService.rawOptions.screenReaderMode?void(this._keyDownHandled=!0):this.cancel(t,!0)));{let e=this.rows-1;return this.scrollLines(2===i.type?-e:e),this.cancel(t,!0)}}_isThirdLevelShift(e,t){e=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return"keypress"===t.type?e:e&&(!t.keyCode||47<t.keyCode)}_keyUp(e){this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16!==e.keyCode&&17!==e.keyCode&&18!==e.keyCode&&this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled)return!1;if(this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(null==e.which)t=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)||(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1))}_inputEvent(e){if(!e.data||"insertText"!==e.inputType||e.composed&&this._keyDownSeen||this.optionsService.rawOptions.screenReaderMode)return!1;if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;var t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}resize(e,t){e!==this.cols||t!==this.rows?super.resize(e,t):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(e,t){var i;null!=(i=this._charSizeService)&&i.measure(),null!=(i=this.viewport)&&i.syncScrollArea(!0)}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(g.DEFAULT_ATTR_DATA));this.refresh(0,this.rows-1),this._onScroll.fire({position:this.buffer.ydisp,source:0})}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;var e,t=this._customKeyEventHandler;this._setup(),super.reset(),null!=(e=this._selectionService)&&e.reset(),this._decorationService.reset(),this._customKeyEventHandler=t,this.refresh(0,this.rows-1),null!=(e=this.viewport)&&e.syncScrollArea()}clearTextureAtlas(){var e;null!=(e=this._renderService)&&e.clearTextureAtlas()}_reportFocus(){var e;null!=(e=this.element)&&e.classList.contains("focus")?this.coreService.triggerDataEvent(o.C0.ESC+"[I"):this.coreService.triggerDataEvent(o.C0.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case a.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:let e=this._renderService.dimensions.canvasWidth.toFixed(0),t=this._renderService.dimensions.canvasHeight.toFixed(0);this.coreService.triggerDataEvent(`${o.C0.ESC}[4;${t};${e}t`);break;case a.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:var i=this._renderService.dimensions.actualCellWidth.toFixed(