UNPKG

ssh-terminal

Version:

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

651 lines (650 loc) 455 kB
var be = { exports: {} }; (function(ee, E) { (function(D, M) { ee.exports = M(); })(self, () => (() => { var D = { 4567: function(T, s, o) { var h = this && this.__decorate || function(r, a, u, p) { var m, d = arguments.length, g = d < 3 ? a : p === null ? p = Object.getOwnPropertyDescriptor(a, u) : p; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") g = Reflect.decorate(r, a, u, p); else for (var y = r.length - 1; y >= 0; y--) (m = r[y]) && (g = (d < 3 ? m(g) : d > 3 ? m(a, u, g) : m(a, u)) || g); return d > 3 && g && Object.defineProperty(a, u, g), g; }, f = this && this.__param || function(r, a) { return function(u, p) { a(u, p, r); }; }; Object.defineProperty(s, "__esModule", { value: !0 }), s.AccessibilityManager = void 0; const n = o(9042), l = o(6114), _ = o(9924), v = o(844), c = o(5596), e = o(4725), i = o(3656); let t = s.AccessibilityManager = class extends v.Disposable { constructor(r, a) { super(), this._terminal = r, this._renderService = a, 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 u = 0; u < this._terminal.rows; u++) this._rowElements[u] = this._createAccessibilityTreeNode(), this._rowContainer.appendChild(this._rowElements[u]); if (this._topBoundaryFocusListener = (u) => this._handleBoundaryFocus(u, 0), this._bottomBoundaryFocusListener = (u) => this._handleBoundaryFocus(u, 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((u) => this._handleResize(u.rows))), this.register(this._terminal.onRender((u) => this._refreshRows(u.start, u.end))), this.register(this._terminal.onScroll(() => this._refreshRows())), this.register(this._terminal.onA11yChar((u) => this._handleChar(u))), this.register(this._terminal.onLineFeed(() => this._handleChar(` `))), this.register(this._terminal.onA11yTab((u) => this._handleTab(u))), this.register(this._terminal.onKey((u) => this._handleKey(u.key))), this.register(this._terminal.onBlur(() => this._clearLiveRegion())), this.register(this._renderService.onDimensionsChange(() => this._refreshRowsDimensions())), this._screenDprMonitor = new c.ScreenDprMonitor(window), this.register(this._screenDprMonitor), this._screenDprMonitor.setListener(() => this._refreshRowsDimensions()), this.register((0, i.addDisposableDomListener)(window, "resize", () => this._refreshRowsDimensions())), this._refreshRows(), this.register((0, v.toDisposable)(() => { this._accessibilityContainer.remove(), this._rowElements.length = 0; })); } _handleTab(r) { for (let a = 0; a < r; a++) this._handleChar(" "); } _handleChar(r) { this._liveRegionLineCount < 21 && (this._charsToConsume.length > 0 ? this._charsToConsume.shift() !== r && (this._charsToAnnounce += r) : this._charsToAnnounce += r, r === ` ` && (this._liveRegionLineCount++, this._liveRegionLineCount === 21 && (this._liveRegion.textContent += n.tooMuchOutput)), l.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, l.isMac && this._liveRegion.remove(); } _handleKey(r) { this._clearLiveRegion(), /\p{Control}/u.test(r) || this._charsToConsume.push(r); } _refreshRows(r, a) { this._liveRegionDebouncer.refresh(r, a, this._terminal.rows); } _renderRows(r, a) { const u = this._terminal.buffer, p = u.lines.length.toString(); for (let m = r; m <= a; m++) { const d = u.translateBufferLineToString(u.ydisp + m, !0), g = (u.ydisp + m + 1).toString(), y = this._rowElements[m]; y && (d.length === 0 ? y.innerText = " " : y.textContent = d, y.setAttribute("aria-posinset", g), y.setAttribute("aria-setsize", p)); } this._announceCharacters(); } _announceCharacters() { this._charsToAnnounce.length !== 0 && (this._liveRegion.textContent += this._charsToAnnounce, this._charsToAnnounce = ""); } _handleBoundaryFocus(r, a) { const u = r.target, p = this._rowElements[a === 0 ? 1 : this._rowElements.length - 2]; if (u.getAttribute("aria-posinset") === (a === 0 ? "1" : `${this._terminal.buffer.lines.length}`) || r.relatedTarget !== p) return; let m, d; if (a === 0 ? (m = u, d = this._rowElements.pop(), this._rowContainer.removeChild(d)) : (m = this._rowElements.shift(), d = u, this._rowContainer.removeChild(m)), m.removeEventListener("focus", this._topBoundaryFocusListener), d.removeEventListener("focus", this._bottomBoundaryFocusListener), a === 0) { const g = this._createAccessibilityTreeNode(); this._rowElements.unshift(g), this._rowContainer.insertAdjacentElement("afterbegin", g); } else { const g = this._createAccessibilityTreeNode(); this._rowElements.push(g), this._rowContainer.appendChild(g); } this._rowElements[0].addEventListener("focus", this._topBoundaryFocusListener), this._rowElements[this._rowElements.length - 1].addEventListener("focus", this._bottomBoundaryFocusListener), this._terminal.scrollLines(a === 0 ? -1 : 1), this._rowElements[a === 0 ? 1 : this._rowElements.length - 2].focus(), r.preventDefault(), r.stopImmediatePropagation(); } _handleResize(r) { this._rowElements[this._rowElements.length - 1].removeEventListener("focus", this._bottomBoundaryFocusListener); for (let a = this._rowContainer.children.length; a < this._terminal.rows; a++) this._rowElements[a] = this._createAccessibilityTreeNode(), this._rowContainer.appendChild(this._rowElements[a]); for (; this._rowElements.length > r; ) this._rowContainer.removeChild(this._rowElements.pop()); this._rowElements[this._rowElements.length - 1].addEventListener("focus", this._bottomBoundaryFocusListener), this._refreshRowsDimensions(); } _createAccessibilityTreeNode() { const r = document.createElement("div"); return r.setAttribute("role", "listitem"), r.tabIndex = -1, this._refreshRowDimensions(r), r; } _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 r = 0; r < this._terminal.rows; r++) this._refreshRowDimensions(this._rowElements[r]); } } _refreshRowDimensions(r) { r.style.height = `${this._renderService.dimensions.css.cell.height}px`; } }; s.AccessibilityManager = t = h([f(1, e.IRenderService)], t); }, 3614: (T, s) => { function o(l) { return l.replace(/\r?\n/g, "\r"); } function h(l, _) { return _ ? "\x1B[200~" + l + "\x1B[201~" : l; } function f(l, _, v, c) { l = h(l = o(l), v.decPrivateModes.bracketedPasteMode && c.rawOptions.ignoreBracketedPasteMode !== !0), v.triggerDataEvent(l, !0), _.value = ""; } function n(l, _, v) { const c = v.getBoundingClientRect(), e = l.clientX - c.left - 10, i = l.clientY - c.top - 10; _.style.width = "20px", _.style.height = "20px", _.style.left = `${e}px`, _.style.top = `${i}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 = h, s.copyHandler = function(l, _) { l.clipboardData && l.clipboardData.setData("text/plain", _.selectionText), l.preventDefault(); }, s.handlePasteEvent = function(l, _, v, c) { l.stopPropagation(), l.clipboardData && f(l.clipboardData.getData("text/plain"), _, v, c); }, s.paste = f, s.moveTextAreaUnderMouseCursor = n, s.rightClickHandler = function(l, _, v, c, e) { n(l, _, v), e && c.rightClickSelect(l), _.value = c.selectionText, _.select(); }; }, 7239: (T, s, o) => { Object.defineProperty(s, "__esModule", { value: !0 }), s.ColorContrastCache = void 0; const h = o(1505); s.ColorContrastCache = class { constructor() { this._color = new h.TwoKeyMap(), this._css = new h.TwoKeyMap(); } setCss(f, n, l) { this._css.set(f, n, l); } getCss(f, n) { return this._css.get(f, n); } setColor(f, n, l) { this._color.set(f, n, l); } getColor(f, n) { return this._color.get(f, n); } clear() { this._color.clear(), this._css.clear(); } }; }, 3656: (T, s) => { Object.defineProperty(s, "__esModule", { value: !0 }), s.addDisposableDomListener = void 0, s.addDisposableDomListener = function(o, h, f, n) { o.addEventListener(h, f, n); let l = !1; return { dispose: () => { l || (l = !0, o.removeEventListener(h, f, n)); } }; }; }, 6465: function(T, s, o) { var h = this && this.__decorate || function(e, i, t, r) { var a, u = arguments.length, p = u < 3 ? i : r === null ? r = Object.getOwnPropertyDescriptor(i, t) : r; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") p = Reflect.decorate(e, i, t, r); else for (var m = e.length - 1; m >= 0; m--) (a = e[m]) && (p = (u < 3 ? a(p) : u > 3 ? a(i, t, p) : a(i, t)) || p); return u > 3 && p && Object.defineProperty(i, t, p), p; }, f = this && this.__param || function(e, i) { return function(t, r) { i(t, r, e); }; }; Object.defineProperty(s, "__esModule", { value: !0 }), s.Linkifier2 = void 0; const n = o(3656), l = o(8460), _ = o(844), v = o(2585); let c = s.Linkifier2 = class extends _.Disposable { get currentLink() { return this._currentLink; } constructor(e) { super(), this._bufferService = e, this._linkProviders = [], this._linkCacheDisposables = [], this._isMouseOut = !0, this._wasResized = !1, this._activeLine = -1, this._onShowLinkUnderline = this.register(new l.EventEmitter()), this.onShowLinkUnderline = this._onShowLinkUnderline.event, this._onHideLinkUnderline = this.register(new l.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(e) { return this._linkProviders.push(e), { dispose: () => { const i = this._linkProviders.indexOf(e); i !== -1 && this._linkProviders.splice(i, 1); } }; } attachToDom(e, i, t) { this._element = e, this._mouseService = i, this._renderService = t, this.register((0, n.addDisposableDomListener)(this._element, "mouseleave", () => { this._isMouseOut = !0, this._clearCurrentLink(); })), this.register((0, n.addDisposableDomListener)(this._element, "mousemove", this._handleMouseMove.bind(this))), this.register((0, n.addDisposableDomListener)(this._element, "mousedown", this._handleMouseDown.bind(this))), this.register((0, n.addDisposableDomListener)(this._element, "mouseup", this._handleMouseUp.bind(this))); } _handleMouseMove(e) { if (this._lastMouseEvent = e, !this._element || !this._mouseService) return; const i = this._positionFromMouseEvent(e, this._element, this._mouseService); if (!i) return; this._isMouseOut = !1; const t = e.composedPath(); for (let r = 0; r < t.length; r++) { const a = t[r]; if (a.classList.contains("xterm")) break; if (a.classList.contains("xterm-hover")) return; } this._lastBufferCell && i.x === this._lastBufferCell.x && i.y === this._lastBufferCell.y || (this._handleHover(i), this._lastBufferCell = i); } _handleHover(e) { if (this._activeLine !== e.y || this._wasResized) return this._clearCurrentLink(), this._askForLink(e, !1), void (this._wasResized = !1); this._currentLink && this._linkAtPosition(this._currentLink.link, e) || (this._clearCurrentLink(), this._askForLink(e, !0)); } _askForLink(e, i) { var t, r; this._activeProviderReplies && i || ((t = this._activeProviderReplies) === null || t === void 0 || t.forEach((u) => { u?.forEach((p) => { p.link.dispose && p.link.dispose(); }); }), this._activeProviderReplies = /* @__PURE__ */ new Map(), this._activeLine = e.y); let a = !1; for (const [u, p] of this._linkProviders.entries()) i ? !((r = this._activeProviderReplies) === null || r === void 0) && r.get(u) && (a = this._checkLinkProviderResult(u, e, a)) : p.provideLinks(e.y, (m) => { var d, g; if (this._isMouseOut) return; const y = m?.map((L) => ({ link: L })); (d = this._activeProviderReplies) === null || d === void 0 || d.set(u, y), a = this._checkLinkProviderResult(u, e, a), ((g = this._activeProviderReplies) === null || g === void 0 ? void 0 : g.size) === this._linkProviders.length && this._removeIntersectingLinks(e.y, this._activeProviderReplies); }); } _removeIntersectingLinks(e, i) { const t = /* @__PURE__ */ new Set(); for (let r = 0; r < i.size; r++) { const a = i.get(r); if (a) for (let u = 0; u < a.length; u++) { const p = a[u], m = p.link.range.start.y < e ? 0 : p.link.range.start.x, d = p.link.range.end.y > e ? this._bufferService.cols : p.link.range.end.x; for (let g = m; g <= d; g++) { if (t.has(g)) { a.splice(u--, 1); break; } t.add(g); } } } } _checkLinkProviderResult(e, i, t) { var r; if (!this._activeProviderReplies) return t; const a = this._activeProviderReplies.get(e); let u = !1; for (let p = 0; p < e; p++) this._activeProviderReplies.has(p) && !this._activeProviderReplies.get(p) || (u = !0); if (!u && a) { const p = a.find((m) => this._linkAtPosition(m.link, i)); p && (t = !0, this._handleNewLink(p)); } if (this._activeProviderReplies.size === this._linkProviders.length && !t) for (let p = 0; p < this._activeProviderReplies.size; p++) { const m = (r = this._activeProviderReplies.get(p)) === null || r === void 0 ? void 0 : r.find((d) => this._linkAtPosition(d.link, i)); if (m) { t = !0, this._handleNewLink(m); break; } } return t; } _handleMouseDown() { this._mouseDownLink = this._currentLink; } _handleMouseUp(e) { if (!this._element || !this._mouseService || !this._currentLink) return; const i = this._positionFromMouseEvent(e, this._element, this._mouseService); i && this._mouseDownLink === this._currentLink && this._linkAtPosition(this._currentLink.link, i) && this._currentLink.link.activate(e, this._currentLink.link.text); } _clearCurrentLink(e, i) { this._element && this._currentLink && this._lastMouseEvent && (!e || !i || this._currentLink.link.range.start.y >= e && this._currentLink.link.range.end.y <= i) && (this._linkLeave(this._element, this._currentLink.link, this._lastMouseEvent), this._currentLink = void 0, (0, _.disposeArray)(this._linkCacheDisposables)); } _handleNewLink(e) { if (!this._element || !this._lastMouseEvent || !this._mouseService) return; const i = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService); i && this._linkAtPosition(e.link, i) && (this._currentLink = e, this._currentLink.state = { decorations: { underline: e.link.decorations === void 0 || e.link.decorations.underline, pointerCursor: e.link.decorations === void 0 || e.link.decorations.pointerCursor }, isHovered: !0 }, this._linkHover(this._element, e.link, this._lastMouseEvent), e.link.decorations = {}, Object.defineProperties(e.link.decorations, { pointerCursor: { get: () => { var t, r; return (r = (t = this._currentLink) === null || t === void 0 ? void 0 : t.state) === null || r === void 0 ? void 0 : r.decorations.pointerCursor; }, set: (t) => { var r, a; !((r = this._currentLink) === null || r === void 0) && r.state && this._currentLink.state.decorations.pointerCursor !== t && (this._currentLink.state.decorations.pointerCursor = t, this._currentLink.state.isHovered && ((a = this._element) === null || a === void 0 || a.classList.toggle("xterm-cursor-pointer", t))); } }, underline: { get: () => { var t, r; return (r = (t = this._currentLink) === null || t === void 0 ? void 0 : t.state) === null || r === void 0 ? void 0 : r.decorations.underline; }, set: (t) => { var r, a, u; !((r = this._currentLink) === null || r === void 0) && r.state && ((u = (a = this._currentLink) === null || a === void 0 ? void 0 : a.state) === null || u === void 0 ? void 0 : u.decorations.underline) !== t && (this._currentLink.state.decorations.underline = t, this._currentLink.state.isHovered && this._fireUnderlineEvent(e.link, t)); } } }), this._renderService && this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((t) => { if (!this._currentLink) return; const r = t.start === 0 ? 0 : t.start + 1 + this._bufferService.buffer.ydisp, a = this._bufferService.buffer.ydisp + 1 + t.end; if (this._currentLink.link.range.start.y >= r && this._currentLink.link.range.end.y <= a && (this._clearCurrentLink(r, a), this._lastMouseEvent && this._element)) { const u = this._positionFromMouseEvent(this._lastMouseEvent, this._element, this._mouseService); u && this._askForLink(u, !1); } }))); } _linkHover(e, i, t) { var r; !((r = this._currentLink) === null || r === void 0) && r.state && (this._currentLink.state.isHovered = !0, this._currentLink.state.decorations.underline && this._fireUnderlineEvent(i, !0), this._currentLink.state.decorations.pointerCursor && e.classList.add("xterm-cursor-pointer")), i.hover && i.hover(t, i.text); } _fireUnderlineEvent(e, i) { const t = e.range, r = this._bufferService.buffer.ydisp, a = this._createLinkUnderlineEvent(t.start.x - 1, t.start.y - r - 1, t.end.x, t.end.y - r - 1, void 0); (i ? this._onShowLinkUnderline : this._onHideLinkUnderline).fire(a); } _linkLeave(e, i, t) { var r; !((r = this._currentLink) === null || r === void 0) && r.state && (this._currentLink.state.isHovered = !1, this._currentLink.state.decorations.underline && this._fireUnderlineEvent(i, !1), this._currentLink.state.decorations.pointerCursor && e.classList.remove("xterm-cursor-pointer")), i.leave && i.leave(t, i.text); } _linkAtPosition(e, i) { const t = e.range.start.y * this._bufferService.cols + e.range.start.x, r = e.range.end.y * this._bufferService.cols + e.range.end.x, a = i.y * this._bufferService.cols + i.x; return t <= a && a <= r; } _positionFromMouseEvent(e, i, t) { const r = t.getCoords(e, i, this._bufferService.cols, this._bufferService.rows); if (r) return { x: r[0], y: r[1] + this._bufferService.buffer.ydisp }; } _createLinkUnderlineEvent(e, i, t, r, a) { return { x1: e, y1: i, x2: t, y2: r, cols: this._bufferService.cols, fg: a }; } }; s.Linkifier2 = c = h([f(0, v.IBufferService)], c); }, 9042: (T, 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(T, s, o) { var h = this && this.__decorate || function(c, e, i, t) { var r, a = arguments.length, u = a < 3 ? e : t === null ? t = Object.getOwnPropertyDescriptor(e, i) : t; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") u = Reflect.decorate(c, e, i, t); else for (var p = c.length - 1; p >= 0; p--) (r = c[p]) && (u = (a < 3 ? r(u) : a > 3 ? r(e, i, u) : r(e, i)) || u); return a > 3 && u && Object.defineProperty(e, i, u), u; }, f = this && this.__param || function(c, e) { return function(i, t) { e(i, t, c); }; }; Object.defineProperty(s, "__esModule", { value: !0 }), s.OscLinkProvider = void 0; const n = o(511), l = o(2585); let _ = s.OscLinkProvider = class { constructor(c, e, i) { this._bufferService = c, this._optionsService = e, this._oscLinkService = i; } provideLinks(c, e) { var i; const t = this._bufferService.buffer.lines.get(c - 1); if (!t) return void e(void 0); const r = [], a = this._optionsService.rawOptions.linkHandler, u = new n.CellData(), p = t.getTrimmedLength(); let m = -1, d = -1, g = !1; for (let y = 0; y < p; y++) if (d !== -1 || t.hasContent(y)) { if (t.loadCell(y, u), u.hasExtendedAttrs() && u.extended.urlId) { if (d === -1) { d = y, m = u.extended.urlId; continue; } g = u.extended.urlId !== m; } else d !== -1 && (g = !0); if (g || d !== -1 && y === p - 1) { const L = (i = this._oscLinkService.getLinkData(m)) === null || i === void 0 ? void 0 : i.uri; if (L) { const C = { start: { x: d + 1, y: c }, end: { x: y + (g || y !== p - 1 ? 0 : 1), y: c } }; let w = !1; if (!a?.allowNonHttpProtocols) try { const A = new URL(L); ["http:", "https:"].includes(A.protocol) || (w = !0); } catch { w = !0; } w || r.push({ text: L, range: C, activate: (A, P) => a ? a.activate(A, P, C) : v(0, P), hover: (A, P) => { var H; return (H = a?.hover) === null || H === void 0 ? void 0 : H.call(a, A, P, C); }, leave: (A, P) => { var H; return (H = a?.leave) === null || H === void 0 ? void 0 : H.call(a, A, P, C); } }); } g = !1, u.hasExtendedAttrs() && u.extended.urlId ? (d = y, m = u.extended.urlId) : (d = -1, m = -1); } } e(r); } }; function v(c, e) { if (confirm(`Do you want to navigate to ${e}? WARNING: This link could potentially be dangerous`)) { const i = window.open(); if (i) { try { i.opener = null; } catch { } i.location.href = e; } else console.warn("Opening link blocked as opener could not be cleared"); } } s.OscLinkProvider = _ = h([f(0, l.IBufferService), f(1, l.IOptionsService), f(2, l.IOscLinkService)], _); }, 6193: (T, s) => { Object.defineProperty(s, "__esModule", { value: !0 }), s.RenderDebouncer = void 0, s.RenderDebouncer = class { constructor(o, h) { this._parentWindow = o, this._renderCallback = h, 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, h, f) { this._rowCount = f, o = o !== void 0 ? o : 0, h = h !== void 0 ? h : 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, h) : h, 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), h = Math.min(this._rowEnd, this._rowCount - 1); this._rowStart = void 0, this._rowEnd = void 0, this._renderCallback(o, h), this._runRefreshCallbacks(); } _runRefreshCallbacks() { for (const o of this._refreshCallbacks) o(0); this._refreshCallbacks = []; } }; }, 5596: (T, s, o) => { Object.defineProperty(s, "__esModule", { value: !0 }), s.ScreenDprMonitor = void 0; const h = o(844); class f extends h.Disposable { constructor(l) { super(), this._parentWindow = l, this._currentDevicePixelRatio = this._parentWindow.devicePixelRatio, this.register((0, h.toDisposable)(() => { this.clearListener(); })); } setListener(l) { this._listener && this.clearListener(), this._listener = l, this._outerListener = () => { this._listener && (this._listener(this._parentWindow.devicePixelRatio, this._currentDevicePixelRatio), this._updateDpr()); }, this._updateDpr(); } _updateDpr() { var l; this._outerListener && ((l = this._resolutionMediaMatchList) === null || l === void 0 || l.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: (T, s, o) => { Object.defineProperty(s, "__esModule", { value: !0 }), s.Terminal = void 0; const h = o(3614), f = o(3656), n = o(6465), l = o(9042), _ = o(3730), v = o(1680), c = o(3107), e = o(5744), i = o(2950), t = o(1296), r = o(428), a = o(4269), u = o(5114), p = o(8934), m = o(3230), d = o(9312), g = o(4725), y = o(6731), L = o(8055), C = o(8969), w = o(8460), A = o(844), P = o(6114), H = o(8437), F = o(2584), S = o(7399), k = o(5941), x = o(9074), R = o(2585), U = o(5435), $ = o(4567), K = typeof window < "u" ? window.document : null; class j extends C.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 = P, this._keyDownHandled = !1, this._keyDownSeen = !1, this._keyPressHandled = !1, this._unprocessedDeadKey = !1, this._accessibilityManager = this.register(new A.MutableDisposable()), this._onCursorMove = this.register(new w.EventEmitter()), this.onCursorMove = this._onCursorMove.event, this._onKey = this.register(new w.EventEmitter()), this.onKey = this._onKey.event, this._onRender = this.register(new w.EventEmitter()), this.onRender = this._onRender.event, this._onSelectionChange = this.register(new w.EventEmitter()), this.onSelectionChange = this._onSelectionChange.event, this._onTitleChange = this.register(new w.EventEmitter()), this.onTitleChange = this._onTitleChange.event, this._onBell = this.register(new w.EventEmitter()), this.onBell = this._onBell.event, this._onFocus = this.register(new w.EventEmitter()), this._onBlur = this.register(new w.EventEmitter()), this._onA11yCharEmitter = this.register(new w.EventEmitter()), this._onA11yTabEmitter = this.register(new w.EventEmitter()), this._onWillOpen = this.register(new w.EventEmitter()), this._setup(), this.linkifier2 = this.register(this._instantiationService.createInstance(n.Linkifier2)), this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)), this._decorationService = this._instantiationService.createInstance(x.DecorationService), this._instantiationService.setService(R.IDecorationService, this._decorationService), this.register(this._inputHandler.onRequestBell(() => this._onBell.fire())), this.register(this._inputHandler.onRequestRefreshRows((B, I) => this.refresh(B, I))), this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus())), this.register(this._inputHandler.onRequestReset(() => this.reset())), this.register(this._inputHandler.onRequestWindowsOptionsReport((B) => this._reportWindowsOptions(B))), this.register(this._inputHandler.onColor((B) => this._handleColorEvent(B))), this.register((0, w.forwardEvent)(this._inputHandler.onCursorMove, this._onCursorMove)), this.register((0, w.forwardEvent)(this._inputHandler.onTitleChange, this._onTitleChange)), this.register((0, w.forwardEvent)(this._inputHandler.onA11yChar, this._onA11yCharEmitter)), this.register((0, w.forwardEvent)(this._inputHandler.onA11yTab, this._onA11yTabEmitter)), this.register(this._bufferService.onResize((B) => this._afterResize(B.cols, B.rows))), this.register((0, A.toDisposable)(() => { var B, I; this._customKeyEventHandler = void 0, (I = (B = this.element) === null || B === void 0 ? void 0 : B.parentNode) === null || I === void 0 || I.removeChild(this.element); })); } _handleColorEvent(b) { if (this._themeService) for (const B of b) { let I, O = ""; switch (B.index) { case 256: I = "foreground", O = "10"; break; case 257: I = "background", O = "11"; break; case 258: I = "cursor", O = "12"; break; default: I = "ansi", O = "4;" + B.index; } switch (B.type) { case 0: const q = L.color.toColorRGB(I === "ansi" ? this._themeService.colors.ansi[B.index] : this._themeService.colors[I]); this.coreService.triggerDataEvent(`${F.C0.ESC}]${O};${(0, k.toRgbString)(q)}${F.C1_ESCAPED.ST}`); break; case 1: if (I === "ansi") this._themeService.modifyColors((N) => N.ansi[B.index] = L.rgba.toColor(...B.color)); else { const N = I; this._themeService.modifyColors((G) => G[N] = L.rgba.toColor(...B.color)); } break; case 2: this._themeService.restoreColor(B.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($.AccessibilityManager, this)) : this._accessibilityManager.clear(); } _handleTextAreaFocus(b) { this.coreService.decPrivateModes.sendFocus && this.coreService.triggerDataEvent(F.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(F.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, B = this.buffer.lines.get(b); if (!B) return; const I = Math.min(this.buffer.x, this.cols - 1), O = this._renderService.dimensions.css.cell.height, q = B.getWidth(I), N = this._renderService.dimensions.css.cell.width * q, G = this.buffer.y * this._renderService.dimensions.css.cell.height, J = I * this._renderService.dimensions.css.cell.width; this.textarea.style.left = J + "px", this.textarea.style.top = G + "px", this.textarea.style.width = N + "px", this.textarea.style.height = O + "px", this.textarea.style.lineHeight = O + "px", this.textarea.style.zIndex = "-5"; } _initGlobal() { this._bindKeys(), this.register((0, f.addDisposableDomListener)(this.element, "copy", (B) => { this.hasSelection() && (0, h.copyHandler)(B, this._selectionService); })); const b = (B) => (0, h.handlePasteEvent)(B, this.textarea, this.coreService, this.optionsService); this.register((0, f.addDisposableDomListener)(this.textarea, "paste", b)), this.register((0, f.addDisposableDomListener)(this.element, "paste", b)), P.isFirefox ? this.register((0, f.addDisposableDomListener)(this.element, "mousedown", (B) => { B.button === 2 && (0, h.rightClickHandler)(B, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord); })) : this.register((0, f.addDisposableDomListener)(this.element, "contextmenu", (B) => { (0, h.rightClickHandler)(B, this.textarea, this.screenElement, this._selectionService, this.options.rightClickSelectsWord); })), P.isLinux && this.register((0, f.addDisposableDomListener)(this.element, "auxclick", (B) => { B.button === 1 && (0, h.moveTextAreaUnderMouseCursor)(B, 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 B; 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 I = K.createDocumentFragment(); this._viewportElement = K.createElement("div"), this._viewportElement.classList.add("xterm-viewport"), I.appendChild(this._viewportElement), this._viewportScrollArea = K.createElement("div"), this._viewportScrollArea.classList.add("xterm-scroll-area"), this._viewportElement.appendChild(this._viewportScrollArea), this.screenElement = K.createElement("div"), this.screenElement.classList.add("xterm-screen"), this._helperContainer = K.createElement("div"), this._helperContainer.classList.add("xterm-helpers"), this.screenElement.appendChild(this._helperContainer), I.appendChild(this.screenElement), this.textarea = K.createElement("textarea"), this.textarea.classList.add("xterm-helper-textarea"), this.textarea.setAttribute("aria-label", l.promptLabel), P.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(u.CoreBrowserService, this.textarea, (B = this._document.defaultView) !== null && B !== void 0 ? B : window), this._instantiationService.setService(g.ICoreBrowserService, this._coreBrowserService), this.register((0, f.addDisposableDomListener)(this.textarea, "focus", (O) => this._handleTextAreaFocus(O))), this.register((0, f.addDisposableDomListener)(this.textarea, "blur", () => this._handleTextAreaBlur())), this._helperContainer.appendChild(this.textarea), this._charSizeService = this._instantiationService.createInstance(r.CharSizeService, this._document, this._helperContainer), this._instantiationService.setService(g.ICharSizeService, this._charSizeService), this._themeService = this._instantiationService.createInstance(y.ThemeService), this._instantiationService.setService(g.IThemeService, this._themeService), this._characterJoinerService = this._instantiationService.createInstance(a.CharacterJoinerService), this._instantiationService.setService(g.ICharacterJoinerService, this._characterJoinerService), this._renderService = this.register(this._instantiationService.createInstance(m.RenderService, this.rows, this.screenElement)), this._instantiationService.setService(g.IRenderService, this._renderService), this.register(this._renderService.onRenderedViewportChange((O) => this._onRender.fire(O))), this.onResize((O) => this._renderService.resize(O.cols, O.rows)), this._compositionView = K.createElement("div"), this._compositionView.classList.add("composition-view"), this._compositionHelper = this._instantiationService.createInstance(i.CompositionHelper, this.textarea, this._compositionView), this._helperContainer.appendChild(this._compositionView), this.element.appendChild(I); try { this._onWillOpen.fire(this.element); } catch { } this._renderService.hasRenderer() || this._renderService.setRenderer(this._createRenderer()), this._mouseService = this._instantiationService.createInstance(p.MouseService), this._instantiationService.setService(g.IMouseService, this._mouseService), this.viewport = this._instantiationService.createInstance(v.Viewport, this._viewportElement, this._viewportScrollArea), this.viewport.onRequestScrollLines((O) => this.scrollLines(O.amount, O.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(d.SelectionService, this.element, this.screenElement, this.linkifier2)), this._instantiationService.setService(g.ISelectionService, this._selectionService), this.register(this._selectionService.onRequestScrollLines((O) => this.scrollLines(O.amount, O.suppressScrollEvent))), this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire())), this.register(this._selectionService.onRequestRedraw((O) => this._renderService.handleSelectionChanged(O.start, O.end, O.columnSelectMode))), this.register(this._selectionService.onLinuxMouseSelection((O) => { this.textarea.value = O, this.textarea.focus(), this.textarea.select(); })), this.register(this._onScroll.event((O) => { 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(c.BufferDecorationRenderer, this.screenElement)), this.register((0, f.addDisposableDomListener)(this.element, "mousedown", (O) => this._selectionService.handleMouseDown(O))), 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($.AccessibilityManager, this)), this.register(this.optionsService.onSpecificOptionChange("screenReaderMode", (O) => this._handleScreenReaderModeOptionChange(O))), this.options.overviewRulerWidth && (this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(e.OverviewRulerRenderer, this._viewportElement, this.screenElement))), this.optionsService.onSpecificOptionChange("overviewRulerWidth", (O) => { !this._overviewRulerRenderer && O && this._viewportElement && this.screenElement && (this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(e.OverviewRulerRenderer, this._viewportElement, this.screenElement))); }), this._charSizeService.measure(), this.refresh(0, this.rows - 1), this._initGlobal(), this.bindMouse(); } _createRenderer() { return this._instantiationService.createInstance(t.DomRenderer, this.element, this.screenElement, this._viewportElement, this.linkifier2); } bindMouse() { const b = this, B = this.element; function I(N) { const G = b._mouseService.getMouseReportCoords(N, b.screenElement); if (!G) return !1; let J, Q; switch (N.overrideType || N.type) { case "mousemove": Q = 32, N.buttons === void 0 ? (J = 3, N.button !== void 0 && (J = N.button < 3 ? N.button : 3)) : J = 1 & N.buttons ? 0 : 4 & N.buttons ? 1 : 2 & N.buttons ? 2 : 3; break; case "mouseup": Q = 0, J = N.button < 3 ? N.button : 3; break; case "mousedown": Q = 1, J = N.button < 3 ? N.button : 3; break; case "wheel": if (b.viewport.getLinesScrolled(N) === 0) return !1; Q = N.deltaY < 0 ? 0 : 1, J = 4; break; default: return !1; } return !(Q === void 0 || J === void 0 || J > 4) && b.coreMouseService.triggerMouseEvent({ col: G.col, row: G.row, x: G.x, y: G.y, button: J, action: Q, ctrl: N.ctrlKey, alt: N.altKey, shift: N.shiftKey }); } const O = { mouseup: null, wheel: null, mousedrag: null, mousemove: null }, q = { mouseup: (N) => (I(N), N.buttons || (this._document.removeEventListener("mouseup", O.mouseup), O.mousedrag && this._document.removeEventListener("mousemove", O.mousedrag)), this.cancel(N)), wheel: (N) => (I(N), this.cancel(N, !0)), mousedrag: (N) => { N.buttons && I(N); }, mousemove: (N) => { N.buttons || I(N); } }; this.register(this.coreMouseService.onProtocolChange((N) => { N ? (this.optionsService.rawOptions.logLevel === "debug" && this._logService.debug("Binding to mouse events:", this.coreMouseService.explainEvents(N)), 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 & N ? O.mousemove || (B.addEventListener("mousemove", q.mousemove), O.mousemove = q.mousemove) : (B.removeEventListener("mousemove", O.mousemove), O.mousemove = null), 16 & N ? O.wheel || (B.addEventListener("wheel", q.wheel, { passive: !1 }), O.wheel = q.wheel) : (B.removeEventListener("wheel", O.wheel), O.wheel = null), 2 & N ? O.mouseup || (B.addEventListener("mouseup", q.mouseup), O.mouseup = q.mouseup) : (this._document.removeEventListener("mouseup", O.mouseup), B.removeEventListener("mouseup", O.mouseup), O.mouseup = null), 4 & N ? O.mousedrag || (O.mousedrag = q.mousedrag) : (this._document.removeEventListener("mousemove", O.mousedrag), O.mousedrag = null); })), this.coreMouseService.activeProtocol = this.coreMouseService.activeProtocol, this.register((0, f.addDisposableDomListener)(B, "mousedown", (N) => { if (N.preventDefault(), this.focus(), this.coreMouseService.areMouseEventsActive && !this._selectionService.shouldForceSelection(N)) return I(N), O.mouseup && this._document.addEventListener("mouseup", O.mouseup), O.mousedrag && this._document.addEventListener("mousemove", O.mousedrag), this.cancel(N); })), this.register((0, f.addDisposableDomListener)(B, "wheel", (N) => { if (!O.wheel) { if (!this.buffer.hasScrollback) { const G = this.viewport.getLinesScrolled(N); if (G === 0) return; const J = F.C0.ESC + (this.coreService.decPrivateModes.applicationCursorKeys ? "O" : "[") + (N.deltaY < 0 ? "A" : "B"); let Q = ""; for (let ne = 0; ne < Math.abs(G); ne++) Q += J; return this.coreService.triggerDataEvent(Q, !0), this.cancel(N, !0); } return this.viewport.handleWheel(N) ? this.cancel(N) : void 0; } }, { passive: !1 })), this.register((0, f.addDisposableDomListener)(B, "touchstart", (N) => { if (!this.coreMouseService.areMouseEventsActive) return this.viewport.handleTouchStart(N), this.cancel(N); }, { passive: !0 })), this.register((0, f.addDisposableDomListener)(B, "touchmove", (N) => { if (!this.coreMouseService.areMouseEventsActive) return this.viewport.handle