UNPKG

ssh-terminal

Version:

SSH Terminal component based on xterm.js for multiple frontend frameworks

5 lines (4 loc) 621 kB
(function(tr,rr){typeof exports=="object"&&typeof module<"u"?module.exports=rr():typeof define=="function"&&define.amd?define(rr):(tr=typeof globalThis<"u"?globalThis:tr||self,tr.SshTerminal=rr())})(this,function(){"use strict";function tr(e,t){for(var i=0;i<t.length;i++){const r=t[i];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in e)){const c=Object.getOwnPropertyDescriptor(r,n);c&&Object.defineProperty(e,n,c.get?c:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}class rr{constructor(){this.tabId=this.getOrCreateTabId()}getOrCreateTabId(){const t=`tab-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return console.log("🆕 Created new Tab ID:",t),t}getTabId(){return this.tabId}}const vn=new rr;var gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function mn(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var i=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(i,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}),i}var Ki={exports:{}};(function(e,t){(function(i,r){e.exports=r()})(self,()=>(()=>{var i={4567:function(a,s,o){var l=this&&this.__decorate||function(v,C,S,b){var w,E=arguments.length,x=E<3?C:b===null?b=Object.getOwnPropertyDescriptor(C,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(v,C,S,b);else for(var k=v.length-1;k>=0;k--)(w=v[k])&&(x=(E<3?w(x):E>3?w(C,S,x):w(C,S))||x);return E>3&&x&&Object.defineProperty(C,S,x),x},f=this&&this.__param||function(v,C){return function(S,b){C(S,b,v)}};Object.defineProperty(s,"__esModule",{value:!0}),s.AccessibilityManager=void 0;const u=o(9042),g=o(6114),_=o(9924),m=o(844),y=o(5596),h=o(4725),d=o(3656);let p=s.AccessibilityManager=class extends m.Disposable{constructor(v,C){super(),this._terminal=v,this._renderService=C,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new _.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(S=>this._handleResize(S.rows))),this.register(this._terminal.onRender(S=>this._refreshRows(S.start,S.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(S=>this._handleChar(S))),this.register(this._terminal.onLineFeed(()=>this._handleChar(` `))),this.register(this._terminal.onA11yTab(S=>this._handleTab(S))),this.register(this._terminal.onKey(S=>this._handleKey(S.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._screenDprMonitor=new y.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener(()=>this._refreshRowsDimensions()),this.register((0,d.addDisposableDomListener)(window,"resize",()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,m.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(v){for(let C=0;C<v;C++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===` `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=u.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout(()=>{this._accessibilityContainer.appendChild(this._liveRegion)},0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(v){this._clearLiveRegion(),/\p{Control}/u.test(v)||this._charsToConsume.push(v)}_refreshRows(v,C){this._liveRegionDebouncer.refresh(v,C,this._terminal.rows)}_renderRows(v,C){const S=this._terminal.buffer,b=S.lines.length.toString();for(let w=v;w<=C;w++){const E=S.translateBufferLineToString(S.ydisp+w,!0),x=(S.ydisp+w+1).toString(),k=this._rowElements[w];k&&(E.length===0?k.innerText=" ":k.textContent=E,k.setAttribute("aria-posinset",x),k.setAttribute("aria-setsize",b))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,C){const S=v.target,b=this._rowElements[C===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(C===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==b)return;let w,E;if(C===0?(w=S,E=this._rowElements.pop(),this._rowContainer.removeChild(E)):(w=this._rowElements.shift(),E=S,this._rowContainer.removeChild(w)),w.removeEventListener("focus",this._topBoundaryFocusListener),E.removeEventListener("focus",this._bottomBoundaryFocusListener),C===0){const x=this._createAccessibilityTreeNode();this._rowElements.unshift(x),this._rowContainer.insertAdjacentElement("afterbegin",x)}else{const x=this._createAccessibilityTreeNode();this._rowElements.push(x),this._rowContainer.appendChild(x)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(C===0?-1:1),this._rowElements[C===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleResize(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let C=this._rowContainer.children.length;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=document.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};s.AccessibilityManager=p=l([f(1,h.IRenderService)],p)},3614:(a,s)=>{function o(g){return g.replace(/\r?\n/g,"\r")}function l(g,_){return _?"\x1B[200~"+g+"\x1B[201~":g}function f(g,_,m,y){g=l(g=o(g),m.decPrivateModes.bracketedPasteMode&&y.rawOptions.ignoreBracketedPasteMode!==!0),m.triggerDataEvent(g,!0),_.value=""}function u(g,_,m){const y=m.getBoundingClientRect(),h=g.clientX-y.left-10,d=g.clientY-y.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${h}px`,_.style.top=`${d}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(s,"__esModule",{value:!0}),s.rightClickHandler=s.moveTextAreaUnderMouseCursor=s.paste=s.handlePasteEvent=s.copyHandler=s.bracketTextForPaste=s.prepareTextForTerminal=void 0,s.prepareTextForTerminal=o,s.bracketTextForPaste=l,s.copyHandler=function(g,_){g.clipboardData&&g.clipboardData.setData("text/plain",_.selectionText),g.preventDefault()},s.handlePasteEvent=function(g,_,m,y){g.stopPropagation(),g.clipboardData&&f(g.clipboardData.getData("text/plain"),_,m,y)},s.paste=f,s.moveTextAreaUnderMouseCursor=u,s.rightClickHandler=function(g,_,m,y,h){u(g,_,m),h&&y.rightClickSelect(g),_.value=y.selectionText,_.select()}},7239:(a,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ColorContrastCache=void 0;const l=o(1505);s.ColorContrastCache=class{constructor(){this._color=new l.TwoKeyMap,this._css=new l.TwoKeyMap}setCss(f,u,g){this._css.set(f,u,g)}getCss(f,u){return this._css.get(f,u)}setColor(f,u,g){this._color.set(f,u,g)}getColor(f,u){return this._color.get(f,u)}clear(){this._color.clear(),this._css.clear()}}},3656:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.addDisposableDomListener=void 0,s.addDisposableDomListener=function(o,l,f,u){o.addEventListener(l,f,u);let g=!1;return{dispose:()=>{g||(g=!0,o.removeEventListener(l,f,u))}}}},6465:function(a,s,o){var l=this&&this.__decorate||function(h,d,p,v){var C,S=arguments.length,b=S<3?d:v===null?v=Object.getOwnPropertyDescriptor(d,p):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(h,d,p,v);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(b=(S<3?C(b):S>3?C(d,p,b):C(d,p))||b);return S>3&&b&&Object.defineProperty(d,p,b),b},f=this&&this.__param||function(h,d){return function(p,v){d(p,v,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Linkifier2=void 0;const u=o(3656),g=o(8460),_=o(844),m=o(2585);let y=s.Linkifier2=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(h){super(),this._bufferService=h,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)(()=>{this._lastMouseEvent=void 0})),this.register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0}))}registerLinkProvider(h){return this._linkProviders.push(h),{dispose:()=>{const d=this._linkProviders.indexOf(h);d!==-1&&this._linkProviders.splice(d,1)}}}attachToDom(h,d,p){this._element=h,this._mouseService=d,this._renderService=p,this.register((0,u.addDisposableDomListener)(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this.register((0,u.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(h){if(this._lastMouseEvent=h,!this._element||!this._mouseService)return;const d=this._positionFromMouseEvent(h,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const p=h.composedPath();for(let v=0;v<p.length;v++){const C=p[v];if(C.classList.contains("xterm"))break;if(C.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(h){if(this._activeLine!==h.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(h,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,h)||(this._clearCurrentLink(),this._askForLink(h,!0))}_askForLink(h,d){var p,v;this._activeProviderReplies&&d||((p=this._activeProviderReplies)===null||p===void 0||p.forEach(S=>{S?.forEach(b=>{b.link.dispose&&b.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=h.y);let C=!1;for(const[S,b]of this._linkProviders.entries())d?!((v=this._activeProviderReplies)===null||v===void 0)&&v.get(S)&&(C=this._checkLinkProviderResult(S,h,C)):b.provideLinks(h.y,w=>{var E,x;if(this._isMouseOut)return;const k=w?.map(N=>({link:N}));(E=this._activeProviderReplies)===null||E===void 0||E.set(S,k),C=this._checkLinkProviderResult(S,h,C),((x=this._activeProviderReplies)===null||x===void 0?void 0:x.size)===this._linkProviders.length&&this._removeIntersectingLinks(h.y,this._activeProviderReplies)})}_removeIntersectingLinks(h,d){const p=new Set;for(let v=0;v<d.size;v++){const C=d.get(v);if(C)for(let S=0;S<C.length;S++){const b=C[S],w=b.link.range.start.y<h?0:b.link.range.start.x,E=b.link.range.end.y>h?this._bufferService.cols:b.link.range.end.x;for(let x=w;x<=E;x++){if(p.has(x)){C.splice(S--,1);break}p.add(x)}}}}_checkLinkProviderResult(h,d,p){var v;if(!this._activeProviderReplies)return p;const C=this._activeProviderReplies.get(h);let S=!1;for(let b=0;b<h;b++)this._activeProviderReplies.has(b)&&!this._activeProviderReplies.get(b)||(S=!0);if(!S&&C){const b=C.find(w=>this._linkAtPosition(w.link,d));b&&(p=!0,this._handleNewLink(b))}if(this._activeProviderReplies.size===this._linkProviders.length&&!p)for(let b=0;b<this._activeProviderReplies.size;b++){const w=(v=this._activeProviderReplies.get(b))===null||v===void 0?void 0:v.find(E=>this._linkAtPosition(E.link,d));if(w){p=!0,this._handleNewLink(w);break}}return p}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(h){if(!this._element||!this._mouseService||!this._currentLink)return;const d=this._positionFromMouseEvent(h,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(h,this._currentLink.link.text)}_clearCurrentLink(h,d){this._element&&this._currentLink&&this._lastMouseEvent&&(!h||!d||this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(h){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(h.link,d)&&(this._currentLink=h,this._currentLink.state={decorations:{underline:h.link.decorations===void 0||h.link.decorations.underline,pointerCursor:h.link.decorations===void 0||h.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,h.link,this._lastMouseEvent),h.link.decorations={},Object.defineProperties(h.link.decorations,{pointerCursor:{get:()=>{var p,v;return(v=(p=this._currentLink)===null||p===void 0?void 0:p.state)===null||v===void 0?void 0:v.decorations.pointerCursor},set:p=>{var v,C;!((v=this._currentLink)===null||v===void 0)&&v.state&&this._currentLink.state.decorations.pointerCursor!==p&&(this._currentLink.state.decorations.pointerCursor=p,this._currentLink.state.isHovered&&((C=this._element)===null||C===void 0||C.classList.toggle("xterm-cursor-pointer",p)))}},underline:{get:()=>{var p,v;return(v=(p=this._currentLink)===null||p===void 0?void 0:p.state)===null||v===void 0?void 0:v.decorations.underline},set:p=>{var v,C,S;!((v=this._currentLink)===null||v===void 0)&&v.state&&((S=(C=this._currentLink)===null||C===void 0?void 0:C.state)===null||S===void 0?void 0:S.decorations.underline)!==p&&(this._currentLink.state.decorations.underline=p,this._currentLink.state.isHovered&&this._fireUnderlineEvent(h.link,p))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(p=>{if(!this._currentLink)return;const v=p.start===0?0:p.start+1+this._bufferService.buffer.ydisp,C=this._bufferService.buffer.ydisp+1+p.end;if(this._currentLink.link.range.start.y>=v&&this._currentLink.link.range.end.y<=C&&(this._clearCurrentLink(v,C),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}})))}_linkHover(h,d,p){var v;!((v=this._currentLink)===null||v===void 0)&&v.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&h.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(p,d.text)}_fireUnderlineEvent(h,d){const p=h.range,v=this._bufferService.buffer.ydisp,C=this._createLinkUnderlineEvent(p.start.x-1,p.start.y-v-1,p.end.x,p.end.y-v-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(C)}_linkLeave(h,d,p){var v;!((v=this._currentLink)===null||v===void 0)&&v.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&h.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(p,d.text)}_linkAtPosition(h,d){const p=h.range.start.y*this._bufferService.cols+h.range.start.x,v=h.range.end.y*this._bufferService.cols+h.range.end.x,C=d.y*this._bufferService.cols+d.x;return p<=C&&C<=v}_positionFromMouseEvent(h,d,p){const v=p.getCoords(h,d,this._bufferService.cols,this._bufferService.rows);if(v)return{x:v[0],y:v[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(h,d,p,v,C){return{x1:h,y1:d,x2:p,y2:v,cols:this._bufferService.cols,fg:C}}};s.Linkifier2=y=l([f(0,m.IBufferService)],y)},9042:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.tooMuchOutput=s.promptLabel=void 0,s.promptLabel="Terminal input",s.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(a,s,o){var l=this&&this.__decorate||function(y,h,d,p){var v,C=arguments.length,S=C<3?h:p===null?p=Object.getOwnPropertyDescriptor(h,d):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(y,h,d,p);else for(var b=y.length-1;b>=0;b--)(v=y[b])&&(S=(C<3?v(S):C>3?v(h,d,S):v(h,d))||S);return C>3&&S&&Object.defineProperty(h,d,S),S},f=this&&this.__param||function(y,h){return function(d,p){h(d,p,y)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OscLinkProvider=void 0;const u=o(511),g=o(2585);let _=s.OscLinkProvider=class{constructor(y,h,d){this._bufferService=y,this._optionsService=h,this._oscLinkService=d}provideLinks(y,h){var d;const p=this._bufferService.buffer.lines.get(y-1);if(!p)return void h(void 0);const v=[],C=this._optionsService.rawOptions.linkHandler,S=new u.CellData,b=p.getTrimmedLength();let w=-1,E=-1,x=!1;for(let k=0;k<b;k++)if(E!==-1||p.hasContent(k)){if(p.loadCell(k,S),S.hasExtendedAttrs()&&S.extended.urlId){if(E===-1){E=k,w=S.extended.urlId;continue}x=S.extended.urlId!==w}else E!==-1&&(x=!0);if(x||E!==-1&&k===b-1){const N=(d=this._oscLinkService.getLinkData(w))===null||d===void 0?void 0:d.uri;if(N){const D={start:{x:E+1,y},end:{x:k+(x||k!==b-1?0:1),y}};let M=!1;if(!C?.allowNonHttpProtocols)try{const $=new URL(N);["http:","https:"].includes($.protocol)||(M=!0)}catch{M=!0}M||v.push({text:N,range:D,activate:($,z)=>C?C.activate($,z,D):m(0,z),hover:($,z)=>{var Q;return(Q=C?.hover)===null||Q===void 0?void 0:Q.call(C,$,z,D)},leave:($,z)=>{var Q;return(Q=C?.leave)===null||Q===void 0?void 0:Q.call(C,$,z,D)}})}x=!1,S.hasExtendedAttrs()&&S.extended.urlId?(E=k,w=S.extended.urlId):(E=-1,w=-1)}}h(v)}};function m(y,h){if(confirm(`Do you want to navigate to ${h}? WARNING: This link could potentially be dangerous`)){const d=window.open();if(d){try{d.opener=null}catch{}d.location.href=h}else console.warn("Opening link blocked as opener could not be cleared")}}s.OscLinkProvider=_=l([f(0,g.IBufferService),f(1,g.IOptionsService),f(2,g.IOscLinkService)],_)},6193:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.RenderDebouncer=void 0,s.RenderDebouncer=class{constructor(o,l){this._parentWindow=o,this._renderCallback=l,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(o,l,f){this._rowCount=f,o=o!==void 0?o:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const o=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,l),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(a,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ScreenDprMonitor=void 0;const l=o(844);class f extends l.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,l.toDisposable)(()=>{this.clearListener()}))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.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)}}s.ScreenDprMonitor=f},3236:(a,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Terminal=void 0;const l=o(3614),f=o(3656),u=o(6465),g=o(9042),_=o(3730),m=o(1680),y=o(3107),h=o(5744),d=o(2950),p=o(1296),v=o(428),C=o(4269),S=o(5114),b=o(8934),w=o(3230),E=o(9312),x=o(4725),k=o(6731),N=o(8055),D=o(8969),M=o(8460),$=o(844),z=o(6114),Q=o(8437),W=o(2584),L=o(7399),O=o(5941),R=o(9074),P=o(2585),Y=o(5435),X=o(4567),ae=typeof window<"u"?window.document:null;class ie extends D.CoreTerminal{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}constructor(B={}){super(B),this.browser=z,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new $.MutableDisposable),this._onCursorMove=this.register(new M.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new M.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new M.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new M.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new M.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new M.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new M.EventEmitter),this._onBlur=this.register(new M.EventEmitter),this._onA11yCharEmitter=this.register(new M.EventEmitter),this._onA11yTabEmitter=this.register(new M.EventEmitter),this._onWillOpen=this.register(new M.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(u.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(R.DecorationService),this._instantiationService.setService(P.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this.register(this._inputHandler.onRequestRefreshRows((V,G)=>this.refresh(V,G))),this.register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this.register(this._inputHandler.onRequestReset(()=>this.reset())),this.register(this._inputHandler.onRequestWindowsOptionsReport(V=>this._reportWindowsOptions(V))),this.register(this._inputHandler.onColor(V=>this._handleColorEvent(V))),this.register((0,M.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,M.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,M.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize(V=>this._afterResize(V.cols,V.rows))),this.register((0,$.toDisposable)(()=>{var V,G;this._customKeyEventHandler=void 0,(G=(V=this.element)===null||V===void 0?void 0:V.parentNode)===null||G===void 0||G.removeChild(this.element)}))}_handleColorEvent(B){if(this._themeService)for(const V of B){let G,q="";switch(V.index){case 256:G="foreground",q="10";break;case 257:G="background",q="11";break;case 258:G="cursor",q="12";break;default:G="ansi",q="4;"+V.index}switch(V.type){case 0:const ce=N.color.toColorRGB(G==="ansi"?this._themeService.colors.ansi[V.index]:this._themeService.colors[G]);this.coreService.triggerDataEvent(`${W.C0.ESC}]${q};${(0,O.toRgbString)(ce)}${W.C1_ESCAPED.ST}`);break;case 1:if(G==="ansi")this._themeService.modifyColors(re=>re.ansi[V.index]=N.rgba.toColor(...V.color));else{const re=G;this._themeService.modifyColors(de=>de[re]=N.rgba.toColor(...V.color))}break;case 2:this._themeService.restoreColor(V.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(B){B?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(B){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[I"),this.updateCursorStyle(B),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var B;return(B=this.textarea)===null||B===void 0?void 0:B.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const B=this.buffer.ybase+this.buffer.y,V=this.buffer.lines.get(B);if(!V)return;const G=Math.min(this.buffer.x,this.cols-1),q=this._renderService.dimensions.css.cell.height,ce=V.getWidth(G),re=this._renderService.dimensions.css.cell.width*ce,de=this.buffer.y*this._renderService.dimensions.css.cell.height,xe=G*this._renderService.dimensions.css.cell.width;this.textarea.style.left=xe+"px",this.textarea.style.top=de+"px",this.textarea.style.width=re+"px",this.textarea.style.height=q+"px",this.textarea.style.lineHeight=q+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",V=>{this.hasSelection()&&(0,l.copyHandler)(V,this._selectionService)}));const B=V=>(0,l.handlePasteEvent)(V,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",B)),this.register((0,f.addDisposableDomListener)(this.element,"paste",B)),z.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",V=>{V.button===2&&(0,l.rightClickHandler)(V,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",V=>{(0,l.rightClickHandler)(V,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),z.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",V=>{V.button===1&&(0,l.moveTextAreaUnderMouseCursor)(V,this.textarea,this.screenElement)}))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",B=>this._keyUp(B),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",B=>this._keyDown(B),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",B=>this._keyPress(B),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",B=>this._compositionHelper.compositionupdate(B))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this.register((0,f.addDisposableDomListener)(this.textarea,"input",B=>this._inputEvent(B),!0)),this.register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(B){var V;if(!B)throw new Error("Terminal requires a parent element.");B.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=B.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),B.appendChild(this.element);const G=ae.createDocumentFragment();this._viewportElement=ae.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),G.appendChild(this._viewportElement),this._viewportScrollArea=ae.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=ae.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=ae.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),G.appendChild(this.screenElement),this.textarea=ae.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),z.isChromeOS||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._coreBrowserService=this._instantiationService.createInstance(S.CoreBrowserService,this.textarea,(V=this._document.defaultView)!==null&&V!==void 0?V:window),this._instantiationService.setService(x.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",q=>this._handleTextAreaFocus(q))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(v.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(x.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(k.ThemeService),this._instantiationService.setService(x.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(C.CharacterJoinerService),this._instantiationService.setService(x.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(w.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(x.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange(q=>this._onRender.fire(q))),this.onResize(q=>this._renderService.resize(q.cols,q.rows)),this._compositionView=ae.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(G);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(b.MouseService),this._instantiationService.setService(x.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(m.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines(q=>this.scrollLines(q.amount,q.suppressScrollEvent,1)),this.register(this._inputHandler.onRequestSyncScrollBar(()=>this.viewport.syncScrollArea())),this.register(this.viewport),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.register(this._renderService.onDimensionsChange(()=>this.viewport.syncScrollArea())),this._selectionService=this.register(this._instantiationService.createInstance(E.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(x.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(q=>this.scrollLines(q.amount,q.suppressScrollEvent))),this.register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this.register(this._selectionService.onRequestRedraw(q=>this._renderService.handleSelectionChanged(q.start,q.end,q.columnSelectMode))),this.register(this._selectionService.onLinuxMouseSelection(q=>{this.textarea.value=q,this.textarea.focus(),this.textarea.select()})),this.register(this._onScroll.event(q=>{this.viewport.syncScrollArea(),this._selectionService.refresh()})),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",()=>this._selectionService.refresh())),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(y.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",q=>this._selectionService.handleMouseDown(q))),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(X.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",q=>this._handleScreenReaderModeOptionChange(q))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(h.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",q=>{!this._overviewRulerRenderer&&q&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(h.OverviewRulerRenderer,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(p.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const B=this,V=this.element;function G(re){const de=B._mouseService.getMouseReportCoords(re,B.screenElement);if(!de)return!1;let xe,Ae;switch(re.overrideType||re.type){case"mousemove":Ae=32,re.buttons===void 0?(xe=3,re.button!==void 0&&(xe=re.button<3?re.button:3)):xe=1&re.buttons?0:4&re.buttons?1:2&re.buttons?2:3;break;case"mouseup":Ae=0,xe=re.button<3?re.button:3;break;case"mousedown":Ae=1,xe=re.button<3?re.button:3;break;case"wheel":if(B.viewport.getLinesScrolled(re)===0)return!1;Ae=re.deltaY<0?0:1,xe=4;break;default:return!1}return!(Ae===void 0||xe===void 0||xe>4)&&B.coreMouseService.triggerMouseEvent({col:de.col,row:de.row,x:de.x,y:de.y,button:xe,action:Ae,ctrl:re.ctrlKey,alt:re.altKey,shift:re.shiftKey})}const q={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ce={mouseup:re=>(G(re),re.buttons||(this._document.removeEventListener("mouseup",q.mouseup),q.mousedrag&&this._document.removeEventListener("mousemove",q.mousedrag)),this.cancel(re)),wheel:re=>(G(re),this.cancel(re,!0)),mousedrag:re=>{re.buttons&&G(re)},mousemove:re=>{re.buttons||G(re)}};this.register(this.coreMouseService.onProtocolChange(re=>{re?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(re)),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&re?q.mousemove||(V.addEventListener("mousemove",ce.mousemove),q.mousemove=ce.mousemove):(V.removeEventListener("mousemove",q.mousemove),q.mousemove=null),16&re?q.wheel||(V.addEventListener("wheel",ce.wheel,{passive:!1}),q.wheel=ce.wheel):(V.removeEventListener("wheel",q.wheel),q.wheel=null),2&re?q.mouseup||(V.addEventListener("mouseup",ce.mouseup),q.mouseup=ce.mouseup):(this._document.removeEventListener("mouseup",q.mouseup),V.removeEventListener("mouseup",q.mouseup),q.mouseup=null),4&re?q.mousedrag||(q.mousedrag=ce.mousedrag):(this._document.removeEventListener("mousemove",q.mousedrag),q.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(V,"mousedown",re=>{if(re.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(re))return G(re),q.mouseup&&this._document.addEventListener("mouseup",q.mouseup),q.mousedrag&&this._document.addEventListener("mousemove",q.mousedrag),this.cancel(re)})),this.register((0,f.addDisposableDomListener)(V,"wheel",re=>{if(!q.wheel){if(!this.buffer.hasScrollback){const de=this.viewport.getLinesScrolled(re);if(de===0)return;const xe=W.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(re.deltaY<0?"A":"B");let Ae="";for(let er=0;er<Math.abs(de);er++)Ae+=xe;return this.coreService.triggerDataEvent(Ae,!0),this.cancel(re,!0)}return this.viewport.handleWheel(re)?this.cancel(re):void 0}},{passive:!1})),this.register((0,f.addDisposableDomListener)(V,"touchstart",re=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(re),this.cancel(re)},{passive:!0})),this.register((0,f.addDisposableDomListener)(V,"touchmove",re=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(re)?void 0:this.cancel(re)},{passive:!1}))}refresh(B,V){var G;(G=this._renderService)===null||G===void 0||G.refreshRows(B,V)}updateCursorStyle(B){var V;!((V=this._selectionService)===null||V===void 0)&&V.shouldColumnSelect(B)?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(B,V,G=0){var q;G===1?(super.scrollLines(B,V,G),this.refresh(0,this.rows-1)):(q=this.viewport)===null||q===void 0||q.scrollLines(B)}paste(B){(0,l.paste)(B,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(B){this._customKeyEventHandler=B}registerLinkProvider(B){return this.linkifier2.registerLinkProvider(B)}registerCharacterJoiner(B){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const V=this._characterJoinerService.register(B);return this.refresh(0,this.rows-1),V}deregisterCharacterJoiner(B){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(B)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(B){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+B)}registerDecoration(B){return this._decorationService.registerDecoration(B)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(B,V,G){this._selectionService.setSelection(B,V,G)}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 B;(B=this._selectionService)===null||B===void 0||B.clearSelection()}selectAll(){var B;(B=this._selectionService)===null||B===void 0||B.selectAll()}selectLines(B,V){var G;(G=this._selectionService)===null||G===void 0||G.selectLines(B,V)}_keyDown(B){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(B)===!1)return!1;const V=this.browser.isMac&&this.options.macOptionIsMeta&&B.altKey;if(!V&&!this._compositionHelper.keydown(B))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;V||B.key!=="Dead"&&B.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const G=(0,L.evaluateKeyboardEvent)(B,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(B),G.type===3||G.type===2){const q=this.rows-1;return this.scrollLines(G.type===2?-q:q),this.cancel(B,!0)}return G.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,B)||(G.cancel&&this.cancel(B,!0),!G.key||!!(B.key&&!B.ctrlKey&&!B.altKey&&!B.metaKey&&B.key.length===1&&B.key.charCodeAt(0)>=65&&B.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(G.key!==W.C0.ETX&&G.key!==W.C0.CR||(this.textarea.value=""),this._onKey.fire({key:G.key,domEvent:B}),this._showCursor(),this.coreService.triggerDataEvent(G.key,!0),!this.optionsService.rawOptions.screenReaderMode||B.altKey||B.ctrlKey?this.cancel(B,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(B,V){const G=B.isMac&&!this.options.macOptionIsMeta&&V.altKey&&!V.ctrlKey&&!V.metaKey||B.isWindows&&V.altKey&&V.ctrlKey&&!V.metaKey||B.isWindows&&V.getModifierState("AltGraph");return V.type==="keypress"?G:G&&(!V.keyCode||V.keyCode>47)}_keyUp(B){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(B)===!1||(function(V){return V.keyCode===16||V.keyCode===17||V.keyCode===18}(B)||this.focus(),this.updateCursorStyle(B),this._keyPressHandled=!1)}_keyPress(B){let V;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(B)===!1)return!1;if(this.cancel(B),B.charCode)V=B.charCode;else if(B.which===null||B.which===void 0)V=B.keyCode;else{if(B.which===0||B.charCode===0)return!1;V=B.which}return!(!V||(B.altKey||B.ctrlKey||B.metaKey)&&!this._isThirdLevelShift(this.browser,B)||(V=String.fromCharCode(V),this._onKey.fire({key:V,domEvent:B}),this._showCursor(),this.coreService.triggerDataEvent(V,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(B){if(B.data&&B.inputType==="insertText"&&(!B.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const V=B.data;return this.coreService.triggerDataEvent(V,!0),this.cancel(B),!0}return!1}resize(B,V){B!==this.cols||V!==this.rows?super.resize(B,V):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(B,V){var G,q;(G=this._charSizeService)===null||G===void 0||G.measure(),(q=this.viewport)===null||q===void 0||q.syncScrollArea(!0)}clear(){var B;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 V=1;V<this.rows;V++)this.buffer.lines.push(this.buffer.getBlankLine(Q.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(B=this.viewport)===null||B===void 0||B.reset(),this.refresh(0,this.rows-1)}}reset(){var B,V;this.options.rows=this.rows,this.options.cols=this.cols;const G=this._customKeyEventHandler;this._setup(),super.reset(),(B=this._selectionService)===null||B===void 0||B.reset(),this._decorationService.reset(),(V=this.viewport)===null||V===void 0||V.reset(),this._customKeyEventHandler=G,this.refresh(0,this.rows-1)}clearTextureAtlas(){var B;(B=this._renderService)===null||B===void 0||B.clearTextureAtlas()}_reportFocus(){var B;!((B=this.element)===null||B===void 0)&&B.classList.contains("focus")?this.coreService.triggerDataEvent(W.C0.ESC+"[I"):this.coreService.triggerDataEvent(W.C0.ESC+"[O")}_reportWindowsOptions(B){if(this._renderService)switch(B){case Y.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const V=this._renderService.dimensions.css.canvas.width.toFixed(0),G=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[4;${G};${V}t`);break;case Y.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const q=this._renderService.dimensions.css.cell.width.toFixed(0),ce=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[6;${ce};${q}t`)}}cancel(B,V){if(this.options.cancelEvents||V)return B.preventDefault(),B.stopPropagation(),!1}}s.Terminal=ie},9924:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TimeBasedDebouncer=void 0,s.TimeBasedDebouncer=class{constructor(o,l=1e3){this._renderCallback=o,this._debounceThresholdMS=l,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,l,f){this._rowCount=f,o=o!==void 0?o:0,l=l!==void 0?l:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,l):l;const u=Date.now();if(u-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=u,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=u-this._lastRefreshMs,_=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},_)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const o=Math.max(this._rowStart,0),l=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,l)}}},1680:function(a,s,o){var l=this&&this.__decorate||function(d,p,v,C){var S,b=arguments.length,w=b<3?p:C===null?C=Object.getOwnPropertyDescriptor(p,v):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,p,v,C);else for(var E=d.length-1;E>=0;E--)(S=d[E])&&(w=(b<3?S(w):b>3?S(p,v,w):S(p,v))||w);return b>3&&w&&Object.defineProperty(p,v,w),w},f=this&&this.__param||function(d,p){return function(v,C){p(v,C,d)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Viewport=void 0;const u=o(3656),g=o(4725),_=o(8460),m=o(844),y=o(2585);let h=s.Viewport=class extends m.Disposable{constructor(d,p,v,C,S,b,w,E){super(),this._viewportElement=d,this._scrollArea=p,this._bufferService=v,this._optionsService=C,this._charSizeService=S,this._renderService=b,this._coreBrowserService=w,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(x=>this._activeBuffer=x.activeBuffer)),this._renderDimensions=this._renderServic